Skip to content

Conversation

@ckiee
Copy link
Member

@ckiee ckiee commented Jan 1, 2023

This allows the user of this non-flake to have similar functionality to follows.

Example (default.nix):

nix-repl> (import ./.).default
«derivation /nix/store/axgvq22kyb8ymchzq1mjayms4jdl6ni6-ledc-0.1.0.drv»

nix-repl> ((import ./.).overrideInputs { nixpkgs = <nixpkgs>; }).default
«derivation /nix/store/r8zw693hpg91yx6f57hyx1gk4zdiq2lm-ledc-0.1.0.drv»

It's currently only able to override our flake's direct inputs. Sorry for the big diff.

ckiee added 2 commits January 1, 2023 23:42
This allows the user of this non-flake to have similar functionality
to `follows`.

Example (default.nix):

    nix-repl> (import ./.).default
    «derivation /nix/store/axgvq22kyb8ymchzq1mjayms4jdl6ni6-ledc-0.1.0.drv»

    nix-repl> ((import ./.).overrideInputs { nixpkgs = <nixpkgs>; }).default
    «derivation /nix/store/r8zw693hpg91yx6f57hyx1gk4zdiq2lm-ledc-0.1.0.drv»
Accept other forks also with type="github".

This is enough to be a bit more convenient in a few more
cases once this propagates into new future projects.
Copy link
Member

@lheckemann lheckemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense overall, and the diff isn't even that big when whitespace is ignored :)

in "${toString y'}${pad (toString m)}${pad (toString d)}${pad (toString hours)}${pad (toString minutes)}${pad (toString seconds)}";

rootOverrides =
mapAttrs'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason to use mapAttrs' and not mapAttrs here?

if key == lockFile.root
then rootSrc
else
if rootOverrides.${key} != null then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if rootOverrides.${key} != null then
if (rootOverrides.${key} or null) != null then

Copy link
Member

@Eveeifyeve Eveeifyeve Nov 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why or null if it returns null????

@ckiee
Copy link
Member Author

ckiee commented Sep 18, 2023

@lheckemann some work continues in https://github.com/ElvishJerricco/flake-compat/tree/add-overrideInputs. i don't currently have the spoons for a review cycle, this may change by next week.

if you're looking for this to get merged, it'd probably be wise to make a PR against https://github.com/nix-community/flake-compat 💜

@DavHau
Copy link
Member

DavHau commented Sep 30, 2023

The current head of the PR is broken, it is missing inputs, no matter if overrideInputs is used or not.
Errror:

error: attribute 'nixpkgs_2' missing

       at /nix/store/dp0f4gy50va2lbrz970lx9v65qb4qv70-source/default.nix:159:20:

          158|               else
          159|                 if rootOverrides.${key} != null then
             |                    ^
          160|                   { type = "path";
       Did you mean nixpkgs?

The PR at the nix-community flake-compat does work fine

@Eveeifyeve
Copy link
Member

Eveeifyeve commented Nov 23, 2025

I am going to get a bit of movement on this pr.
If it means I have to make a pr to close this one so be it.

@adrian-gierakowski
Copy link
Contributor

this i badly needed

@Mic92
Copy link
Member

Mic92 commented Dec 6, 2025

@adrian-gierakowski probably easier to just open a new pr.

@adrian-gierakowski
Copy link
Contributor

@adrian-gierakowski probably easier to just open a new pr.

@Mic92 Yes, I was just looking into this. I think I'd like to build on top of this PR (if there is a chance it could be merged soon) as I'd like to add some tests

Copy link
Contributor

@adrian-gierakowski adrian-gierakowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've taken this for a spin and here's my understanding of how it works:

  1. it allows to override specific top level input by providing a "path" (relative or absolute)
  2. any type of input can be overriden
  3. follows which point at overridden input's inputs are not modified
    for example, given inputs a and b, and a.inputs.nixpkgs.follows = "b/nixpkgs", when b gets overridden, a's nixpkgs will remain unchanged

@Mic92 @roberth let me know what you think, is this sufficient or do you have something more sophisticated in mind?

@roberth
Copy link
Member

roberth commented Dec 7, 2025

The Nix CLI with --override-input does seem to respect follows, whereas this only replaces a specific input relation.

I'm also concerned that this limited feature creates friction for a more generalized or "compliant" version of the same feature.

Furthermore I believe there's significant tech debt in flake-compat that makes it harder to see a more general solution; an over-reliance on the arbitrarily named nodes.*.

@adrian-gierakowski
Copy link
Contributor

I'd recommend closing this PR now and continue the conversation on the rebased up-to-date version here

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants