Merge pull request #216292 from NickCao/zram
zram-generator: use buildRustPackage instead of stdenv.mkDerivation
This commit is contained in:
commit
5c9f00f1d4
1 changed files with 17 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
||||||
{ lib
|
{ lib
|
||||||
, stdenv
|
, stdenv
|
||||||
, fetchFromGitHub
|
, fetchFromGitHub
|
||||||
|
, rust
|
||||||
, rustPlatform
|
, rustPlatform
|
||||||
, pkg-config
|
, pkg-config
|
||||||
, ronn
|
, ronn
|
||||||
|
@ -9,7 +10,7 @@
|
||||||
, nixosTests
|
, nixosTests
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
pname = "zram-generator";
|
pname = "zram-generator";
|
||||||
version = "1.1.2";
|
version = "1.1.2";
|
||||||
|
|
||||||
|
@ -20,23 +21,20 @@ stdenv.mkDerivation rec {
|
||||||
hash = "sha256-n+ZOWU+sPq9DcHgzQWTxxfMmiz239qdetXypqdy33cM=";
|
hash = "sha256-n+ZOWU+sPq9DcHgzQWTxxfMmiz239qdetXypqdy33cM=";
|
||||||
};
|
};
|
||||||
|
|
||||||
cargoDeps = rustPlatform.importCargoLock {
|
|
||||||
lockFile = ./Cargo.lock;
|
|
||||||
};
|
|
||||||
|
|
||||||
# RFE: Include Cargo.lock in sources
|
# RFE: Include Cargo.lock in sources
|
||||||
# https://github.com/systemd/zram-generator/issues/65
|
# https://github.com/systemd/zram-generator/issues/65
|
||||||
|
cargoLock.lockFile = ./Cargo.lock;
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
cp ${./Cargo.lock} Cargo.lock
|
cp ${./Cargo.lock} Cargo.lock
|
||||||
|
substituteInPlace Makefile \
|
||||||
|
--replace 'target/$(BUILDTYPE)' 'target/${rust.toRustTargetSpec stdenv.hostPlatform}/$(BUILDTYPE)'
|
||||||
substituteInPlace src/generator.rs \
|
substituteInPlace src/generator.rs \
|
||||||
--replace 'Command::new("systemd-detect-virt")' 'Command::new("${systemd}/bin/systemd-detect-virt")' \
|
--replace 'Command::new("systemd-detect-virt")' 'Command::new("${systemd}/bin/systemd-detect-virt")' \
|
||||||
--replace 'Command::new("modprobe")' 'Command::new("${kmod}/bin/modprobe")'
|
--replace 'Command::new("modprobe")' 'Command::new("${kmod}/bin/modprobe")'
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nativeBuildInputs = with rustPlatform; [
|
nativeBuildInputs = [
|
||||||
cargoSetupHook
|
|
||||||
rust.cargo
|
|
||||||
rust.rustc
|
|
||||||
pkg-config
|
pkg-config
|
||||||
ronn
|
ronn
|
||||||
];
|
];
|
||||||
|
@ -45,7 +43,16 @@ stdenv.mkDerivation rec {
|
||||||
systemd
|
systemd
|
||||||
];
|
];
|
||||||
|
|
||||||
makeFlags = [
|
preBuild = ''
|
||||||
|
# embedded into the binary at build time
|
||||||
|
# https://github.com/systemd/zram-generator/blob/v1.1.2/Makefile#LL11-L11C56
|
||||||
|
export SYSTEMD_UTIL_DIR=$($PKG_CONFIG --variable=systemdutildir systemd)
|
||||||
|
'';
|
||||||
|
|
||||||
|
dontCargoInstall = true;
|
||||||
|
|
||||||
|
installFlags = [
|
||||||
|
"-o program" # already built by cargoBuildHook
|
||||||
"PREFIX=$(out)"
|
"PREFIX=$(out)"
|
||||||
"SYSTEMD_SYSTEM_UNIT_DIR=$(out)/lib/systemd/system"
|
"SYSTEMD_SYSTEM_UNIT_DIR=$(out)/lib/systemd/system"
|
||||||
"SYSTEMD_SYSTEM_GENERATOR_DIR=$(out)/lib/systemd/system-generators"
|
"SYSTEMD_SYSTEM_GENERATOR_DIR=$(out)/lib/systemd/system-generators"
|
||||||
|
|
Loading…
Reference in a new issue