diff --git a/nixos/modules/config/nix-channel.nix b/nixos/modules/config/nix-channel.nix index 630474f70efe..4d6e19975508 100644 --- a/nixos/modules/config/nix-channel.nix +++ b/nixos/modules/config/nix-channel.nix @@ -6,7 +6,12 @@ - ./nix.nix - ./nix-flakes.nix */ -{ config, lib, ... }: +{ + config, + lib, + pkgs, + ... +}: let inherit (lib) mkIf @@ -98,7 +103,9 @@ in ]; system.preSwitchChecks.no-nix-channel = mkIf (!cfg.channel.enable) ( - builtins.readFile ./nix-channel/pre-switch-check.sh + lib.replaceStrings [ "@getent@" ] [ (lib.getExe pkgs.getent) ] ( + builtins.readFile ./nix-channel/pre-switch-check.sh + ) ); }; } diff --git a/nixos/modules/config/nix-channel/pre-switch-check.sh b/nixos/modules/config/nix-channel/pre-switch-check.sh index b108244b07d3..cf6d3af8395c 100644 --- a/nixos/modules/config/nix-channel/pre-switch-check.sh +++ b/nixos/modules/config/nix-channel/pre-switch-check.sh @@ -16,7 +16,7 @@ while IFS=: read -r _ _ _ _ _ home _ ; do warn "$home/.nix-defexpr/channels exists, but channels have been disabled." explainChannelWarning=1 fi -done < <(getent passwd) +done < <(@getent@ passwd) if [[ $explainChannelWarning -eq 1 ]]; then echo "Due to https://github.com/NixOS/nix/issues/9574, Nix may still use these channels when NIX_PATH is unset." >&2 echo "Delete the above directory or directories to prevent this." >&2