NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.9k stars 1.53k forks source link

Untracked files excluded from flake even with "path:" input #11930

Open cecchi opened 4 days ago

cecchi commented 4 days ago

Describe the bug

I am a new Nix user. After discovering that files that are untracked by git are not included in Nix flakes, I found a suggested workaround to use a path: input: https://hackmd.io/@nix-ux/Hkvf16Xw5?print-pdf#/

Unfortunately, neither of these result in the untracked file(s) being included:

inputs = {
  local-src = "path:";
};
inputs = {
  local-src = {
    url = "path:";
    flake = false;
  };
};

However, if I use --override-input local-src "path:" it does work (even though as far as I can tell I am overriding the value with the exact same value).

Without override (untracked files are not included):

> nix build .#buildApp
error: builder for '/nix/store/qlc9344v6qm1cz7gnimxly73csvbzqn0-foo.drv' failed with exit code 1;
       last 17 log lines:
       # ... edited for brevity ...
       > Running phase: installPhase
       > No ignore.txt

With override (untracked files are included):

> nix build .#buildApp --override-input local-src "path:"
• Updated input 'local-src':
    'path:?lastModified=0&narHash=sha256-V416LmrnNZ55aFRBeYrKsdW%2BCJmkEmPnS5W6pa1q0rs%3D' (1970-01-01)
  → 'path:?lastModified=1732159360&narHash=sha256-jNUXrWnLZid%2BPehmOvk8/pDM%2BaIG1AUPugxO3%2BUv4PQ%3D' (2024-11-21)

Steps To Reproduce

I have created a minimal reproduction repo here: https://github.com/cecchi/nix-path-input-bug-repro

Expected behavior

  1. There should be a clear and documented way to include files that are not tracked by git (https://github.com/NixOS/nix/pull/9352)
  2. The --override-input argument should not change the behavior when setting the same value

nix-env --version output

nix-env (Nix) 2.25.0

Priorities

Add :+1: to issues you find important.