diff --git a/default.nix b/default.nix index ec64995..37e87db 100644 --- a/default.nix +++ b/default.nix @@ -23,7 +23,7 @@ let gitignoreSourceWith = { path }: lib.cleanSourceWith { name = "source"; - filter = find-files.gitignoreFilterWith { basePath = path.origPath or path; }; + filter = find-files.gitignoreFilterWith { basePath = path.origSrc or path; }; src = path; }; diff --git a/nix/ci.nix b/nix/ci.nix index c574b1a..5a529e4 100644 --- a/nix/ci.nix +++ b/nix/ci.nix @@ -5,7 +5,6 @@ let ; in dimension "Nixpkgs" { - "nixpkgs-19_03" = sources."nixos-19.03"; "nixpkgs-19_09" = sources."nixos-19.09"; "nixpkgs-21_05" = sources."nixos-21.05"; } (_key: nixpkgs: diff --git a/nix/sources.json b/nix/sources.json index 56cbf2a..5aafd37 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -11,18 +11,6 @@ "url": "https://github.com/nmattia/niv/archive/5e9671a9a87c240b1c6ce981d04ad23ba4291451.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, - "nixos-19.03": { - "branch": "nixos-19.03", - "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", - "homepage": "https://github.com/NixOS/nixpkgs", - "owner": "NixOS", - "repo": "nixpkgs-channels", - "rev": "2dfae8e22fde5032419c3027964c406508332974", - "sha256": "0293j9wib78n5nspywrmd9qkvcqq2vcrclrryxqnaxvj3bs1c0vj", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs-channels/archive/2dfae8e22fde5032419c3027964c406508332974.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, "nixos-19.09": { "branch": "nixos-19.09", "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", diff --git a/tests/default.nix b/tests/default.nix index a02acfa..18844be 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -1,4 +1,4 @@ -{ pkgs ? import {} }: +{ pkgs ? import {}, lib ? pkgs.lib }: let testdata = import ./testdata.nix { inherit pkgs; }; @@ -22,13 +22,31 @@ in subdir-9 = runner.makeTest { name = "subdir-9"; rootDir = testdata.sourceUnfiltered + "/test-tree"; subpath = "9-expected"; }; subdir-10 = runner.makeTest { name = "subdir-10"; rootDir = testdata.sourceUnfiltered + "/test-tree"; subpath = "10-subdir-ignoring-itself"; }; + # Make sure the files aren't added to the store before filtering. + shortcircuit = runner.makeTest { + name = "nested"; + rootDir = testdata.sourceUnfilteredRecursive + "/test-tree"; + preCheck = '' + # Instead of a file, create a fifo so that the filter would error out if it tries to add it to the store. + rm 1-simpl/1 + mkfifo 1-simpl/1 + ''; + }; + unit-tests = let gitignoreNix = import ../default.nix { inherit (pkgs) lib; }; - inherit (gitignoreNix) gitignoreFilterWith; + inherit (gitignoreNix) gitignoreFilterWith gitignoreSourceWith; example = gitignoreFilterWith { basePath = ./.; extraRules = '' *.foo !*.bar ''; }; + shortcircuit = gitignoreSourceWith { + path = { + inherit (lib.cleanSource ./.) _isLibCleanSourceWith filter name; + outPath = throw "do not use outPath"; + origSrc = ./.; + }; + }; in # Test that extraRules works: @@ -36,6 +54,9 @@ in assert example ./x.bar "regular" == true; assert example ./x.qux "regular" == true; + # Make sure outPath is not used. (It's not about the store path) + assert lib.hasPrefix builtins.storeDir "${shortcircuit}"; + # End of test. (a drv to show a buildable attr when successful) pkgs.emptyFile or null; -} \ No newline at end of file +} diff --git a/tests/runner.nix b/tests/runner.nix index cca3d89..dac3a99 100644 --- a/tests/runner.nix +++ b/tests/runner.nix @@ -24,11 +24,11 @@ let discover rootDir by itself. */ - makeTest = {name ? "source", rootDir, subpath ? ""}: + makeTest = {name ? "source", rootDir, subpath ? "", preCheck ? ""}: pkgs.runCommand "test-${name}" { inherit name; viaGit = listingViaGit { inherit name rootDir subpath; }; - viaNix = listingViaNixGitignore { inherit name rootDir subpath; }; + viaNix = listingViaNixGitignore { inherit name rootDir subpath preCheck; }; } '' if diff $viaNix $viaGit; then touch $out @@ -64,7 +64,7 @@ let installPhase = ":"; }; - listingViaNixGitignore = {name ? "source", rootDir, subpath}: + listingViaNixGitignore = {name ? "source", rootDir, subpath, preCheck}: pkgs.stdenv.mkDerivation { name = "${name}-listing-via-nix"; src = rootDir; @@ -79,6 +79,7 @@ let export NIX_LOG_DIR=$TMPDIR export NIX_STATE_DIR=$TMPDIR test -n "$subpath" && cd $subpath + ${preCheck} nix-instantiate --eval --expr --json \ --readonly-mode --option sandbox false \ '(import ${gitignoreSource ../.}/tests/runner.nix {}).toStringNixGitignore ./.' \