LnL7 / nix-darwin

nix modules for darwin
MIT License
3.19k stars 457 forks source link

flake: match NixOS definition of `nixpkgs.flake.source` #1083

Closed emilazy closed 1 month ago

emilazy commented 2 months ago

Closes: #1082

emilazy commented 2 months ago

This is still wrong because Nixpkgs isn’t necessarily from our nixpkgs input at all and I forgot all the lessons I learned in https://github.com/LnL7/nix-darwin/pull/723 and everything is sad and I need to do something else here. :(

sellout commented 2 months ago

FWIW, my configuration builds successfully with this change. Good luck with finding a solution that satisfies you!

Enzime commented 2 months ago

How does this PR relate to #1076?

antoineco commented 2 months ago

I'm admitedly confused about this one. The error was

'nix.registry.nixpkgs.to.path' is defined multiple times

but all this PR does is type the value of nixpkgs.flake.source from a flake attrset to a string representation of its path in the Nix store.

How does this prevent said option from being set multiple times?


edit: I see the mkIf (config.flake != null) now:

https://github.com/LnL7/nix-darwin/blob/21fe31f26473c180390cfa81e3ea81aca0204c80/modules/nix/nixpkgs-flake.nix#L91-L94

https://github.com/LnL7/nix-darwin/blob/6374cd7e50aa057a688142eed2345083047ad884/modules/nix/default.nix#L478-L482

emilazy commented 2 months ago

Sorry for the dramatic reaction, I have just been repeatedly burned by Nixpkgs mismatch issues :)

I will try to explain what’s going on here and what issues there still are tomorrow.

emilazy commented 2 months ago

Didn’t end up getting around to writing down all the moving parts here today; will try to do so in the next couple days. The tl;dr is that this PR won’t make anything worse and should be okay to merge, but the whole way this is set currently is quite incorrect in a way that can result in pretty bad outcomes (e.g. pinning a vulnerable version of Nixpkgs even though your system uses a good one, or even getting a different release branch entirely). I think the upstream NixOS version of this is also broken in a similar but less likely to trigger way (due to the fact that it’s in the Nixpkgs repository itself). I’m still thinking about the best way to resolve the issues; https://github.com/LnL7/nix-darwin/pull/1076 is not strictly related, but could potentially also use some rethinking depending on what ends up seeming best (and I should adjust it to fix https://github.com/LnL7/nix-darwin/issues/792 anyway).