numtide / flake-utils

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

Add convenient generic attribute #24

Closed jD91mZM2 closed 1 year ago

jD91mZM2 commented 3 years ago

Doing

{
  lib = {
    test = 1;
  };
} // eachDefaultSystem (system: {
  packages = { /* ... */ };
})

is really inconvenient. This lets you do

eachDefaultSystem (system: {
  lib.generic = {
    test = 1;
  };
  packages = { /* ... */ };
})
zimbatm commented 3 years ago

Agreed with the observation that the current situation could be better.

The proposed solution is not super discoverable and also re-instantiates the generic bits multiple times even if a single one will be used in the end.

What do you think of this instead?

eachDefaultSystem2 {
  generic = { lib.test = 1; };
  eachSystem = system: {
    packages = { /* ... */ };
  };
}
jD91mZM2 commented 3 years ago

Good idea!

zimbatm commented 3 years ago

@jD91mZM2: pushed another proposal. I think that generic should just override the top-level.

amitojsingh366 commented 3 years ago

https://www.redox-os.org/news/open-source-mental-health/