Merge pull request #14178 from the-kenny/systemd-cryptsetup-external-generator

Systemd: Allow specifying external generators
This commit is contained in:
Eelco Dolstra 2016-04-12 11:26:22 +02:00
commit dddb62d3e3
3 changed files with 50 additions and 2 deletions

View File

@ -472,6 +472,13 @@ in
'';
};
systemd.generator-packages = mkOption {
default = [];
type = types.listOf types.package;
example = literalExample "[ pkgs.systemd-cryptsetup-generator ]";
description = "Packages providing systemd generators.";
};
systemd.defaultUnit = mkOption {
default = "multi-user.target";
type = types.str;
@ -628,7 +635,18 @@ in
environment.systemPackages = [ systemd ];
environment.etc = {
environment.etc = let
# generate contents for /etc/systemd/system-generators from
# systemd.generators and systemd.generator-packages
generators = pkgs.runCommand "system-generators" { packages = cfg.generator-packages; } ''
mkdir -p $out
for package in $packages
do
ln -s $package/lib/systemd/system-generators/* $out/
done;
${concatStrings (mapAttrsToList (generator: target: "ln -s ${target} $out/${generator};\n") cfg.generators)}
'';
in ({
"systemd/system".source = generateUnits "system" cfg.units upstreamSystemUnits upstreamSystemWants;
"systemd/user".source = generateUnits "user" cfg.user.units upstreamUserUnits [];
@ -667,7 +685,9 @@ in
${concatStringsSep "\n" cfg.tmpfiles.rules}
'';
} // mapAttrs' (n: v: nameValuePair "systemd/system-generators/${n}" {"source"=v;}) cfg.generators;
"systemd/system-generators" = { source = generators; };
});
system.activationScripts.systemd = stringAfter [ "groups" ]
''

View File

@ -0,0 +1,25 @@
{ stdenv, systemd, cryptsetup }:
assert stdenv.isLinux;
stdenv.lib.overrideDerivation systemd (p: {
version = p.version;
name = "systemd-cryptsetup-generator";
nativeBuildInputs = p.nativeBuildInputs ++ [ cryptsetup ];
outputs = [ "out" ];
buildPhase = ''
make $makeFlags built-sources
make $makeFlags systemd-cryptsetup
make $makeFlags systemd-cryptsetup-generator
'';
installPhase = ''
mkdir -p $out/lib/systemd/
cp systemd-cryptsetup $out/lib/systemd/systemd-cryptsetup
mkdir -p $out/lib/systemd/system-generators/
cp systemd-cryptsetup-generator $out/lib/systemd/system-generators/systemd-cryptsetup-generator
'';
})

View File

@ -11006,6 +11006,9 @@ in
linuxHeaders = linuxHeaders_3_18;
};
# standalone cryptsetup generator for systemd
systemd-cryptsetup-generator = callPackage ../os-specific/linux/systemd/cryptsetup-generator.nix { };
# In nixos, you can set systemd.package = pkgs.systemd_with_lvm2 to get
# LVM2 working in systemd.
systemd_with_lvm2 = pkgs.lib.overrideDerivation pkgs.systemd (p: {