forked from aurae-runtime/aurae
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
80 lines (71 loc) · 2.63 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
{
inputs = {
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.rust-overlay.follows = "rust-overlay";
};
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 ];
};
patchedSource = pkgs.runCommand "patch-source" {} ''
set +x
# Copy the api folder into the two projects
mkdir -p $out
cp -r ${builtins.toString ./.}/* $out/
chmod -R +w $out
cd $out
ls -al
cp -r api auraed
cp -r api auraescript
# Replace '../api' with 'api' in both scripts
sed -i 's/\.\.\/api/api/g' auraed/build.rs
sed -i 's/\.\.\/api/api/g' auraescript/build.rs
'';
# create the workspace & dependencies package set
rustPkgs = pkgs.rustBuilder.makePackageSet {
rustVersion = "1.64.0";
packageFun = import ./Cargo.nix;
workspaceSrc = patchedSource;
packageOverrides = pkgs: pkgs.rustBuilder.overrides.all ++ [
(pkgs.rustBuilder.rustLib.makeOverride {
name = "libseccomp";
overrideAttrs = drv: {
propagatedNativeBuildInputs = drv.propagatedNativeBuildInputs or [ ] ++ [
pkgs.libseccomp.dev
];
};
})
];
};
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
auraed = (rustPkgs.workspace.auraed {}).bin;
auraescript = (rustPkgs.workspace.auraescript {}).bin;
# nix build
default = packages.auraed; # rec
};
}
);
}