-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
88 lines (73 loc) · 2.19 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{
description = "webpack but for C code.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
rustVersion = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
rustPlatform = pkgs.makeRustPlatform {
cargo = rustVersion;
rustc = rustVersion;
};
cargoToml = fromTOML (builtins.readFile ./Cargo.toml);
cbundlDrv = rustPlatform.buildRustPackage {
pname = cargoToml.package.name;
version = cargoToml.package.version;
src = ./.;
nativeBuildInputs = with pkgs; [
# Wanted by the build script.
git
nettools # only for hostname
];
cargoLock.lockFile = ./Cargo.lock;
meta = with pkgs.lib; {
description = cargoToml.package.description;
homepage = cargoToml.package.homepage;
downloadPage = "${cargoToml.package.repository}/releases";
license = licenses.asl20;
mainProgram = cargoToml.package.name;
platforms = platforms.all;
};
};
in
{
formatter = pkgs.nixpkgs-fmt;
devShells = rec {
# For writing code.
# $ nix develop
dev = pkgs.mkShell {
packages = [ rustVersion ];
};
# For editing the artwork.
# $ nix develop '.#art'
art = pkgs.mkShell {
packages = with pkgs; [
inkscape
scour
];
};
default = dev;
};
packages.default = cbundlDrv;
apps.default = {
type = "app";
program = "${cbundlDrv}/bin/cbundl";
};
}
);
}