-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflake.nix
96 lines (95 loc) · 3.25 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
89
90
91
92
93
94
95
96
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
crane.url = "github:ipetkov/crane";
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane }:
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ]
(system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
elfutils' = (pkgs.elfutils.override { enableDebuginfod = false; }).overrideAttrs (attrs: {
configureFlags = attrs.configureFlags ++ [ "--without-zstd" ];
});
buildInputs = with pkgs; [
llvmPackages_16.clang
llvmPackages_16.libcxx
llvmPackages_16.libclang
llvmPackages_16.lld
elfutils'
zlib.static
zlib.dev
glibc
glibc.static
protobuf
];
nativeBuildInputs = with pkgs; [
pkg-config
];
rust-toolchain = pkgs.rust-bin.nightly.latest.default;
craneLib = (crane.mkLib nixpkgs.legacyPackages.${system}).overrideToolchain rust-toolchain;
lightswitch = craneLib.buildPackage {
src = ./.;
doCheck = false;
buildInputs = buildInputs;
nativeBuildInputs = nativeBuildInputs;
hardeningDisable = [ "all" ];
LIBCLANG_PATH = with pkgs; lib.makeLibraryPath [ llvmPackages_16.libclang ];
LIBBPF_SYS_LIBRARY_PATH = with pkgs; lib.makeLibraryPath [ zlib.static elfutils' ];
};
in
with pkgs;
{
formatter = pkgs.nixpkgs-fmt;
packages = {
default = lightswitch;
container = pkgs.dockerTools.buildLayeredImage {
name = "lightswitch";
config = {
Entrypoint = [ "${lightswitch}/bin/lightswitch" ];
Env = [
"RUST_BACKTRACE=1"
];
};
};
vmtest = (import ./vm.nix { inherit pkgs; }).run-vmtest lightswitch;
};
devShells.default = mkShell {
nativeBuildInputs = nativeBuildInputs;
buildInputs = buildInputs ++ [
rust-toolchain
# Debugging tools
strace
gdb
# Upload container image to registry
skopeo
# Cargo subcommand tools
## To upgrade deps
cargo-edit
## Snapshot testing
cargo-insta
## Remove unused deps
cargo-shear
## Release to crates.io
cargo-release
# Commented out because this is typically not cached and it's rarely used
# ocamlPackages.magic-trace
];
hardeningDisable = [ "all" ];
LIBCLANG_PATH = lib.makeLibraryPath [ llvmPackages_16.libclang ];
LIBBPF_SYS_LIBRARY_PATH = lib.makeLibraryPath [ zlib.static elfutils' ];
RUST_GDB = "${gdb}/bin/gdb";
};
}
);
}