gytis-ivaskevicius / flake-utils-plus

Use Nix flakes without any fluff.
MIT License
459 stars 52 forks source link

`generateNixPathFromInputs` should check for `default.nix` file instead of for package set #107

Closed lilyball closed 2 weeks ago

lilyball commented 2 years ago

nix.generateNixPathFromInputs only adds inputs to NIX_PATH if they have a packages or legacyPackages output. This is a rather curious restriction, as the existence of such a package set does not prove that the flake source can be imported directly. It also means that flakes that can be imported, such as nix-darwin, don't end up in NIX_PATH as they don't have a package set.

Instead of testing for the package set, it should check if the flake has a default.nix file. Unfortunately I don't think Nix lets you test if a file exists, so this might require using an activation script instead of config.environment.etc. Though perhaps setting environment.etc."nix/input".source to a derivation whose outPath is a directory of symlinks might work? That way the derivation build script can test the inputs for a default.nix.

lilyball commented 2 years ago

I hacked this together myself, and I can confirm that environment.etc."nix/input".source = pkgs.runCommandNoCC works to build a directory. There may be an issue activating the result for anyone who already has the existing /etc/nix/inputs as a directory though (this is true for nix-darwin, I don't know if nixos's environment.etc activation is any smarter, though my belief is nix-darwin just copied it from nixos).

gytis-ivaskevicius commented 2 years ago

Yeah, good point. Will implement it this weekend

gytis-ivaskevicius commented 2 years ago

I think it's fixed by https://github.com/gytis-ivaskevicius/flake-utils-plus/issues/105?