-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
78 lines (66 loc) · 1.95 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
{
description = "Alternative implementation of the Emulab client-side programs";
inputs = {
mars-std.url = "github:mars-research/mars-std";
crane.url = "github:ipetkov/crane";
};
outputs = { self, mars-std, crane, ... }: let
# System types to support.
supportedSystems = [ "x86_64-linux" ];
# Rust nightly version.
nightlyVersion = "2022-09-15";
in mars-std.lib.eachSystem supportedSystems (system: let
pkgs = mars-std.legacyPackages.${system};
inherit (pkgs) lib;
inherit (pkgs.rust) toRustTargetSpec;
targetOverrides = {
"x86_64-linux" = "x86_64-unknown-linux-musl";
};
buildTarget = targetOverrides.${system} or (toRustTargetSpec pkgs.stdenv.hostPlatform);
rustNightly = pkgs.rust-bin.nightly.${nightlyVersion}.default.override {
extensions = [ "rust-src" "rust-analyzer-preview" ];
targets = [
(toRustTargetSpec pkgs.stdenv.hostPlatform)
buildTarget
];
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustNightly;
miniond = craneLib.buildPackage {
src = craneLib.cleanCargoSource ./.;
cargoExtraArgs = "--target ${buildTarget}";
};
in rec {
packages = {
inherit miniond;
};
defaultPackage = self.packages.${system}.miniond;
devShell = pkgs.mkShell {
inputsFrom = [ defaultPackage ];
nativeBuildInputs = with pkgs; [
cargo-outdated
];
};
}) // {
nixosModule = { pkgs, ... }: {
imports = [
./nixos/emulab.nix
./nixos/miniond.nix
];
nixpkgs.overlays = [
(_: super: {
miniond = self.packages.${pkgs.system}.miniond;
})
];
};
nixosConfigurations.testSystem = mars-std.inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModule
({ pkgs, lib, ... }: {
hardware.emulab.enable = true;
boot.isContainer = true;
})
];
};
};
}