forked from cargo2nix/cargo2nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
46 lines (39 loc) · 1.53 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
{
inputs = {
cargo2nix.url = "path:../../";
# Use a github flake URL for real packages
# cargo2nix.url = "github:cargo2nix/cargo2nix/release-0.11.0";
flake-utils.follows = "cargo2nix/flake-utils";
nixpkgs.follows = "cargo2nix/nixpkgs";
};
outputs = inputs: with inputs; # pass through all inputs and bring them into scope
# Build the output set for each default system and map system sets into
# attributes, resulting in paths such as:
# nix build .#packages.x86_64-linux.<name>
flake-utils.lib.eachDefaultSystem (system:
# let-in expressions, very similar to Rust's let bindings. These names
# are used to express the output but not themselves paths in the output.
let
# create nixpkgs that contains rustBuilder from cargo2nix overlay
pkgs = import nixpkgs {
inherit system;
overlays = [ cargo2nix.overlays.default ];
};
# create the workspace & dependencies package set
rustPkgs = pkgs.rustBuilder.makePackageSet {
rustVersion = "1.61.0";
packageFun = import ./Cargo.nix;
};
in rec {
# this is the output (recursive) set (expressed for each system)
# the packages in `nix build .#packages.<system>.<name>`
packages = {
# nix build .#hello-world
# nix build .#packages.x86_64-linux.hello-world
hello-world = (rustPkgs.workspace.hello-world {}).bin;
# nix build
default = packages.hello-world; # rec
};
}
);
}