Skip to content

Commit

Permalink
flake.nix: Do check
Browse files Browse the repository at this point in the history
  • Loading branch information
roberth committed Mar 6, 2024
1 parent 8c32e70 commit e6b79bd
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 30 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

# must match golden-tests/derivations/complex/new/flake.lock
nixpkgs-golden.url = "github:NixOS/nixpkgs/5ca8e2e9e1fa5e66a749b39261ad6bd0e07bc87f";

utils.url = "github:numtide/flake-utils";
};

outputs = { nixpkgs, utils, ... }:
outputs = inputs@{ nixpkgs, utils, ... }:
let
config = { };

Expand All @@ -22,7 +25,32 @@
# Golden tests require write access to the /nix/var
# and read access to the test data into /nix/store
# So we can't run these tests in build time
pkgsNew.haskell.lib.dontCheck
pkgsNew.haskell.lib.compose.overrideCabal
(old: {
testToolDepends = old.testToolDepends or [] ++ [
pkgsNew.nix
];
# For testing, we use a relocated Nix store, because the
# real /nix/store in the sandbox is only accessible as files;
# not a store objects (https://nixos.org/manual/nix/stable/glossary.html#gloss-store-object)
# A relocated store lets us use /nix/store as the logical
# storeDir, while using an arbitrary directory for storage.
preCheck = ''
${old.preCheck or ""}
TESTROOT="$(mktemp --tmpdir -d test-state-XXXXXX)"
export NIX_BUILD_HOOK=
export NIX_CONF_DIR=$TEST_ROOT/etc
export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
export NIX_STATE_DIR=$TEST_ROOT/var/nix
export NIX_REMOTE="$TESTROOT/store"
export HOME="$TESTROOT/home"
mkdir -p $HOME
echo "Copying pinned Nixpkgs for golden tests to relocated store $NIX_REMOTE"
nix eval --expr 'builtins.path { path = ${inputs.nixpkgs-golden}; name = "source"; }' \
--impure --extra-experimental-features nix-command --offline
'';
})
(self.callCabal2nix "nix-diff" ./. { });
};
});
Expand Down

0 comments on commit e6b79bd

Please sign in to comment.