-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
71 lines (61 loc) · 2.35 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=release-23.05";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
cargo2nix = {
url = "github:cargo2nix/cargo2nix/release-0.11.0";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.rust-overlay.follows = "rust-overlay";
};
};
outputs = inputs: with inputs;
# 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 {
packageFun = import ./Cargo.nix;
rustVersion = "1.73.0";
};
# The workspace defines a development shell with all of the dependencies
# and environment settings necessary for a regular `cargo build`
workspaceShell = rustPkgs.workspaceShell {
# This adds cargo2nix to the project shell via the cargo2nix flake
packages = [ cargo2nix.packages."${system}".cargo2nix ];
};
in rec {
# this is the output (recursive) set (expressed for each system)
devShells = {
default = workspaceShell; # nix develop
};
# the packages in `nix build .#packages.<system>.<name>`
packages = {
# nix build .#unixsocks
# nix build .#packages.x86_64-linux.unixsocks
unixsocks = (rustPkgs.workspace.unixsocks {}).bin;
# nix build
default = packages.unixsocks;
};
# nix run github:positron-solutions/unixsocks
apps = rec {
unixsocks = { type = "app"; program = "${packages.default}/bin/unixsocks"; };
default = unixsocks;
};
}
);
}