LnL7 / nix-darwin

nix modules for darwin
MIT License
2.82k stars 431 forks source link

Nixpkgs config (e.g. allowUnfree) not being picked up properly? #1045

Closed tsteckenborn closed 1 month ago

tsteckenborn commented 1 month ago

Hey there,

Currently in the process of setting up nix-darwin for the first time.

I specified

          nixpkgs.config = {
            allowUnfree = true;
            allowBroken = false;
            allowUnsupportedSystem = false;
          };

yet when reaching a packages such as Raycast I receive an error w.r.t. allowUnfree:

error: Package ‘raycast-1.81.2’ in /nix/store/p9sy5nf9jdwj69gmr3c3n03npzr5kkqi-source/pkgs/os-specific/darwin/raycast/default.nix:55 has an unfree license (‘unfree’), refusing to evaluate.

Exporting export NIXPKGS_ALLOW_UNFREE=1 with --impure seems to work, but I'd have expected that I don't need that given the config above. Can someone shed some light on how this should behave?

Edit: Seems like atleast one other person has a similar issue in Originally posted by @bglgwyng in https://github.com/LnL7/nix-darwin/issues/89#issuecomment-2122218235

Enzime commented 1 month ago

What does your nix-darwin.lib.darwinSystem call look like?

tsteckenborn commented 1 month ago
    darwinConfigurations."HostName" = darwin.lib.darwinSystem {
      system = "aarch64-darwin";
      pkgs = import nixpkgs {system = "aarch64-darwin";};

      modules = [
            ({pkgs, ...}: {
            ...<further content>
Enzime commented 1 month ago

If you pass in pkgs, then it won't be constructed by nix-darwin and the nixpkgs.* options won't work. You can just remove the pkgs = ... line

tsteckenborn commented 1 month ago

Could you help me understand the use of the respective line? I'm asking as I've seen that in a lot of (older) guides and partially in other configurations I could find on GitHub (with partial inclusion of such nixpkgs config as well, which if the usage hasn't changed might indicate that a few people might run into this issue)

Enzime commented 1 month ago

If you're using that exact line, then there's no value in defining it that way because it won't allow you to use the nixpkgs.* options to configure Nixpkgs and you're not giving it any special options, so you might as well let nix-darwin instantiate Nixpkgs. The main use case would be if you're already instantiating Nixpkgs elsewhere in your flake.nix and want to share the same instance.