summary refs log tree commit diff
path: root/pkgs/os-specific/linux/kernel/manual-config.nix
diff options
context:
space:
mode:
authorSandro Jäckel <sandro.jaeckel@gmail.com>2022-08-21 01:49:42 +0200
committerSandro Jäckel <sandro.jaeckel@gmail.com>2022-10-14 23:56:28 +0200
commit000e115d02dd1b683cdb5395bc6a35726625b5d2 (patch)
tree3f710fddae5c541ade6c75ca201a56bab6ee6f1d /pkgs/os-specific/linux/kernel/manual-config.nix
parent724efe9dad576b0eda1a8f90c1d88a8e75288dd1 (diff)
downloadnixpkgs-000e115d02dd1b683cdb5395bc6a35726625b5d2.tar
nixpkgs-000e115d02dd1b683cdb5395bc6a35726625b5d2.tar.gz
nixpkgs-000e115d02dd1b683cdb5395bc6a35726625b5d2.tar.bz2
nixpkgs-000e115d02dd1b683cdb5395bc6a35726625b5d2.tar.lz
nixpkgs-000e115d02dd1b683cdb5395bc6a35726625b5d2.tar.xz
nixpkgs-000e115d02dd1b683cdb5395bc6a35726625b5d2.tar.zst
nixpkgs-000e115d02dd1b683cdb5395bc6a35726625b5d2.zip
kernel: move prePatch to postPatch to not mess with patches
Diffstat (limited to 'pkgs/os-specific/linux/kernel/manual-config.nix')
-rw-r--r--pkgs/os-specific/linux/kernel/manual-config.nix13
1 files changed, 4 insertions, 9 deletions
diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix
index 1049d1c62a9..f9aa1880104 100644
--- a/pkgs/os-specific/linux/kernel/manual-config.nix
+++ b/pkgs/os-specific/linux/kernel/manual-config.nix
@@ -105,7 +105,7 @@ let
         # Fixes determinism by normalizing metadata for the archive of kheaders
         ++ optional (lib.versionAtLeast version "5.2" && lib.versionOlder version "5.4") ./gen-kheaders-metadata.patch;
 
-      prePatch = ''
+      postPatch = ''
         sed -i Makefile -e 's|= depmod|= ${buildPackages.kmod}/bin/depmod|'
 
         # fixup for pre-5.4 kernels using the $(cd $foo && /bin/pwd) pattern
@@ -118,14 +118,9 @@ let
         # See also https://kernelnewbies.org/BuildId
         sed -i Makefile -e 's|--build-id=[^ ]*|--build-id=none|'
 
-        # Some linux-hardened patches now remove certain files in the scripts directory, so we cannot
-        # patch all scripts until after patches are applied.
-        # However, scripts/ld-version.sh is still ran when generating a configfile for a kernel, so it needs
-        # to be patched prior to patchPhase
-        patchShebangs scripts/ld-version.sh
-      '';
+        # Some linux-hardened patches now remove certain files in the scripts directory, so the file may not exist.
+        [[ -f scripts/ld-version.sh ]] && patchShebangs scripts/ld-version.sh
 
-      postPatch = ''
         # Set randstruct seed to a deterministic but diversified value. Note:
         # we could have instead patched gen-random-seed.sh to take input from
         # the buildFlags, but that would require also patching the kernel's
@@ -135,7 +130,7 @@ let
           if [ -f "$file" ]; then
             substituteInPlace "$file" \
               --replace NIXOS_RANDSTRUCT_SEED \
-              $(echo ${randstructSeed}${src} ${configfile} | sha256sum | cut -d ' ' -f 1 | tr -d '\n')
+              $(echo ${randstructSeed}${src} ${placeholder "configfile"} | sha256sum | cut -d ' ' -f 1 | tr -d '\n')
             break
           fi
         done