Describe the bug
When using lib.fileset.gitTracked in combination with --store, the build fails with lib.fileset.gitTracked: Expected the argument (/tmp/nix-store/nix/store/8a5a320f0h66jh066qabxkm67msvbcql-source) to point to a local working tree of a Git repository, but it's not.
Steps To Reproduce
-
Create a new git repository
-
Add the following flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-23.11";
};
outputs = {nixpkgs, ...}: {
packages.x86_64-linux.default = let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
fs = pkgs.lib.fileset;
in
pkgs.stdenvNoCC.mkDerivation {
name = "gitTrackedBug";
src = fs.toSource {
root = ./.;
fileset = fs.gitTracked ./.;
};
buildPhase = "touch $out";
};
};
}
-
Build with nix build (works as expected)
-
Build with nix build --store /tmp/nix-store/ (this fails)
Additional context
I'm pretty sure this is the same underlying issue as #269283. I think the issue is that the hasStorePathPrefix check fails when it should trigger in the chroot-ed nix store
|
else if hasStorePathPrefix path then |
hasStorePathPrefix has a note about usage with other filesystem roots, which seems relevant
|
# This function likely breaks or needs adjustment if used with other filesystem roots, if they ever get implemented. |
|
# Let's try to error nicely in such a case, though it's unclear how an implementation would work even and whether this could be detected. |
|
# See also https://github.com/NixOS/nix/pull/6530#discussion_r1422843117 |
|
(deconstructed.root == /. && toString deconstructed.root == "/") |
|
"lib.path.hasStorePathPrefix: Argument has a filesystem root (${toString deconstructed.root}) that's not /, which is currently not supported."; |
but I don't know enough about how the actual --store implemention works under the hood to comment further.
Notify maintainers
@infinisil
Add a 👍 reaction to issues you find important.
Describe the bug
When using
lib.fileset.gitTrackedin combination with--store, the build fails withlib.fileset.gitTracked: Expected the argument (/tmp/nix-store/nix/store/8a5a320f0h66jh066qabxkm67msvbcql-source) to point to a local working tree of a Git repository, but it's not.Steps To Reproduce
Create a new git repository
Add the following
flake.nixBuild with
nix build(works as expected)Build with
nix build --store /tmp/nix-store/(this fails)Additional context
I'm pretty sure this is the same underlying issue as #269283. I think the issue is that the
hasStorePathPrefixcheck fails when it should trigger in thechroot-ed nix storenixpkgs/lib/fileset/internal.nix
Line 913 in 4551ff1
hasStorePathPrefixhas a note about usage with other filesystem roots, which seems relevantnixpkgs/lib/path/default.nix
Lines 398 to 402 in 066ccb9
but I don't know enough about how the actual
--storeimplemention works under the hood to comment further.Notify maintainers
@infinisil
Add a 👍 reaction to issues you find important.