numtide / flake-utils

Pure Nix flake utility functions [maintainer=@zimbatm]
MIT License
1.21k stars 79 forks source link

eachDefaultSystem docs are sorely missing a real example #94

Open colemickens opened 1 year ago

colemickens commented 1 year ago

I'm very unconvinced about using a flake import to override the systems that "eachDefaultSystem" is going to build for. I love flakes but seeing inputs used for this seems confusing to me.

Further, I've been looking at/for examples, etc, and have no idea how to get jj (https://github.com/martinvonz/jj) to support riscv64-linux.

colemickens commented 1 year ago

This pattern is throwing up red flags for me. Least of all, overriding a transitive dependency with a path doesn't seem to work.

I have:

{
 systems = { url = "path:./flake.systems.nix"; flake = false; };
 jj = { url = "github:martinvonz/jj"; inputs."flake-utils".inputs."systems".follows = "system"; };
}

and I can see from reading the lock file that the override is not working.

colemickens commented 1 year ago

I guess I can override flake-utils, with it's system overridden, and then pass that to jj as an override, but ... this is going to get hairy fast. So this sorta works:

{
    systems = { url = "path:./flake.systems.nix"; flake = false; };
    flake-utils = { url = "github:numtide/flake-utils"; inputs."systems".follows = "systems"; };
    jj = { url = "github:martinvonz/jj"; inputs."flake-utils".follows = "flake-utils"; };
}

Now I have multiple (enough, really) flake-utils through my flake.lock, but now I also have this version that is slightly different. Now I have to decide if I override every potential flake input that consume flake-utils.

Also, a question -- should I have been able to override that dependency transitively?

zimbatm commented 1 year ago

I think your last example is the right way to do it, given the current design constraints of flakes.

The best is to flatten the inputs as much as possible so there is only one version of each dependency.

Moise225 commented 6 months ago

latest.json

malik-n commented 2 weeks ago

I am also looking for another example. Trying to simplify my flake.nix with eachDefaultSystem but turning it unusable.

Is there any example flake.nix that defines nixosConfigurations and formatter? Using treefmt maybe