From e62b83a934ea44d6da145cfe02b2d401d95d174f Mon Sep 17 00:00:00 2001 From: Marwan Aljubeh Date: Tue, 7 Mar 2023 12:53:20 +0000 Subject: [PATCH] Fix system.patches Currently, `system.patches` doesn't work because it will attempt to first detect if the patch has already been applied by checking if it can be applied in reverse. However, when that happens, `patch` detects that the supplied patch is incorrectly reversed and attempts to ask the user if they want to "Ignore -R": ``` Unreversed (or previously applied) patch detected! Ignore -R? [y] ``` Because the output is piped to `/dev/null` the user will basically see nothing and `darwin-rebuild switch` will hang until the user presses "Enter" (possibly to check if the terminal is frozen). At which point, patch will ignore the --reverse and exit successfully, preventing the patch from being applied at all. This change fixes that bug by using `--force` which tells patch that we know what we're doing and prevents it from prompting the user if they want to ignore `--reverse`. --- modules/system/patches.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/system/patches.nix b/modules/system/patches.nix index 92f45c1..bb384e8 100644 --- a/modules/system/patches.nix +++ b/modules/system/patches.nix @@ -62,7 +62,7 @@ in ${concatMapStringsSep "\n" (f: '' f="$(basename ${f})" - if ! patch --reverse --dry-run -d / -p1 < '${f}' &> /dev/null; then + if ! patch --force --reverse --dry-run -d / -p1 < '${f}' &> /dev/null; then patch --forward --backup -d / -p1 < '${f}' || true fi '') cfg.patches}