mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
nixos/nix-channel: move stale-channel warning to preSwitchChecks (#527658)
This commit is contained in:
@@ -11,7 +11,6 @@ let
|
||||
inherit (lib)
|
||||
mkIf
|
||||
mkOption
|
||||
stringAfter
|
||||
types
|
||||
;
|
||||
|
||||
@@ -98,8 +97,8 @@ in
|
||||
''f /root/.nix-channels - - - - ${config.system.defaultChannel} nixos\n''
|
||||
];
|
||||
|
||||
system.activationScripts.no-nix-channel = mkIf (!cfg.channel.enable) (
|
||||
stringAfter [ "etc" "users" ] (builtins.readFile ./nix-channel/activation-check.sh)
|
||||
system.preSwitchChecks.no-nix-channel = mkIf (!cfg.channel.enable) (
|
||||
builtins.readFile ./nix-channel/pre-switch-check.sh
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# shellcheck shell=bash
|
||||
warn() {
|
||||
printf "\033[1;35mwarning:\033[0m %s\n" "$*" >&2
|
||||
}
|
||||
|
||||
explainChannelWarning=0
|
||||
if [[ -e "/root/.nix-defexpr/channels" ]]; then
|
||||
@@ -11,11 +13,13 @@ if [[ -e "/nix/var/nix/profiles/per-user/root/channels" ]]; then
|
||||
fi
|
||||
while IFS=: read -r _ _ _ _ _ home _ ; do
|
||||
if [[ -n "$home" && -e "$home/.nix-defexpr/channels" ]]; then
|
||||
warn "$home/.nix-defexpr/channels exists, but channels have been disabled." 1>&2
|
||||
warn "$home/.nix-defexpr/channels exists, but channels have been disabled."
|
||||
explainChannelWarning=1
|
||||
fi
|
||||
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." 1>&2
|
||||
echo "Delete the above directory or directories to prevent this." 1>&2
|
||||
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
|
||||
fi
|
||||
# This check is informational only and must never block a switch.
|
||||
true
|
||||
@@ -1,20 +0,0 @@
|
||||
# Run:
|
||||
# nix-build -A nixosTests.nix-channel
|
||||
{ lib, testers }:
|
||||
let
|
||||
inherit (lib) fileset;
|
||||
|
||||
runShellcheck = testers.shellcheck {
|
||||
name = "activation-check";
|
||||
src = fileset.toSource {
|
||||
root = ./.;
|
||||
fileset = fileset.unions [
|
||||
./activation-check.sh
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
lib.recurseIntoAttrs {
|
||||
inherit runShellcheck;
|
||||
}
|
||||
@@ -1122,7 +1122,6 @@ in
|
||||
nimdow = runTest ./nimdow.nix;
|
||||
nipap = runTest ./web-apps/nipap.nix;
|
||||
nitter = runTest ./nitter.nix;
|
||||
nix-channel = pkgs.callPackage ../modules/config/nix-channel/test.nix { };
|
||||
nix-config = runTest ./nix-config.nix;
|
||||
nix-daemon-firewall = runTest ./nix-daemon-firewall.nix;
|
||||
nix-daemon-unprivileged = runTest ./nix-daemon-unprivileged.nix;
|
||||
|
||||
Reference in New Issue
Block a user