forked from Patryk27/lxd-snapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
94 lines (78 loc) · 2.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
{
description = "lxd-snapper: LXD snapshots, automated";
inputs = {
naersk = {
url = "github:nmattia/naersk";
};
nixpkgs = {
url = "github:nixos/nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
};
};
outputs = { self, naersk, nixpkgs, rust-overlay }:
let
mkPackage = { system, target, RUSTFLAGS }:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
rust-overlay.overlay
];
};
rust = (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain).override {
targets = [ target ];
};
naersk' = pkgs.callPackage naersk {
cargo = rust;
rustc = rust;
};
# Generates a new derivation without the ./tests directory; allows to
# save a lot of time on incremental `nix flake check`-s, as otherwise
# any change to any end-to-end test would force lxd-snapper to be
# rebuilt from scratch.
src = pkgs.runCommand "src" { } ''
mkdir $out
ln -s "${./Cargo.lock}" $out/Cargo.lock
ln -s "${./Cargo.toml}" $out/Cargo.toml
ln -s "${./docs}" $out/docs
ln -s "${./libs}" $out/libs
ln -s "${./src}" $out/src
'';
in
naersk'.buildPackage {
inherit src RUSTFLAGS;
doCheck = true;
cargoTestOptions = args: args ++ [ "--workspace" ];
CARGO_BUILD_TARGET = target;
};
mkCheck = { system }:
import ./tests {
inherit nixpkgs;
lxd-snapper = self.defaultPackage."${system}";
};
in
{
defaultPackage = {
i686-linux = mkPackage {
system = "i686-linux";
target = "i686-unknown-linux-musl";
RUSTFLAGS = "";
};
x86_64-linux = mkPackage {
system = "x86_64-linux";
target = "x86_64-unknown-linux-musl";
RUSTFLAGS = "-C relocation-model=dynamic-no-pic";
};
};
checks = {
i686-linux = mkCheck {
system = "i686-linux";
};
x86_64-linux = mkCheck {
system = "x86_64-linux";
};
};
};
}