Skip to content

null flake input #7807

Open
Open

Description

@maralorn

Is your feature request related to a problem? Please describe.
When a flake input has unneeded dependencies, it might be desirable to ensure that they won’t be downloaded or accessed. (e.g. when nix flake archive is used).

Describe the solution you'd like
I’d like to have the possibility to do something like

inputs.foo = { url = "..."; inputs.bar = null; }

This would ideally clearly fail with an error message whenever that flake input would be accessed during evaluation.

Describe alternatives you've considered

  1. I considered uploading an empty flake on github with a flake.nix which contains { outputs = _:{}; }.
    Then I could do inputs.bar.url = github:user/empty; this has the downside of unnecessary network requests, especially because this might be needed in moments when there is no network access.

  2. A flake like that could even be added to the registry, so that one could do inputs.bar.url = "empty"; but that has the same downsides.

  3. I have tried inputs.foo.inputs.bar = { url = "file:/dev/null"; flake = false; }. This works to add a dummy input to a flake, i.e. { inputs.foo = { url = "file:/dev/null; flake = false; }. (I don’t know why one would ever do that.) However, when overriding a dependency this way if the dependency (in this case foo) has not set flake = false for bar then it will still try to access the flake.nix of /dev/null and thus throw an error.

  4. An alternative solution which requires a change in nix might be inputs.bar.url = "empty"; but empty is considered magic and resolves to the flake suggested in 1. without network access.

  5. An inline flake input would also help here, e.g.: inputs.bar = { type = "inline"; value = { outputs = _:{};} but it’s a rather crazy idea.

Activity

  1. added
    feature
    on Feb 11, 2023
  2. maralorn commented on Feb 11, 2023

    @maralorn
    MemberAuthor

    To clarify: I am not a big fan of any of those solutions I just would like to control the dependency closure of my flake somehow.

  3. NobbZ commented on Feb 12, 2023

    @NobbZ
    Contributor

    In my blog I had troubles with a nar error for an unneded input. And as it wasn't actually needed I let it follow yet another flake input (in this case nixpkgs), though someone else said making it follow "" should work as well, which I just tried, and a nix flake prefetch and a nix build still seem to complete succesfully.

    https://github.com/NobbZ/nobbz-dev-astro/blob/main/flake.nix#L6-L7

  4. maralorn commented on Feb 13, 2023

    @maralorn
    MemberAuthor

    Yes, inputs.foo.inputs.bar.follows = "" is my current workaround. It works, but error messages from that can be very gnarly and it might produce very weird bugs if no error occurs.

  5. roberth commented on Feb 13, 2023

    @roberth
    Member

    follow ""

    This means to follow the local flake aka self.
    When the interaction between your dependency and its dependency changes, this could lead to some weird errors. A null flake could throw a clear error instead: flake input 'foo.bar.baz' was set to 'null' by 'foo', but it appears to be needed nonetheless. or something.

  6. maralorn commented on Feb 13, 2023

    @maralorn
    MemberAuthor

    Yeah, exactly. That’s why I opened this issue. Edit: (Ah, you weren’t quoting me. Then my response is not that necessary.)

  7. NobbZ commented on Feb 14, 2023

    @NobbZ
    Contributor

    This means to follow the local flake aka self.

    Interesting, I wasn't aware of these semantics and always assumed this was "the empty flake" already.

    Indeed an explicit null/empty flake would make it much nicer and nix understanding the intend would improve the possibility of error reporting a lot!

    Thank you for explaining the differences.

  8. moved this to 🏗 To discuss in Nix teamon Feb 17, 2023
  9. nixos-discourse commented on Feb 20, 2023

    @nixos-discourse
  10. moved this from ⚖ To discuss to ⏰ Postponed in Nix teamon Feb 27, 2023
  11. valpackett commented on Feb 7, 2026

    @valpackett

    I have a different use case for an actual null input. I want a non-flake input (source code) to be null by default…

    {
      inputs = {
        nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
        thing-src = {
          flake = false;
          # nothing else, just, null
        };
      };
    
      outputs = { nixpkgs, thing-src }: {
        packages.aarch64-linux.thing = if builtins.isNull thing-src
          then nixpkgs.thing
          else (nixpkgs.thing.overrideAttrs { src = thing-src; });
      };
    }

    …in order to be able to override sources from the command line like nix develop --override-input thing-src ../thing-src without incurring the overhead of the source being an input to the flake when not overriding. I.e. when not overriding, I want to keep reusing the existing cache for a fetch… derivation that's used as the source, which flake inputs can't reuse.

  12. syborg64 commented on Nov 12, 2026

    @syborg64

    Nix store have a similar concept of a dummy store
    Is is a valid but empty store.

    One clean way to support these sorts of usecases would be to have a (first-party) dummy flake which is a valid but empty flake.

    • It would allow default-empty inputs that can be meaningfully overridden
    • It would allow 'disabling' inputs by overriding them with an dummy flake (where evaluation is compatible)
    • It doesn't suffer as nearly much from the issues of a null value (e.g. validity, differences in semantics)

    The same dummy url used by stores dummy:// is already syntactically compatible

  13. syborg64 commented on Nov 12, 2026

    @syborg64

    For users wanting a similar functionality before proper support, we can achieve this with file:///dev/null as a non-flake.

    Evaluating it returns an empty source.

    some boilerplate can evaluate it as a flake by importing the contained flake.nix (when pointed to a real flake)
    As long as it's not evaluated, it won't fail. More boilerplate can be added to let it evaluate to an empty flake (when pointed to /dev/null)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions