mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
633518628f
$ nix-env -e $(which firefox) or $ nix-env -e /nix/store/nywzlygrkfcgz7dfmhm5xixlx1l0m60v-pan-0.132 * nix-env -i: if an argument contains a slash anywhere, treat it as a path and follow it through symlinks into the Nix store. This allows things like $ nix-build -A firefox $ nix-env -i ./result * nix-env -q/-i/-e: don't complain when the `*' selector doesn't match anything. In particular, `nix-env -q \*' doesn't fail anymore on an empty profile.
113 lines
3.9 KiB
Bash
113 lines
3.9 KiB
Bash
source common.sh
|
|
|
|
clearProfiles
|
|
|
|
set -x
|
|
|
|
# Query installed: should be empty.
|
|
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 0
|
|
|
|
# Query available: should contain several.
|
|
test "$($nixenv -p $profiles/test -f ./user-envs.nix -qa '*' | wc -l)" -eq 5
|
|
|
|
# Query descriptions.
|
|
$nixenv -p $profiles/test -f ./user-envs.nix -qa '*' --description | grep silly
|
|
|
|
# Install "foo-1.0".
|
|
$nixenv -p $profiles/test -f ./user-envs.nix -i foo-1.0
|
|
|
|
# Query installed: should contain foo-1.0 now (which should be
|
|
# executable).
|
|
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1
|
|
$nixenv -p $profiles/test -q '*' | grep -q foo-1.0
|
|
test "$($profiles/test/bin/foo)" = "foo-1.0"
|
|
|
|
# Store the path of foo-1.0.
|
|
outPath10=$($nixenv -p $profiles/test -q --out-path --no-name '*' | grep foo-1.0)
|
|
echo "foo-1.0 = $outPath10"
|
|
test -n "$outPath10"
|
|
|
|
# Install "foo-2.0pre1": should remove foo-1.0.
|
|
$nixenv -p $profiles/test -f ./user-envs.nix -i foo-2.0pre1
|
|
|
|
# Query installed: should contain foo-2.0pre1 now.
|
|
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1
|
|
$nixenv -p $profiles/test -q '*' | grep -q foo-2.0pre1
|
|
test "$($profiles/test/bin/foo)" = "foo-2.0pre1"
|
|
|
|
# Upgrade "foo": should install foo-2.0.
|
|
$nixenv -p $profiles/test -f ./user-envs.nix -u foo
|
|
|
|
# Query installed: should contain foo-2.0 now.
|
|
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 1
|
|
$nixenv -p $profiles/test -q '*' | grep -q foo-2.0
|
|
test "$($profiles/test/bin/foo)" = "foo-2.0"
|
|
|
|
# Store the path of foo-2.0.
|
|
outPath20=$($nixenv -p $profiles/test -q --out-path --no-name '*' | grep foo-2.0)
|
|
test -n "$outPath20"
|
|
|
|
# Install bar-0.1, uninstall foo.
|
|
$nixenv -p $profiles/test -f ./user-envs.nix -i bar-0.1
|
|
$nixenv -p $profiles/test -f ./user-envs.nix -e foo
|
|
|
|
# Query installed: should only contain bar-0.1 now.
|
|
if $nixenv -p $profiles/test -q '*' | grep -q foo; then false; fi
|
|
$nixenv -p $profiles/test -q '*' | grep -q bar
|
|
|
|
# Rollback: should bring "foo" back.
|
|
$nixenv -p $profiles/test --rollback
|
|
$nixenv -p $profiles/test -q '*' | grep -q foo-2.0
|
|
$nixenv -p $profiles/test -q '*' | grep -q bar
|
|
|
|
# Rollback again: should remove "bar".
|
|
$nixenv -p $profiles/test --rollback
|
|
$nixenv -p $profiles/test -q '*' | grep -q foo-2.0
|
|
if $nixenv -p $profiles/test -q '*' | grep -q bar; then false; fi
|
|
|
|
# Count generations.
|
|
test "$($nixenv -p $profiles/test --list-generations | wc -l)" -eq 5
|
|
|
|
# Install foo-1.0, now using its store path.
|
|
echo $outPath10
|
|
$nixenv -p $profiles/test -i "$outPath10"
|
|
$nixenv -p $profiles/test -q '*' | grep -q foo-1.0
|
|
|
|
# Uninstall foo-1.0, using a symlink to its store path.
|
|
ln -sfn $outPath10/bin/foo $TEST_ROOT/symlink
|
|
$nixenv -p $profiles/test -e $TEST_ROOT/symlink
|
|
if $nixenv -p $profiles/test -q '*' | grep -q foo; then false; fi
|
|
|
|
# Install foo-1.0, now using a symlink to its store path.
|
|
$nixenv -p $profiles/test -i $TEST_ROOT/symlink
|
|
$nixenv -p $profiles/test -q '*' | grep -q foo
|
|
|
|
# Delete all old generations.
|
|
$nixenv -p $profiles/test --delete-generations old
|
|
|
|
# Run the garbage collector. This should get rid of foo-2.0 but not
|
|
# foo-1.0.
|
|
$NIX_BIN_DIR/nix-collect-garbage
|
|
test -e "$outPath10"
|
|
if test -e "$outPath20"; then false; fi
|
|
|
|
# Uninstall everything
|
|
$nixenv -p $profiles/test -f ./user-envs.nix -e '*'
|
|
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 0
|
|
|
|
# Installing "foo" should only install the newest foo.
|
|
$nixenv -p $profiles/test -f ./user-envs.nix -i foo
|
|
test "$($nixenv -p $profiles/test -q '*' | grep foo- | wc -l)" -eq 1
|
|
$nixenv -p $profiles/test -q '*' | grep -q foo-2.0
|
|
|
|
# On the other hand, this should install both (and should fail due to
|
|
# a collision).
|
|
$nixenv -p $profiles/test -f ./user-envs.nix -e '*'
|
|
if $nixenv -p $profiles/test -f ./user-envs.nix -i foo-1.0 foo-2.0; then false; fi
|
|
|
|
# Installing "*" should install one foo and one bar.
|
|
$nixenv -p $profiles/test -f ./user-envs.nix -e '*'
|
|
$nixenv -p $profiles/test -f ./user-envs.nix -i '*'
|
|
test "$($nixenv -p $profiles/test -q '*' | wc -l)" -eq 2
|
|
$nixenv -p $profiles/test -q '*' | grep -q foo-2.0
|
|
$nixenv -p $profiles/test -q '*' | grep -q bar-0.1.1
|