hercules-ci / flake-parts

❄️ Simplify Nix Flakes with the module system
https://flake.parts
MIT License
721 stars 41 forks source link

perSystem: include outPath in flake attributes #152

Closed Pacman99 closed 1 year ago

Pacman99 commented 1 year ago

I want to pass self' to my nixos modules and be able to do "${self'}/... to refer to paths within the flake. I think it would be good for flake-parts to preserve outPath within self' and inputs in inputs', so that way self' and inputs' are identical to self and inputs but with system picked out.

roberth commented 1 year ago

For context, this PR was discussed here in

I think flake-parts should promote encapsulation, but you are free to define this addition in your own flake for your convenience. I.e.

{
  perInput = system: flake: {
    # Allow for input coercion to string, ex: "${inputs'.flake-parts}/shell.nix"
    inherit (flake) outPath;
  };
}

I'd be open to adding this little module as flake-parts.flakeModules.perSystemOutPath. (perInputOutPath is probably not as obvious to readers)

Another idea is to add a perInput attribute like flake, such that self'.flake == self; perhaps in perSystem.nix's config.