mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 13:40:28 +03:00
Merge pull request #323613 from CyberShadow/fix-nix-path-without-channels-v2
nix-channel: do not set empty nix-path when disabling channels
This commit is contained in:
commit
4ca52fdf5f
15 changed files with 291 additions and 7 deletions
|
@ -33,6 +33,8 @@ let
|
|||
''
|
||||
#!${pkgs.runtimeShell}
|
||||
|
||||
source ${./lib/lib.sh}
|
||||
|
||||
systemConfig='@out@'
|
||||
|
||||
export PATH=/empty
|
||||
|
|
5
nixos/modules/system/activation/lib/lib.sh
Normal file
5
nixos/modules/system/activation/lib/lib.sh
Normal file
|
@ -0,0 +1,5 @@
|
|||
# shellcheck shell=bash
|
||||
|
||||
warn() {
|
||||
printf "\033[1;35mwarning:\033[0m %s\n" "$*" >&2
|
||||
}
|
36
nixos/modules/system/activation/lib/test.nix
Normal file
36
nixos/modules/system/activation/lib/test.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
# Run:
|
||||
# nix-build -A nixosTests.activation-lib
|
||||
{ lib, stdenv, testers }:
|
||||
let
|
||||
inherit (lib) fileset;
|
||||
|
||||
runTests = stdenv.mkDerivation {
|
||||
name = "tests-activation-lib";
|
||||
src = fileset.toSource {
|
||||
root = ./.;
|
||||
fileset = fileset.unions [
|
||||
./lib.sh
|
||||
./test.sh
|
||||
];
|
||||
};
|
||||
buildPhase = ":";
|
||||
doCheck = true;
|
||||
postUnpack = ''
|
||||
patchShebangs --build .
|
||||
'';
|
||||
checkPhase = ''
|
||||
./test.sh
|
||||
'';
|
||||
installPhase = ''
|
||||
touch $out
|
||||
'';
|
||||
};
|
||||
|
||||
runShellcheck = testers.shellcheck {
|
||||
src = runTests.src;
|
||||
};
|
||||
|
||||
in
|
||||
lib.recurseIntoAttrs {
|
||||
inherit runTests runShellcheck;
|
||||
}
|
34
nixos/modules/system/activation/lib/test.sh
Executable file
34
nixos/modules/system/activation/lib/test.sh
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Run:
|
||||
# ./test.sh
|
||||
# or:
|
||||
# nix-build -A nixosTests.activation-lib
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
set -euo pipefail
|
||||
|
||||
# report failure
|
||||
onerr() {
|
||||
set +e
|
||||
# find failed statement
|
||||
echo "call trace:"
|
||||
local i=0
|
||||
while t="$(caller $i)"; do
|
||||
line="${t%% *}"
|
||||
file="${t##* }"
|
||||
echo " $file:$line" >&2
|
||||
((i++))
|
||||
done
|
||||
# red
|
||||
printf "\033[1;31mtest failed\033[0m\n" >&2
|
||||
exit 1
|
||||
}
|
||||
trap onerr ERR
|
||||
|
||||
source ./lib.sh
|
||||
|
||||
(warn hi, this works >/dev/null) 2>&1 | grep -E $'.*warning:.* hi, this works' >/dev/null
|
||||
|
||||
# green
|
||||
printf "\033[1;32mok\033[0m\n"
|
Loading…
Add table
Add a link
Reference in a new issue