sqlite_orm: 1.9 -> 1.9.1 (#379250)
[NixPkgs.git] / pkgs / by-name / zr / zram-generator / package.nix
blobd92690792bba6689a6f75c0f0f5c080fc41b79b4
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   rustPlatform,
6   pkg-config,
7   bash,
8   ronn,
9   systemd,
10   kmod,
11   nixosTests,
14 rustPlatform.buildRustPackage rec {
15   pname = "zram-generator";
16   version = "1.2.1";
18   src = fetchFromGitHub {
19     owner = "systemd";
20     repo = pname;
21     rev = "v${version}";
22     hash = "sha256-aGBvvjGKZ5biruwmJ0ITakqPhTWs9hspRIE9QirqstA=";
23   };
25   # RFE: Include Cargo.lock in sources
26   # https://github.com/systemd/zram-generator/issues/65
27   cargoLock.lockFile = ./Cargo.lock;
29   postPatch = ''
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")'
38   '';
40   nativeBuildInputs = [
41     pkg-config
42     ronn
43   ];
45   buildInputs = [
46     systemd
47   ];
49   preBuild = ''
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)
53   '';
55   dontCargoInstall = true;
57   installFlags = [
58     "-o program" # already built by cargoBuildHook
59     "PREFIX=$(out)"
60     "SYSTEMD_SYSTEM_UNIT_DIR=$(out)/lib/systemd/system"
61     "SYSTEMD_SYSTEM_GENERATOR_DIR=$(out)/lib/systemd/system-generators"
62   ];
64   passthru = {
65     tests = {
66       inherit (nixosTests) zram-generator;
67     };
68     updateScript = ./update.sh;
69   };
71   meta = with lib; {
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 ];
76   };