lix-module does not seem to work with nix-darwin #42

Closed
opened 2024-10-25 01:14:06 +00:00 by dstcruz · 2 comments

*Expected behavior:

After a nix-darwin install following the Lix install instructions I expect nix --version to report that I'm using Lix.

Observed behavior:

After a nix-drawing install following the Lix install instructions it seems that lix-module is not setting the nix package in nix-darwin to Lix.

To reproduce:

After a fresh install of Lix on a Mac, I can see that the system is indeed using Lix:

-bash-3.2$ nix --version
nix (Lix, like Nix) 2.91.1

After installing nix-darwin using the flake configuration at the bottom I get:

-bash-3.2$ nix --version
nix (Nix) 2.24.9

There are currently 2 nixes installed in the system -- this seems to be normal with nix-darwin installs. The first one on the path is the one provided by nix-darwin, the second one is the one provided by the Lix install:

-bash-3.2$ which -a nix
/run/current-system/sw/bin/nix
/nix/var/nix/profiles/default/bin/nix

I can verify that, in deed, the second one reports Lix, as expected.

Here is the minimal flake.nix used, which follows the Lix install directions

{
  description = "Minimal failing flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

    lix-module = {
      url = "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    nix-darwin = {
      url = "github:LnL7/nix-darwin";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  # Build using: 
  # > darwin-rebuild switch --flake .#macbook
  outputs = inputs @ {lix-module, ...} : {
    darwinConfigurations.macbook =
      inputs.nix-darwin.lib.darwinSystem {
        system = "x86_64-darwin";
        pkgs = import inputs.nixpkgs { system = "x86_64-darwin"; };

        modules = [
          # see: https://lix.systems/add-to-config/
          lix-module.nixosModules.default

          ({ pkgs, ... }: {
            environment.systemPackages = [
            ];

            nix.useDaemon = true;
            nix.extraOptions = ''
              experimental-features = nix-command flakes
            '';

            # Used for backwards compatibility, please read the changelog before changing.
            # $ darwin-rebuild changelog
            system.stateVersion = 4;
          })
        ];
      };
  };
}
***Expected behavior:** After a nix-darwin install following the Lix install instructions I expect `nix --version` to report that I'm using Lix. **Observed behavior:** After a nix-drawing install following the Lix install instructions it seems that `lix-module` is not setting the nix package in nix-darwin to Lix. **To reproduce:** After a fresh install of Lix on a Mac, I can see that the system is indeed using Lix: ```bash -bash-3.2$ nix --version nix (Lix, like Nix) 2.91.1 ``` After installing nix-darwin using the flake configuration at the bottom I get: ```bash -bash-3.2$ nix --version nix (Nix) 2.24.9 ``` There are currently 2 nixes installed in the system -- this seems to be normal with nix-darwin installs. The first one on the path is the one provided by nix-darwin, the second one is the one provided by the Lix install: ```bash -bash-3.2$ which -a nix /run/current-system/sw/bin/nix /nix/var/nix/profiles/default/bin/nix ``` I can verify that, in deed, the second one reports Lix, as expected. Here is the minimal `flake.nix` used, which follows the Lix install directions ```nix { description = "Minimal failing flake"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; lix-module = { url = "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz"; inputs.nixpkgs.follows = "nixpkgs"; }; nix-darwin = { url = "github:LnL7/nix-darwin"; inputs.nixpkgs.follows = "nixpkgs"; }; }; # Build using: # > darwin-rebuild switch --flake .#macbook outputs = inputs @ {lix-module, ...} : { darwinConfigurations.macbook = inputs.nix-darwin.lib.darwinSystem { system = "x86_64-darwin"; pkgs = import inputs.nixpkgs { system = "x86_64-darwin"; }; modules = [ # see: https://lix.systems/add-to-config/ lix-module.nixosModules.default ({ pkgs, ... }: { environment.systemPackages = [ ]; nix.useDaemon = true; nix.extraOptions = '' experimental-features = nix-command flakes ''; # Used for backwards compatibility, please read the changelog before changing. # $ darwin-rebuild changelog system.stateVersion = 4; }) ]; }; }; } ```
Member

I'm not very familiar with nix-darwin, but your setup looks wrong. This line:

pkgs = import inputs.nixpkgs { system = "x86_64-darwin"; };

Sets pkgs to be as is in nixpkgs input. And nixpkgs input doesn't have an overlay applied. So basically, you force-override the pkgs to ignore the overlay that is supplied by lix-module.

Removing this line should help. Let me know if there are further issues, or if there's anything on the documentation side that we should fix!

I'm not very familiar with `nix-darwin`, but your setup looks wrong. This line: ``` pkgs = import inputs.nixpkgs { system = "x86_64-darwin"; }; ``` Sets `pkgs` to be as is in `nixpkgs` input. And `nixpkgs` input doesn't have an overlay applied. So basically, you force-override the `pkgs` to ignore the overlay that is supplied by `lix-module`. Removing this line should help. Let me know if there are further issues, or if there's anything on the documentation side that we should fix!
Author

That did it. I can't figure out how that line made it into my flake, as I have searched for the likely places where it could have come from and I can't find it. I thought it came from the nix-darwin flake instructions, but it is clearly not there.

Thanks for the reply!

That did it. I can't figure out how that line made it into my flake, as I have searched for the likely places where it could have come from and I can't find it. I thought it came from the nix-darwin flake instructions, but it is clearly not there. Thanks for the reply!
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/nixos-module#42
No description provided.