Closed Industrial closed 2 hours ago
This is the minimal reproduction:
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-parts.url = "github:hercules-ci/flake-parts";
nix-unit.inputs.nixpkgs.follows = "nixpkgs";
nix-unit.url = "github:nix-community/nix-unit";
};
outputs = inputs @ {self, ...}:
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
systems = inputs.nixpkgs.lib.systems.flakeExposed;
flake = {
tests.testPass = {
expr = 3;
expected = 4;
};
};
perSystem = {
system,
pkgs,
...
}: {
checks = {
tests =
pkgs.runCommand "tests"
{
nativeBuildInputs = [
inputs.nix-unit.packages.${system}.default
];
} ''
export HOME="$(realpath .)"
# The nix derivation must be able to find all used inputs in the nix-store
# because it cannot download it during buildTime.
nix-unit --eval-store "$HOME" \
--extra-experimental-features flakes \
--override-input nixpkgs ${inputs.nixpkgs} \
--flake ${self}#tests
touch $out
'';
};
};
};
}
I caved in and removed flake-parts
.
Then I found that I can just run the unit tests pre-push
with https://github.com/cachix/git-hooks.nix (already had that installed). Works perfectly :D
Hi.
I'm trying to implement
nix-unit
: https://nix-community.github.io/nix-unit/examples/flakes.htmlWhen I add it to my
nix flake check
then I get an error about it not being able to download things.The page specifically says
# The nix derivation must be able to find all used inputs in the nix-store because it cannot download it during buildTime.
and that's happening so I don't know what I did wrong :SThis is where I'm using the check in my flake (using
flake-parts
): https://github.com/Industrial/nixos-dotfiles/blob/main/flake.nix#L98This is the check: https://github.com/Industrial/nixos-dotfiles/blob/main/checks/tests.nix
Hmm copy pasting the example into a flake works. It must be my setup that's the problem.