forked from lix-project/lix
Merge remote-tracking branch 'upstream/master' into errors-phase-2
This commit is contained in:
commit
92123c6c79
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
@ -6,7 +6,7 @@ jobs:
|
||||||
tests:
|
tests:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-18.04, macos]
|
os: [ubuntu-latest, macos-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
|
@ -40,14 +40,20 @@ elif [ "$(uname -s)" = "Linux" ] && [ -e /run/systemd/system ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
INSTALL_MODE=no-daemon
|
INSTALL_MODE=no-daemon
|
||||||
# Trivially handle the --daemon / --no-daemon options
|
|
||||||
|
# handle the command line flags
|
||||||
|
while [ "x${1:-}" != "x" ]; do
|
||||||
if [ "x${1:-}" = "x--no-daemon" ]; then
|
if [ "x${1:-}" = "x--no-daemon" ]; then
|
||||||
INSTALL_MODE=no-daemon
|
INSTALL_MODE=no-daemon
|
||||||
elif [ "x${1:-}" = "x--daemon" ]; then
|
elif [ "x${1:-}" = "x--daemon" ]; then
|
||||||
INSTALL_MODE=daemon
|
INSTALL_MODE=daemon
|
||||||
|
elif [ "x${1:-}" = "x--no-channel-add" ]; then
|
||||||
|
NIX_INSTALLER_NO_CHANNEL_ADD=1
|
||||||
|
elif [ "x${1:-}" = "x--no-modify-profile" ]; then
|
||||||
|
NIX_INSTALLER_NO_MODIFY_PROFILE=1
|
||||||
elif [ "x${1:-}" != "x" ]; then
|
elif [ "x${1:-}" != "x" ]; then
|
||||||
(
|
(
|
||||||
echo "Nix Installer [--daemon|--no-daemon]"
|
echo "Nix Installer [--daemon|--no-daemon] [--no-channel-add] [--no-modify-profile]"
|
||||||
|
|
||||||
echo "Choose installation method."
|
echo "Choose installation method."
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -61,9 +67,16 @@ elif [ "x${1:-}" != "x" ]; then
|
||||||
echo " trivial to uninstall."
|
echo " trivial to uninstall."
|
||||||
echo " (default)"
|
echo " (default)"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo " --no-channel-add: Don't add any channels. nixpkgs-unstable is installed by default."
|
||||||
|
echo ""
|
||||||
|
echo " --no-modify-profile: Skip channel installation. When not provided nixpkgs-unstable"
|
||||||
|
echo " is installed by default."
|
||||||
|
echo ""
|
||||||
) >&2
|
) >&2
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
if [ "$INSTALL_MODE" = "daemon" ]; then
|
if [ "$INSTALL_MODE" = "daemon" ]; then
|
||||||
printf '\e[1;31mSwitching to the Daemon-based Installer\e[0m\n'
|
printf '\e[1;31mSwitching to the Daemon-based Installer\e[0m\n'
|
||||||
|
@ -130,6 +143,7 @@ if [ -z "$NIX_SSL_CERT_FILE" ] || ! [ -f "$NIX_SSL_CERT_FILE" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Subscribe the user to the Nixpkgs channel and fetch it.
|
# Subscribe the user to the Nixpkgs channel and fetch it.
|
||||||
|
if [ -z "$NIX_INSTALLER_NO_CHANNEL_ADD" ]; then
|
||||||
if ! $nix/bin/nix-channel --list | grep -q "^nixpkgs "; then
|
if ! $nix/bin/nix-channel --list | grep -q "^nixpkgs "; then
|
||||||
$nix/bin/nix-channel --add https://nixos.org/channels/nixpkgs-unstable
|
$nix/bin/nix-channel --add https://nixos.org/channels/nixpkgs-unstable
|
||||||
fi
|
fi
|
||||||
|
@ -139,6 +153,7 @@ if [ -z "$_NIX_INSTALLER_TEST" ]; then
|
||||||
echo "To try again later, run \"nix-channel --update nixpkgs\"."
|
echo "To try again later, run \"nix-channel --update nixpkgs\"."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
added=
|
added=
|
||||||
p=$HOME/.nix-profile/etc/profile.d/nix.sh
|
p=$HOME/.nix-profile/etc/profile.d/nix.sh
|
||||||
|
|
|
@ -130,7 +130,7 @@ bool Settings::isExperimentalFeatureEnabled(const std::string & name)
|
||||||
void Settings::requireExperimentalFeature(const std::string & name)
|
void Settings::requireExperimentalFeature(const std::string & name)
|
||||||
{
|
{
|
||||||
if (!isExperimentalFeatureEnabled(name))
|
if (!isExperimentalFeatureEnabled(name))
|
||||||
throw Error("experimental Nix feature '%s' is disabled", name);
|
throw Error("experimental Nix feature '%1%' is disabled; use '--experimental-features %1%' to override", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::isWSL1()
|
bool Settings::isWSL1()
|
||||||
|
|
|
@ -167,12 +167,15 @@ void mainWrapped(int argc, char * * argv)
|
||||||
|
|
||||||
args.parseCmdline(argvToStrings(argc, argv));
|
args.parseCmdline(argvToStrings(argc, argv));
|
||||||
|
|
||||||
settings.requireExperimentalFeature("nix-command");
|
|
||||||
|
|
||||||
initPlugins();
|
initPlugins();
|
||||||
|
|
||||||
if (!args.command) args.showHelpAndExit();
|
if (!args.command) args.showHelpAndExit();
|
||||||
|
|
||||||
|
if (args.command->first != "repl"
|
||||||
|
&& args.command->first != "doctor"
|
||||||
|
&& args.command->first != "upgrade-nix")
|
||||||
|
settings.requireExperimentalFeature("nix-command");
|
||||||
|
|
||||||
Finally f([]() { stopProgressBar(); });
|
Finally f([]() { stopProgressBar(); });
|
||||||
|
|
||||||
startProgressBar(args.printBuildLogs);
|
startProgressBar(args.printBuildLogs);
|
||||||
|
|
|
@ -105,10 +105,24 @@ mv $cacheDir/nar2 $cacheDir/nar
|
||||||
# incomplete closure.
|
# incomplete closure.
|
||||||
clearStore
|
clearStore
|
||||||
|
|
||||||
rm $(grep -l "StorePath:.*dependencies-input-2" $cacheDir/*.narinfo)
|
rm -v $(grep -l "StorePath:.*dependencies-input-2" $cacheDir/*.narinfo)
|
||||||
|
|
||||||
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o $TEST_ROOT/result 2>&1 | tee $TEST_ROOT/log
|
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o $TEST_ROOT/result 2>&1 | tee $TEST_ROOT/log
|
||||||
grep -q "copying path" $TEST_ROOT/log
|
grep -q "copying path.*input-0" $TEST_ROOT/log
|
||||||
|
grep -q "copying path.*input-2" $TEST_ROOT/log
|
||||||
|
grep -q "copying path.*top" $TEST_ROOT/log
|
||||||
|
|
||||||
|
|
||||||
|
# Idem, but without cached .narinfo.
|
||||||
|
clearStore
|
||||||
|
clearCacheCache
|
||||||
|
|
||||||
|
nix-build --substituters "file://$cacheDir" --no-require-sigs dependencies.nix -o $TEST_ROOT/result 2>&1 | tee $TEST_ROOT/log
|
||||||
|
grep -q "don't know how to build" $TEST_ROOT/log
|
||||||
|
grep -q "building.*input-1" $TEST_ROOT/log
|
||||||
|
grep -q "building.*input-2" $TEST_ROOT/log
|
||||||
|
grep -q "copying path.*input-0" $TEST_ROOT/log
|
||||||
|
grep -q "copying path.*top" $TEST_ROOT/log
|
||||||
|
|
||||||
|
|
||||||
if [ -n "$HAVE_SODIUM" ]; then
|
if [ -n "$HAVE_SODIUM" ]; then
|
||||||
|
|
|
@ -4,13 +4,13 @@ let
|
||||||
|
|
||||||
input1 = mkDerivation {
|
input1 = mkDerivation {
|
||||||
name = "build-hook-input-1";
|
name = "build-hook-input-1";
|
||||||
builder = ./dependencies.builder1.sh;
|
buildCommand = "mkdir $out; echo FOO > $out/foo";
|
||||||
requiredSystemFeatures = ["foo"];
|
requiredSystemFeatures = ["foo"];
|
||||||
};
|
};
|
||||||
|
|
||||||
input2 = mkDerivation {
|
input2 = mkDerivation {
|
||||||
name = "build-hook-input-2";
|
name = "build-hook-input-2";
|
||||||
builder = ./dependencies.builder2.sh;
|
buildCommand = "mkdir $out; echo BAR > $out/bar";
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
|
@ -20,5 +20,5 @@ cat $outPath/foobar | grep FOOBAR
|
||||||
|
|
||||||
# Ensure that input1 was built on store1 due to the required feature.
|
# Ensure that input1 was built on store1 due to the required feature.
|
||||||
p=$(readlink -f $outPath/input-2)
|
p=$(readlink -f $outPath/input-2)
|
||||||
(! nix path-info --store $TEST_ROOT/store0 --all | grep dependencies.builder1.sh)
|
(! nix path-info --store $TEST_ROOT/store0 --all | grep builder-build-hook-input-1.sh)
|
||||||
nix path-info --store $TEST_ROOT/store1 --all | grep dependencies.builder1.sh
|
nix path-info --store $TEST_ROOT/store1 --all | grep builder-build-hook-input-1.sh
|
||||||
|
|
|
@ -11,7 +11,7 @@ rec {
|
||||||
derivation ({
|
derivation ({
|
||||||
inherit system;
|
inherit system;
|
||||||
builder = shell;
|
builder = shell;
|
||||||
args = ["-e" args.builder or (builtins.toFile "builder.sh" "if [ -e .attrs.sh ]; then source .attrs.sh; fi; eval \"$buildCommand\"")];
|
args = ["-e" args.builder or (builtins.toFile "builder-${args.name}.sh" "if [ -e .attrs.sh ]; then source .attrs.sh; fi; eval \"$buildCommand\"")];
|
||||||
PATH = path;
|
PATH = path;
|
||||||
} // removeAttrs args ["builder" "meta"])
|
} // removeAttrs args ["builder" "meta"])
|
||||||
// { meta = args.meta or {}; };
|
// { meta = args.meta or {}; };
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
mkdir $out
|
|
||||||
echo FOO > $out/foo
|
|
|
@ -1,2 +0,0 @@
|
||||||
mkdir $out
|
|
||||||
echo BAR > $out/bar
|
|
|
@ -2,18 +2,27 @@ with import ./config.nix;
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|
||||||
|
input0 = mkDerivation {
|
||||||
|
name = "dependencies-input-0";
|
||||||
|
buildCommand = "mkdir $out; echo foo > $out/bar";
|
||||||
|
};
|
||||||
|
|
||||||
input1 = mkDerivation {
|
input1 = mkDerivation {
|
||||||
name = "dependencies-input-1";
|
name = "dependencies-input-1";
|
||||||
builder = ./dependencies.builder1.sh;
|
buildCommand = "mkdir $out; echo FOO > $out/foo";
|
||||||
};
|
};
|
||||||
|
|
||||||
input2 = mkDerivation {
|
input2 = mkDerivation {
|
||||||
name = "dependencies-input-2";
|
name = "dependencies-input-2";
|
||||||
builder = "${./dependencies.builder2.sh}";
|
buildCommand = ''
|
||||||
|
mkdir $out
|
||||||
|
echo BAR > $out/bar
|
||||||
|
echo ${input0} > $out/input0
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
body = mkDerivation {
|
body = mkDerivation {
|
||||||
name = "dependencies";
|
name = "dependencies-top";
|
||||||
builder = ./dependencies.builder0.sh + "/FOOBAR/../.";
|
builder = ./dependencies.builder0.sh + "/FOOBAR/../.";
|
||||||
input1 = input1 + "/.";
|
input1 = input1 + "/.";
|
||||||
input2 = "${input2}/.";
|
input2 = "${input2}/.";
|
||||||
|
|
|
@ -6,7 +6,7 @@ drvPath=$(nix-instantiate dependencies.nix)
|
||||||
|
|
||||||
echo "derivation is $drvPath"
|
echo "derivation is $drvPath"
|
||||||
|
|
||||||
nix-store -q --tree "$drvPath" | grep '───.*builder1.sh'
|
nix-store -q --tree "$drvPath" | grep '───.*builder-dependencies-input-1.sh'
|
||||||
|
|
||||||
# Test Graphviz graph generation.
|
# Test Graphviz graph generation.
|
||||||
nix-store -q --graph "$drvPath" > $TEST_ROOT/graph
|
nix-store -q --graph "$drvPath" > $TEST_ROOT/graph
|
||||||
|
|
|
@ -11,7 +11,7 @@ checkRef() {
|
||||||
|
|
||||||
outPath=$(nix-build ./export-graph.nix -A 'foo."bar.runtimeGraph"' -o $TEST_ROOT/result)
|
outPath=$(nix-build ./export-graph.nix -A 'foo."bar.runtimeGraph"' -o $TEST_ROOT/result)
|
||||||
|
|
||||||
test $(nix-store -q --references $TEST_ROOT/result | wc -l) = 2 || fail "bad nr of references"
|
test $(nix-store -q --references $TEST_ROOT/result | wc -l) = 3 || fail "bad nr of references"
|
||||||
|
|
||||||
checkRef input-2
|
checkRef input-2
|
||||||
for i in $(cat $outPath); do checkRef $i; done
|
for i in $(cat $outPath); do checkRef $i; done
|
||||||
|
|
|
@ -4,12 +4,12 @@ rec {
|
||||||
|
|
||||||
input1 = mkDerivation {
|
input1 = mkDerivation {
|
||||||
name = "dependencies-input-1";
|
name = "dependencies-input-1";
|
||||||
builder = ./dependencies.builder1.sh;
|
buildCommand = "mkdir $out; echo FOO > $out/foo";
|
||||||
};
|
};
|
||||||
|
|
||||||
input2 = mkDerivation {
|
input2 = mkDerivation {
|
||||||
name = "dependencies-input-2";
|
name = "dependencies-input-2";
|
||||||
builder = ./dependencies.builder2.sh;
|
buildCommand = "mkdir $out; echo BAR > $out/bar";
|
||||||
};
|
};
|
||||||
|
|
||||||
test1 = mkDerivation {
|
test1 = mkDerivation {
|
||||||
|
|
|
@ -32,10 +32,10 @@ if [ "$xmllint" != false ]; then
|
||||||
$xmllint --noout $TEST_ROOT/meta.xml || fail "malformed XML"
|
$xmllint --noout $TEST_ROOT/meta.xml || fail "malformed XML"
|
||||||
fi
|
fi
|
||||||
grep -q 'meta.*description.*Random test package' $TEST_ROOT/meta.xml
|
grep -q 'meta.*description.*Random test package' $TEST_ROOT/meta.xml
|
||||||
grep -q 'item.*attrPath="foo".*name="dependencies"' $TEST_ROOT/meta.xml
|
grep -q 'item.*attrPath="foo".*name="dependencies-top"' $TEST_ROOT/meta.xml
|
||||||
|
|
||||||
# Do an install.
|
# Do an install.
|
||||||
nix-env -i dependencies
|
nix-env -i dependencies-top
|
||||||
[ -e $TEST_HOME/.nix-profile/foobar ]
|
[ -e $TEST_HOME/.nix-profile/foobar ]
|
||||||
|
|
||||||
clearProfiles
|
clearProfiles
|
||||||
|
@ -51,9 +51,9 @@ if [ "$xmllint" != false ]; then
|
||||||
$xmllint --noout $TEST_ROOT/meta.xml || fail "malformed XML"
|
$xmllint --noout $TEST_ROOT/meta.xml || fail "malformed XML"
|
||||||
fi
|
fi
|
||||||
grep -q 'meta.*description.*Random test package' $TEST_ROOT/meta.xml
|
grep -q 'meta.*description.*Random test package' $TEST_ROOT/meta.xml
|
||||||
grep -q 'item.*attrPath="foo".*name="dependencies"' $TEST_ROOT/meta.xml
|
grep -q 'item.*attrPath="foo".*name="dependencies-top"' $TEST_ROOT/meta.xml
|
||||||
|
|
||||||
# Do an install.
|
# Do an install.
|
||||||
nix-env -i dependencies
|
nix-env -i dependencies-top
|
||||||
[ -e $TEST_HOME/.nix-profile/foobar ]
|
[ -e $TEST_HOME/.nix-profile/foobar ]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue