summary refs log tree commit diff
path: root/pkgs/build-support/kernel/make-initrd.nix
diff options
context:
space:
mode:
authorArian van Putten <aeroboy94@gmail.com>2019-01-15 17:09:17 +0100
committerArian van Putten <aeroboy94@gmail.com>2019-05-29 16:07:05 +0200
commitb086b342bb5f443d3e98805eed60bbf76d37106c (patch)
treee722192cb52a963df0cbb28b90442ff03bcf1535 /pkgs/build-support/kernel/make-initrd.nix
parent2669633053796ac5cb19cec79e96b0933fcf0ec3 (diff)
downloadnixpkgs-b086b342bb5f443d3e98805eed60bbf76d37106c.tar
nixpkgs-b086b342bb5f443d3e98805eed60bbf76d37106c.tar.gz
nixpkgs-b086b342bb5f443d3e98805eed60bbf76d37106c.tar.bz2
nixpkgs-b086b342bb5f443d3e98805eed60bbf76d37106c.tar.lz
nixpkgs-b086b342bb5f443d3e98805eed60bbf76d37106c.tar.xz
nixpkgs-b086b342bb5f443d3e98805eed60bbf76d37106c.tar.zst
nixpkgs-b086b342bb5f443d3e98805eed60bbf76d37106c.zip
build-support/make-initrd: Don't derive derivation name from file name
not all valid file names are valid derivation names. This can cause
troubles when, for example, trying to place systemd template unit
files, which contain an '@' in their name,  in an initrd.

Fixes #53987
Diffstat (limited to 'pkgs/build-support/kernel/make-initrd.nix')
-rw-r--r--pkgs/build-support/kernel/make-initrd.nix14
1 files changed, 12 insertions, 2 deletions
diff --git a/pkgs/build-support/kernel/make-initrd.nix b/pkgs/build-support/kernel/make-initrd.nix
index 7ad1affb65a..7a5642e565d 100644
--- a/pkgs/build-support/kernel/make-initrd.nix
+++ b/pkgs/build-support/kernel/make-initrd.nix
@@ -16,10 +16,16 @@
 , name ? "initrd"
 , compressor ? "gzip -9n"
 , prepend ? []
+, lib
 }:
+let 
+  # !!! Move this into a public lib function, it is probably useful for others
+  toValidStoreName = x: with builtins; 
+    lib.concatStringsSep "-" (filter (x: !(isList x)) (split "[^a-zA-Z0-9_=.?-]+" x));
 
-stdenv.mkDerivation rec {
+in stdenv.mkDerivation rec {
   inherit name;
+
   builder = ./make-initrd.sh;
 
   makeUInitrd = stdenv.hostPlatform.platform.kernelTarget == "uImage";
@@ -36,8 +42,12 @@ stdenv.mkDerivation rec {
   # Note: we don't use closureInfo yet, as that won't build with nix-1.x.
   # See #36268.
   exportReferencesGraph =
-    map (x: [("closure-" + baseNameOf x.symlink) x.object]) contents;
+    lib.zipListsWith 
+      (x: i: [("closure-${toValidStoreName (baseNameOf x.symlink)}-${toString i}") x.object]) 
+      contents 
+      (lib.range 0 (lib.length contents - 1));
   pathsFromGraph = ./paths-from-graph.pl;
 
   inherit compressor prepend;
 }
+