summaryrefslogtreecommitdiff
path: root/modules/system/patches.nix
diff options
context:
space:
mode:
authorMichael Hoang <enzime@users.noreply.github.com>2024-11-03 19:26:56 +1100
committerMichael Hoang <enzime@users.noreply.github.com>2024-11-07 17:20:00 +1100
commitfd510a7122d49cc1cbd72b9e70b1ae6b3c76c990 (patch)
treefecc1d000b6f8d74fa66257ec7e2fd4e53fed6e2 /modules/system/patches.nix
parent041996803af5497fb000e3f79621fa5bb6995057 (diff)
system: replace `for f in $(ls ...)` with `for f in .../*`
Fixes SC2045 but has one quirk which is if the bash glob doesn't match anything it'll treat it as a string and run the loop once with `f=.../*` so we need to check that `$f` actually exists.
Diffstat (limited to 'modules/system/patches.nix')
-rw-r--r--modules/system/patches.nix15
1 files changed, 9 insertions, 6 deletions
diff --git a/modules/system/patches.nix b/modules/system/patches.nix
index 4f96501..7b19255 100644
--- a/modules/system/patches.nix
+++ b/modules/system/patches.nix
@@ -30,9 +30,9 @@ in
Set of patches to apply to {file}`/`.
::: {.warning}
-
+
This can modify everything so use with caution.
-
+
:::
Useful for safely changing system files. Unlike the etc module this
@@ -56,10 +56,13 @@ in
# Applying patches to /.
echo "applying patches..." >&2
- for f in $(ls /run/current-system/patches 2> /dev/null); do
- if test ! -e "${config.system.build.patches}/patches/$f"; then
- patch --force --reverse --backup -d / -p1 < "/run/current-system/patches/$f" || true
- fi
+ for f in /run/current-system/patches/*; do
+ [[ -e "$f" ]] || break # handle when directory is empty
+ f=''${f#/run/current-system/patches/}
+
+ if [[ ! -e "${config.system.build.patches}/patches/$f" ]]; then
+ patch --force --reverse --backup -d / -p1 < "/run/current-system/patches/$f" || true
+ fi
done
${concatMapStringsSep "\n" (f: ''