git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/systemd.tmpfiles.packages: fix an edge case

symlinkJoin can break (silently) when the passed paths contain symlinks to directories. This should work now. Down-side: when lib/tmpfiles.d doesn't exist for some passed package, the error message is a little less explicit, because we never get to the postBuild phase (and symlinkJoin doesn't provide a better way): /nix/store/HASH-NAME/lib/tmpfiles.d: No such file or directory Also, it seemed pointless to create symlinks for whole package trees and using only a part of the result (usually very small part).

commit3937923f81b08de1e7f8593ca62d05b8337daaaf authorVladimír Čunát <v@cunat.cz> dateSun 16 Aug 2020, 10:14 (6 years ago) parent3ab2bf6
2 files changed+7−5
nixos/modules/system/boot/systemd.nix+5−5 pkgs/build-support/trivial-builders.nix+2
nixos/modules/system/boot/systemd.nix+5−5
@@ -1012,18 +1012,18 @@ in
10121012 "sysctl.d/50-coredump.conf".source = "${systemd}/example/sysctl.d/50-coredump.conf";
10131013 "sysctl.d/50-default.conf".source = "${systemd}/example/sysctl.d/50-default.conf";
10141014
1015− "tmpfiles.d".source = (pkgs.symlinkJoin {
1015+ "tmpfiles.d".source = pkgs.symlinkJoin {
10161016 name = "tmpfiles.d";
1017− paths = cfg.tmpfiles.packages;
1017+ paths = map (p: p + "/lib/tmpfiles.d") cfg.tmpfiles.packages;
10181018 postBuild = ''
10191019 for i in $(cat $pathsPath); do
1020− (test -d $i/lib/tmpfiles.d && test $(ls $i/lib/tmpfiles.d/*.conf | wc -l) -ge 1) || (
1021− echo "ERROR: The path $i was passed to systemd.tmpfiles.packages but either does not contain the folder lib/tmpfiles.d or if it contains that folder, there are no files ending in .conf in it."
1020+ (test -d "$i" && test $(ls "$i"/*.conf | wc -l) -ge 1) || (
1021+ echo "ERROR: The path '$i' from systemd.tmpfiles.packages contains no *.conf files."
10221022 exit 1
10231023 )
10241024 done
10251025 '';
1026− }) + "/lib/tmpfiles.d";
1026+ };
10271027
10281028 "systemd/system-generators" = { source = hooks "generators" cfg.generators; };
10291029 "systemd/system-shutdown" = { source = hooks "shutdown" cfg.shutdown; };
pkgs/build-support/trivial-builders.nix+2
@@ -240,6 +240,8 @@ rec {
240240 * This creates a single derivation that replicates the directory structure
241241 * of all the input paths.
242242 *
243+ * BEWARE: it may not "work right" when the passed paths contain symlinks to directories.
244+ *
243245 * Examples:
244246 * # adds symlinks of hello to current build.
245247 * symlinkJoin { name = "myhello"; paths = [ pkgs.hello ]; }