2024-02-08 16:58:45 +01:00
|
|
|
{
|
2025-08-26 14:52:12 +02:00
|
|
|
perSystem =
|
|
|
|
|
{
|
|
|
|
|
config,
|
|
|
|
|
...
|
|
|
|
|
}:
|
|
|
|
|
{
|
|
|
|
|
# https://flake.parts/options/nix-cargo-integration
|
|
|
|
|
nci.projects.nix-bindings = {
|
|
|
|
|
path = ./.;
|
|
|
|
|
drvConfig = {
|
2025-10-27 01:37:18 +01:00
|
|
|
imports = [
|
|
|
|
|
# Downstream projects import this into depsDrvConfig instead
|
|
|
|
|
config.nix-bindings-rust.nciBuildConfig
|
|
|
|
|
];
|
|
|
|
|
# Extra settings for running the tests
|
2025-08-26 14:52:12 +02:00
|
|
|
mkDerivation = {
|
|
|
|
|
# Prepare the environment for Nix to work.
|
|
|
|
|
# Nix does not provide a suitable environment for running itself in
|
|
|
|
|
# the sandbox - not by default. We configure it to use a relocated store.
|
|
|
|
|
preCheck = ''
|
|
|
|
|
# nix needs a home directory
|
|
|
|
|
export HOME="$(mktemp -d $TMPDIR/home.XXXXXX)"
|
2024-03-19 18:01:05 +01:00
|
|
|
|
2025-08-26 14:52:12 +02:00
|
|
|
# configure a relocated store
|
|
|
|
|
store_data=$(mktemp -d $TMPDIR/store-data.XXXXXX)
|
|
|
|
|
export NIX_REMOTE="$store_data"
|
|
|
|
|
export NIX_BUILD_HOOK=
|
|
|
|
|
export NIX_CONF_DIR=$store_data/etc
|
|
|
|
|
export NIX_LOCALSTATE_DIR=$store_data/nix/var
|
|
|
|
|
export NIX_LOG_DIR=$store_data/nix/var/log/nix
|
|
|
|
|
export NIX_STATE_DIR=$store_data/nix/var/nix
|
2024-03-19 18:01:05 +01:00
|
|
|
|
2025-08-26 14:52:12 +02:00
|
|
|
echo "Configuring relocated store at $NIX_REMOTE..."
|
2024-03-19 18:01:05 +01:00
|
|
|
|
2025-10-23 19:42:05 +02:00
|
|
|
# Create nix.conf with experimental features enabled
|
|
|
|
|
mkdir -p "$NIX_CONF_DIR"
|
|
|
|
|
echo "experimental-features = ca-derivations flakes" > "$NIX_CONF_DIR/nix.conf"
|
|
|
|
|
|
2025-08-26 14:52:12 +02:00
|
|
|
# Init ahead of time, because concurrent initialization is flaky
|
2025-10-27 01:37:18 +01:00
|
|
|
${config.nix-bindings-rust.nixPackage}/bin/nix-store --init
|
2024-03-19 18:01:05 +01:00
|
|
|
|
2025-08-26 14:52:12 +02:00
|
|
|
echo "Store initialized."
|
|
|
|
|
'';
|
|
|
|
|
};
|
2024-02-16 09:14:15 +01:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
2024-02-08 16:58:45 +01:00
|
|
|
}
|