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:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-18.04, macos]
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
|
|
@ -40,30 +40,43 @@ elif [ "$(uname -s)" = "Linux" ] && [ -e /run/systemd/system ]; then
|
|||
fi
|
||||
|
||||
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."
|
||||
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 ""
|
||||
) >&2
|
||||
exit
|
||||
fi
|
||||
# handle the command line flags
|
||||
while [ "x${1:-}" != "x" ]; do
|
||||
if [ "x${1:-}" = "x--no-daemon" ]; then
|
||||
INSTALL_MODE=no-daemon
|
||||
elif [ "x${1:-}" = "x--daemon" ]; then
|
||||
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
|
||||
(
|
||||
echo "Nix Installer [--daemon|--no-daemon] [--no-channel-add] [--no-modify-profile]"
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
# Subscribe the user to the Nixpkgs channel and fetch it.
|
||||
if ! $nix/bin/nix-channel --list | grep -q "^nixpkgs "; then
|
||||
$nix/bin/nix-channel --add https://nixos.org/channels/nixpkgs-unstable
|
||||
fi
|
||||
if [ -z "$_NIX_INSTALLER_TEST" ]; then
|
||||
if ! $nix/bin/nix-channel --update nixpkgs; then
|
||||
echo "Fetching the nixpkgs channel failed. (Are you offline?)"
|
||||
echo "To try again later, run \"nix-channel --update nixpkgs\"."
|
||||
if [ -z "$NIX_INSTALLER_NO_CHANNEL_ADD" ]; then
|
||||
if ! $nix/bin/nix-channel --list | grep -q "^nixpkgs "; then
|
||||
$nix/bin/nix-channel --add https://nixos.org/channels/nixpkgs-unstable
|
||||
fi
|
||||
if [ -z "$_NIX_INSTALLER_TEST" ]; then
|
||||
if ! $nix/bin/nix-channel --update nixpkgs; then
|
||||
echo "Fetching the nixpkgs channel failed. (Are you offline?)"
|
||||
echo "To try again later, run \"nix-channel --update nixpkgs\"."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ bool Settings::isExperimentalFeatureEnabled(const std::string & name)
|
|||
void Settings::requireExperimentalFeature(const std::string & 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()
|
||||
|
|
|
@ -167,12 +167,15 @@ void mainWrapped(int argc, char * * argv)
|
|||
|
||||
args.parseCmdline(argvToStrings(argc, argv));
|
||||
|
||||
settings.requireExperimentalFeature("nix-command");
|
||||
|
||||
initPlugins();
|
||||
|
||||
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(); });
|
||||
|
||||
startProgressBar(args.printBuildLogs);
|
||||
|
|
|
@ -105,10 +105,24 @@ mv $cacheDir/nar2 $cacheDir/nar
|
|||
# incomplete closure.
|
||||
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
|
||||
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
|
||||
|
|
|
@ -4,13 +4,13 @@ let
|
|||
|
||||
input1 = mkDerivation {
|
||||
name = "build-hook-input-1";
|
||||
builder = ./dependencies.builder1.sh;
|
||||
buildCommand = "mkdir $out; echo FOO > $out/foo";
|
||||
requiredSystemFeatures = ["foo"];
|
||||
};
|
||||
|
||||
input2 = mkDerivation {
|
||||
name = "build-hook-input-2";
|
||||
builder = ./dependencies.builder2.sh;
|
||||
buildCommand = "mkdir $out; echo BAR > $out/bar";
|
||||
};
|
||||
|
||||
in
|
||||
|
|
|
@ -20,5 +20,5 @@ cat $outPath/foobar | grep FOOBAR
|
|||
|
||||
# Ensure that input1 was built on store1 due to the required feature.
|
||||
p=$(readlink -f $outPath/input-2)
|
||||
(! nix path-info --store $TEST_ROOT/store0 --all | grep dependencies.builder1.sh)
|
||||
nix path-info --store $TEST_ROOT/store1 --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 builder-build-hook-input-1.sh
|
||||
|
|
|
@ -11,7 +11,7 @@ rec {
|
|||
derivation ({
|
||||
inherit system;
|
||||
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;
|
||||
} // removeAttrs args ["builder" "meta"])
|
||||
// { 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 {
|
||||
|
||||
input0 = mkDerivation {
|
||||
name = "dependencies-input-0";
|
||||
buildCommand = "mkdir $out; echo foo > $out/bar";
|
||||
};
|
||||
|
||||
input1 = mkDerivation {
|
||||
name = "dependencies-input-1";
|
||||
builder = ./dependencies.builder1.sh;
|
||||
buildCommand = "mkdir $out; echo FOO > $out/foo";
|
||||
};
|
||||
|
||||
input2 = mkDerivation {
|
||||
name = "dependencies-input-2";
|
||||
builder = "${./dependencies.builder2.sh}";
|
||||
buildCommand = ''
|
||||
mkdir $out
|
||||
echo BAR > $out/bar
|
||||
echo ${input0} > $out/input0
|
||||
'';
|
||||
};
|
||||
|
||||
body = mkDerivation {
|
||||
name = "dependencies";
|
||||
name = "dependencies-top";
|
||||
builder = ./dependencies.builder0.sh + "/FOOBAR/../.";
|
||||
input1 = input1 + "/.";
|
||||
input2 = "${input2}/.";
|
||||
|
|
|
@ -6,7 +6,7 @@ drvPath=$(nix-instantiate dependencies.nix)
|
|||
|
||||
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.
|
||||
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)
|
||||
|
||||
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
|
||||
for i in $(cat $outPath); do checkRef $i; done
|
||||
|
|
|
@ -4,12 +4,12 @@ rec {
|
|||
|
||||
input1 = mkDerivation {
|
||||
name = "dependencies-input-1";
|
||||
builder = ./dependencies.builder1.sh;
|
||||
buildCommand = "mkdir $out; echo FOO > $out/foo";
|
||||
};
|
||||
|
||||
input2 = mkDerivation {
|
||||
name = "dependencies-input-2";
|
||||
builder = ./dependencies.builder2.sh;
|
||||
buildCommand = "mkdir $out; echo BAR > $out/bar";
|
||||
};
|
||||
|
||||
test1 = mkDerivation {
|
||||
|
@ -23,5 +23,5 @@ rec {
|
|||
builder = ./gc-concurrent2.builder.sh;
|
||||
inherit input1 input2;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -32,10 +32,10 @@ if [ "$xmllint" != false ]; then
|
|||
$xmllint --noout $TEST_ROOT/meta.xml || fail "malformed XML"
|
||||
fi
|
||||
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.
|
||||
nix-env -i dependencies
|
||||
nix-env -i dependencies-top
|
||||
[ -e $TEST_HOME/.nix-profile/foobar ]
|
||||
|
||||
clearProfiles
|
||||
|
@ -51,9 +51,9 @@ if [ "$xmllint" != false ]; then
|
|||
$xmllint --noout $TEST_ROOT/meta.xml || fail "malformed XML"
|
||||
fi
|
||||
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.
|
||||
nix-env -i dependencies
|
||||
nix-env -i dependencies-top
|
||||
[ -e $TEST_HOME/.nix-profile/foobar ]
|
||||
|
||||
|
|
Loading…
Reference in a new issue