14 rustPlatform.buildRustPackage rec {
15 pname = "zram-generator";
18 src = fetchFromGitHub {
22 hash = "sha256-aGBvvjGKZ5biruwmJ0ITakqPhTWs9hspRIE9QirqstA=";
25 # RFE: Include Cargo.lock in sources
26 # https://github.com/systemd/zram-generator/issues/65
27 cargoLock.lockFile = ./Cargo.lock;
30 cp ${./Cargo.lock} Cargo.lock
31 substituteInPlace Makefile \
32 --replace-fail 'target/$(BUILDTYPE)' 'target/${stdenv.hostPlatform.rust.rustcTargetSpec}/$(BUILDTYPE)'
33 substituteInPlace src/generator.rs \
34 --replace-fail 'Command::new("systemd-detect-virt")' 'Command::new("${systemd}/bin/systemd-detect-virt")' \
35 --replace-fail 'Command::new("modprobe")' 'Command::new("${kmod}/bin/modprobe")'
36 substituteInPlace src/config.rs \
37 --replace-fail 'Command::new("/bin/sh")' 'Command::new("${bash}/bin/sh")'
50 # embedded into the binary at build time
51 # https://github.com/systemd/zram-generator/blob/v1.2.0/Makefile#LL11-L11C56
52 export SYSTEMD_UTIL_DIR=$($PKG_CONFIG --variable=systemdutildir systemd)
55 dontCargoInstall = true;
58 "-o program" # already built by cargoBuildHook
60 "SYSTEMD_SYSTEM_UNIT_DIR=$(out)/lib/systemd/system"
61 "SYSTEMD_SYSTEM_GENERATOR_DIR=$(out)/lib/systemd/system-generators"
66 inherit (nixosTests) zram-generator;
68 updateScript = ./update.sh;
72 homepage = "https://github.com/systemd/zram-generator";
73 license = licenses.mit;
74 description = "Systemd unit generator for zram devices";
75 maintainers = with maintainers; [ nickcao ];