Hi all, road blocked for me when installing nix-darwin with home-manager on my system.
nix-info -m
- system: `"x86_64-darwin"`
- host os: `Darwin 24.1.0, macOS 10.16`
- multi-user?: `yes`
- sandbox: `no`
- version: `nix-env (Nix) 2.24.10`
- channels(root): `"nixpkgs"`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
edited: I just noticed it says macOS 10.16, I’m on Sequoia 15.1
Nix was installed using sh <(curl -L https://nixos.org/nix/install)
to a clean machine.
Here are my files (~/nixconfig)
flake.nix
{
description = "Worka's Darwin system flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-darwin = {
url = "github:LnL7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nix-darwin, home-manager }:
let
darwinUser = builtins.getEnv "DARWIN_USER";
darwinHost = builtins.getEnv "DARWIN_HOST";
workaDarwinSystem = { hostname, username }: nix-darwin.lib.darwinSystem {
system = "x86_64-darwin";
modules = [
./configuration.nix
home-manager.darwinModules.home-manager
{
networking.hostName = hostname;
users.users.${username}.home = "/Users/${username}";
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.${username} = { pkgs, lib, ... }:
import ./home.nix { inherit pkgs lib username; };
}
];
specialArgs = {
inherit (nixpkgs) lib;
inherit username;
};
};
in {
darwinConfigurations.${darwinHost} = workaDarwinSystem {
hostname = darwinHost;
username = darwinUser;
};
};
}
home.nix
{ pkgs, lib, username, ... }:
{
home.packages = with pkgs; [
neovim
git
tree
ripgrep
fd
jq
];
home.username = username;
home.homeDirectory = lib.mkForce "/Users/${username}";
home.stateVersion = "24.05";
# home-manager enable
programs.home-manager.enable = true;
}
configuration.nix
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
vim
git
];
services.nix-daemon.enable = true;
nix.package = pkgs.nix;
# zsh enable
programs.zsh.enable = true;
# allows unfree packages to be installed
nixpkgs.config.allowUnfree = true;
# Finder settings
system.defaults.finder = {
AppleShowAllExtensions = true;
AppleShowAllFiles = true;
CreateDesktop = false;
FXEnableExtensionChangeWarning = false;
ShowPathbar = true;
ShowStatusBar = true;
};
# Dock setting
system.defaults.dock = {
autohide = true;
show-recents = false;
tilesize = 50;
magnification = true;
largesize = 64;
orientation = "bottom";
mineffect = "scale";
launchanim = false;
};
system.stateVersion = 5;
nixpkgs.hostPlatform = "x86_64-darwin";
}
As per nix-darwin documentation the next step is to run this command:
nix run nix-darwin -- switch --flake ~/.config/nix-darwin
which I adjust to match the nix run nix-darwin -- switch --flake ~/nixconfig
I tried also with nix run nix-darwin --extra-experimental-features "nix-command flakes" -- switch --flake ~/nixconfig
.
Error:
error: flake ‘git+file:///Users/worka/nixconfig’ does not provide attribute ‘packages.x86_64-darwin.darwinConfigurations.Workas-MacBook-Pro.system’, ‘legacyPackages.x86_64-darwin.darwinConfigurations.Workas-MacBook-Pro.system’ or ‘darwinConfigurations.Workas-MacBook-Pro.system’
echo $DARWIN_USER & $DARWIN_HOST is correct.
What went wrong?
Or rather what should I do next if I want to have home-manager installed correctly?
Thanks in advance.