2024-05-28 10:10:02 -04:00
|
|
|
# shellcheck shell=bash
|
|
|
|
|
2004-05-04 08:15:30 -04:00
|
|
|
test -n "$TEST_ROOT"
|
2024-05-13 08:56:14 -04:00
|
|
|
# We would delete any daemon socket, so let's stop the daemon first.
|
|
|
|
killDaemon
|
|
|
|
# Destroy the test directory that may have persisted from previous runs
|
2024-05-14 10:23:08 -04:00
|
|
|
if [[ -e "$TEST_ROOT" ]]; then
|
|
|
|
chmod -R u+w "$TEST_ROOT"
|
|
|
|
rm -rf "$TEST_ROOT"
|
|
|
|
fi
|
2024-05-06 09:42:49 -04:00
|
|
|
mkdir -p "$TEST_ROOT"
|
|
|
|
mkdir "$TEST_HOME"
|
2004-05-04 08:15:30 -04:00
|
|
|
|
|
|
|
mkdir "$NIX_STORE_DIR"
|
2005-02-01 12:50:48 -05:00
|
|
|
mkdir "$NIX_LOCALSTATE_DIR"
|
2005-02-18 03:40:52 -05:00
|
|
|
mkdir -p "$NIX_LOG_DIR"/drvs
|
2004-05-04 08:15:30 -04:00
|
|
|
mkdir "$NIX_STATE_DIR"
|
2005-02-15 04:39:12 -05:00
|
|
|
mkdir "$NIX_CONF_DIR"
|
2004-05-04 08:15:30 -04:00
|
|
|
|
2005-02-15 04:39:12 -05:00
|
|
|
cat > "$NIX_CONF_DIR"/nix.conf <<EOF
|
2014-05-02 13:02:10 -04:00
|
|
|
build-users-group =
|
2017-08-31 08:28:25 -04:00
|
|
|
keep-derivations = false
|
2018-11-07 11:08:28 -05:00
|
|
|
sandbox = false
|
2023-10-25 05:39:18 -04:00
|
|
|
experimental-features = nix-command
|
2020-07-02 10:37:30 -04:00
|
|
|
gc-reserved-space = 0
|
2020-12-09 08:53:45 -05:00
|
|
|
substituters =
|
2020-01-28 10:34:37 -05:00
|
|
|
flake-registry = $TEST_ROOT/registry.json
|
2021-02-05 06:11:50 -05:00
|
|
|
show-trace = true
|
2018-02-13 08:16:32 -05:00
|
|
|
include nix.conf.extra
|
2021-07-26 00:54:55 -04:00
|
|
|
trusted-users = $(whoami)
|
2018-02-13 08:16:32 -05:00
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > "$NIX_CONF_DIR"/nix.conf.extra <<EOF
|
2010-02-24 08:12:57 -05:00
|
|
|
fsync-metadata = false
|
2023-10-25 05:39:18 -04:00
|
|
|
extra-experimental-features = flakes
|
2018-02-13 08:16:32 -05:00
|
|
|
!include nix.conf.extra.not-there
|
2005-02-15 04:39:12 -05:00
|
|
|
EOF
|
|
|
|
|
2004-05-04 08:15:30 -04:00
|
|
|
# Initialise the database.
|
2024-05-06 09:42:49 -04:00
|
|
|
# The flag itself does nothing, but running the command touches the store
|
2011-10-10 17:32:34 -04:00
|
|
|
nix-store --init
|
2024-05-06 09:42:49 -04:00
|
|
|
# Sanity check
|
2016-07-27 11:14:41 -04:00
|
|
|
test -e "$NIX_STATE_DIR"/db/db.sqlite
|