mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Merge remote-tracking branch 'upstream/master' into errors-phase-2
This commit is contained in:
commit
92123c6c79
15 changed files with 94 additions and 57 deletions
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,30 +40,43 @@ 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
|
|
||||||
if [ "x${1:-}" = "x--no-daemon" ]; then
|
|
||||||
INSTALL_MODE=no-daemon
|
|
||||||
elif [ "x${1:-}" = "x--daemon" ]; then
|
|
||||||
INSTALL_MODE=daemon
|
|
||||||
elif [ "x${1:-}" != "x" ]; then
|
|
||||||
(
|
|
||||||
echo "Nix Installer [--daemon|--no-daemon]"
|
|
||||||
|
|
||||||
echo "Choose installation method."
|
# handle the command line flags
|
||||||
echo ""
|
while [ "x${1:-}" != "x" ]; do
|
||||||
echo " --daemon: Installs and configures a background daemon that manages the store,"
|
if [ "x${1:-}" = "x--no-daemon" ]; then
|
||||||
echo " providing multi-user support and better isolation for local builds."
|
INSTALL_MODE=no-daemon
|
||||||
echo " Both for security and reproducibility, this method is recommended if"
|
elif [ "x${1:-}" = "x--daemon" ]; then
|
||||||
echo " supported on your platform."
|
INSTALL_MODE=daemon
|
||||||
echo " See https://nixos.org/nix/manual/#sect-multi-user-installation"
|
elif [ "x${1:-}" = "x--no-channel-add" ]; then
|
||||||
echo ""
|
NIX_INSTALLER_NO_CHANNEL_ADD=1
|
||||||
echo " --no-daemon: Simple, single-user installation that does not require root and is"
|
elif [ "x${1:-}" = "x--no-modify-profile" ]; then
|
||||||
echo " trivial to uninstall."
|
NIX_INSTALLER_NO_MODIFY_PROFILE=1
|
||||||
echo " (default)"
|
elif [ "x${1:-}" != "x" ]; then
|
||||||
echo ""
|
(
|
||||||
) >&2
|
echo "Nix Installer [--daemon|--no-daemon] [--no-channel-add] [--no-modify-profile]"
|
||||||
exit
|
|
||||||
fi
|
echo "Choose installation method."
|
||||||
|
echo ""
|
||||||
|
echo " --daemon: Installs and configures a background daemon that manages the store,"
|
||||||
|
echo " providing multi-user support and better isolation for local builds."
|
||||||
|
echo " Both for security and reproducibility, this method is recommended if"
|
||||||
|
echo " supported on your platform."
|
||||||
|
echo " See https://nixos.org/nix/manual/#sect-multi-user-installation"
|
||||||
|
echo ""
|
||||||
|
echo " --no-daemon: Simple, single-user installation that does not require root and is"
|
||||||
|
echo " trivial to uninstall."
|
||||||
|
echo " (default)"
|
||||||
|
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
|
||||||
|
exit
|
||||||
|
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,13 +143,15 @@ 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 ! $nix/bin/nix-channel --list | grep -q "^nixpkgs "; then
|
if [ -z "$NIX_INSTALLER_NO_CHANNEL_ADD" ]; then
|
||||||
$nix/bin/nix-channel --add https://nixos.org/channels/nixpkgs-unstable
|
if ! $nix/bin/nix-channel --list | grep -q "^nixpkgs "; then
|
||||||
fi
|
$nix/bin/nix-channel --add https://nixos.org/channels/nixpkgs-unstable
|
||||||
if [ -z "$_NIX_INSTALLER_TEST" ]; then
|
fi
|
||||||
if ! $nix/bin/nix-channel --update nixpkgs; then
|
if [ -z "$_NIX_INSTALLER_TEST" ]; then
|
||||||
echo "Fetching the nixpkgs channel failed. (Are you offline?)"
|
if ! $nix/bin/nix-channel --update nixpkgs; then
|
||||||
echo "To try again later, run \"nix-channel --update nixpkgs\"."
|
echo "Fetching the nixpkgs channel failed. (Are you offline?)"
|
||||||
|
echo "To try again later, run \"nix-channel --update nixpkgs\"."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
||||||
|
@ -23,5 +23,5 @@ rec {
|
||||||
builder = ./gc-concurrent2.builder.sh;
|
builder = ./gc-concurrent2.builder.sh;
|
||||||
inherit input1 input2;
|
inherit input1 input2;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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