Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, stdenv
3, fetchFromGitHub
4, rustPlatform
5, cargo
6, rustc
7, pkg-config
8, asciidoc
9, ncurses
10, glibc
11, dbus
12, cryptsetup
13, util-linux
14, udev
15, lvm2
16, systemd
17, xfsprogs
18, thin-provisioning-tools
19, clevis
20, jose
21, jq
22, curl
23, tpm2-tools
24, coreutils
25, clevisSupport ? false
26, nixosTests
27}:
28
29stdenv.mkDerivation rec {
30 pname = "stratisd";
31 version = "3.5.5";
32
33 src = fetchFromGitHub {
34 owner = "stratis-storage";
35 repo = pname;
36 rev = "v${version}";
37 hash = "sha256-d8vGwxvfNbN234rZJm4nmsDqvp8OVGEvazM6hI7BGvs=";
38 };
39
40 cargoDeps = rustPlatform.importCargoLock {
41 lockFile = ./Cargo.lock;
42 outputHashes = {
43 "loopdev-0.4.0" = "sha256-nV52zjsg5u6++J8CdN2phii8AwjHg1uap2lt+U8obDQ=";
44 };
45 };
46
47 postPatch = ''
48 substituteInPlace udev/61-stratisd.rules \
49 --replace stratis-base32-decode "$out/lib/udev/stratis-base32-decode" \
50 --replace stratis-str-cmp "$out/lib/udev/stratis-str-cmp"
51
52 substituteInPlace systemd/stratis-fstab-setup \
53 --replace stratis-min "$out/bin/stratis-min" \
54 --replace systemd-ask-password "${systemd}/bin/systemd-ask-password" \
55 --replace sleep "${coreutils}/bin/sleep" \
56 --replace udevadm "${udev}/bin/udevadm"
57 '';
58
59 nativeBuildInputs = [
60 rustPlatform.cargoSetupHook
61 rustPlatform.bindgenHook
62 cargo
63 rustc
64 pkg-config
65 asciidoc
66 ncurses # tput
67 ];
68
69 buildInputs = [
70 glibc
71 glibc.static
72 dbus
73 cryptsetup
74 util-linux
75 udev
76 lvm2
77 ];
78
79 outputs = ["out" "initrd"];
80
81 EXECUTABLES_PATHS = lib.makeBinPath ([
82 xfsprogs
83 thin-provisioning-tools
84 ] ++ lib.optionals clevisSupport [
85 clevis
86 jose
87 jq
88 cryptsetup
89 curl
90 tpm2-tools
91 coreutils
92 ]);
93
94 makeFlags = [ "PREFIX=${placeholder "out"}" "INSTALL=install" ];
95 buildFlags = [ "build-all" ];
96
97 doCheck = true;
98 checkTarget = "test";
99
100 # remove files for supporting dracut
101 postInstall = ''
102 mkdir -p "$initrd/bin"
103 cp "dracut/90stratis/stratis-rootfs-setup" "$initrd/bin"
104 mkdir -p "$initrd/lib/systemd/system"
105 substitute "dracut/90stratis/stratisd-min.service" "$initrd/lib/systemd/system/stratisd-min.service" \
106 --replace /usr "$out" \
107 --replace mkdir "${coreutils}/bin/mkdir"
108 mkdir -p "$initrd/lib/udev/rules.d"
109 cp udev/61-stratisd.rules "$initrd/lib/udev/rules.d"
110 rm -r "$out/lib/dracut"
111 rm -r "$out/lib/systemd/system-generators"
112 '';
113
114 passthru.tests = nixosTests.stratis;
115
116 meta = with lib; {
117 description = "Easy to use local storage management for Linux";
118 homepage = "https://stratis-storage.github.io";
119 license = licenses.mpl20;
120 maintainers = with maintainers; [ nickcao ];
121 platforms = [ "x86_64-linux" ];
122 };
123}