feat(darwin): add nix-darwin support with a default macOS host
Add the nix-darwin input (nix-darwin-26.05, follows nixpkgs) and a mkDarwinHost mirroring mkHost: shared commonModule (nixpkgs/nix settings) is factored out and reused, home-manager is wired via darwinModules, and identity is threaded through specialArgs. New darwinConfigurations.lyrathorpe-mac (aarch64-darwin) reuses the cross-platform ./lyrathorpe/home modules (shell, git, editor); Linux-only sway/desktop modules are excluded. Build with: darwin-rebuild switch --flake .#lyrathorpe-mac.
This commit is contained in:
Generated
+22
@@ -72,6 +72,27 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nix-darwin": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1779036909,
|
||||||
|
"narHash": "sha256-zXcwYQGCT6pzinK+1dBB2ekTVtfxGZAapb3Evdcu4fY=",
|
||||||
|
"owner": "nix-darwin",
|
||||||
|
"repo": "nix-darwin",
|
||||||
|
"rev": "56c666e108467d87d13508936aade6d567f2a501",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-darwin",
|
||||||
|
"ref": "nix-darwin-26.05",
|
||||||
|
"repo": "nix-darwin",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixos-apple-silicon": {
|
"nixos-apple-silicon": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
@@ -149,6 +170,7 @@
|
|||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-parts": "flake-parts",
|
"flake-parts": "flake-parts",
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
|
"nix-darwin": "nix-darwin",
|
||||||
"nixos-apple-silicon": "nixos-apple-silicon",
|
"nixos-apple-silicon": "nixos-apple-silicon",
|
||||||
"nixos-wsl": "nixos-wsl",
|
"nixos-wsl": "nixos-wsl",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
# Apple Silicon (Asahi) support for the MacBook host.
|
# Apple Silicon (Asahi) support for the MacBook host.
|
||||||
nixos-apple-silicon.url = "github:nix-community/nixos-apple-silicon";
|
nixos-apple-silicon.url = "github:nix-community/nixos-apple-silicon";
|
||||||
nixos-apple-silicon.inputs.nixpkgs.follows = "nixpkgs";
|
nixos-apple-silicon.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
# nix-darwin: manage macOS hosts from this same flake.
|
||||||
|
nix-darwin.url = "github:nix-darwin/nix-darwin/nix-darwin-26.05";
|
||||||
|
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
# Provides mkFlake: the systems/perSystem scaffolding used below.
|
# Provides mkFlake: the systems/perSystem scaffolding used below.
|
||||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
|
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||||
@@ -28,6 +31,7 @@
|
|||||||
home-manager,
|
home-manager,
|
||||||
nixos-wsl,
|
nixos-wsl,
|
||||||
nixos-apple-silicon,
|
nixos-apple-silicon,
|
||||||
|
nix-darwin,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } (
|
flake-parts.lib.mkFlake { inherit inputs; } (
|
||||||
@@ -51,20 +55,23 @@
|
|||||||
"lens-desktop"
|
"lens-desktop"
|
||||||
];
|
];
|
||||||
|
|
||||||
# Shared scaffolding for every host: common user, overlays, home-manager.
|
# nixpkgs + nix-daemon settings shared by NixOS and Darwin hosts.
|
||||||
|
commonModule = {
|
||||||
|
nixpkgs.overlays = overlays;
|
||||||
|
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) unfreePackages;
|
||||||
|
nix.settings.experimental-features = [
|
||||||
|
"nix-command"
|
||||||
|
"flakes"
|
||||||
|
];
|
||||||
|
# Make `nix shell nixpkgs#...` and <nixpkgs> use the pinned nixpkgs.
|
||||||
|
nix.registry.nixpkgs.flake = nixpkgs;
|
||||||
|
nix.nixPath = [ "nixpkgs=${nixpkgs}" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Shared scaffolding for every NixOS host: common user, settings, home-manager.
|
||||||
baseModules = [
|
baseModules = [
|
||||||
./lyrathorpe/user.nix
|
./lyrathorpe/user.nix
|
||||||
{
|
commonModule
|
||||||
nixpkgs.overlays = overlays;
|
|
||||||
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) unfreePackages;
|
|
||||||
nix.settings.experimental-features = [
|
|
||||||
"nix-command"
|
|
||||||
"flakes"
|
|
||||||
];
|
|
||||||
# Make `nix shell nixpkgs#...` and <nixpkgs> use the pinned nixpkgs.
|
|
||||||
nix.registry.nixpkgs.flake = nixpkgs;
|
|
||||||
nix.nixPath = [ "nixpkgs=${nixpkgs}" ];
|
|
||||||
}
|
|
||||||
home-manager.nixosModules.home-manager
|
home-manager.nixosModules.home-manager
|
||||||
{
|
{
|
||||||
home-manager.useGlobalPkgs = true;
|
home-manager.useGlobalPkgs = true;
|
||||||
@@ -99,6 +106,43 @@
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Shared scaffolding for every Darwin (macOS) host.
|
||||||
|
darwinBaseModules = [
|
||||||
|
commonModule
|
||||||
|
home-manager.darwinModules.home-manager
|
||||||
|
{
|
||||||
|
home-manager.useGlobalPkgs = true;
|
||||||
|
home-manager.useUserPackages = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
# mkDarwinHost :: { system, username, fullName, modules, homeModules } -> darwinSystem
|
||||||
|
# Darwin counterpart of mkHost. macOS already owns the login user, so we
|
||||||
|
# only attach the platform and home-manager; no NixOS user module here.
|
||||||
|
mkDarwinHost =
|
||||||
|
{
|
||||||
|
system,
|
||||||
|
username,
|
||||||
|
fullName,
|
||||||
|
modules,
|
||||||
|
homeModules,
|
||||||
|
}:
|
||||||
|
nix-darwin.lib.darwinSystem {
|
||||||
|
specialArgs = { inherit inputs username fullName; };
|
||||||
|
modules =
|
||||||
|
darwinBaseModules
|
||||||
|
++ modules
|
||||||
|
++ [
|
||||||
|
{
|
||||||
|
nixpkgs.hostPlatform = system;
|
||||||
|
# macOS owns the account; point home-manager at its home dir.
|
||||||
|
users.users.${username}.home = "/Users/${username}";
|
||||||
|
home-manager.extraSpecialArgs = { inherit inputs username fullName; };
|
||||||
|
home-manager.users.${username}.imports = homeModules;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# Host table — declarative registry of every machine. To add a host:
|
# Host table — declarative registry of every machine. To add a host:
|
||||||
# give it a name, its `system`, the owning user, and the module lists.
|
# give it a name, its `system`, the owning user, and the module lists.
|
||||||
# mapAttrs below turns each entry into a nixosConfiguration of the same name.
|
# mapAttrs below turns each entry into a nixosConfiguration of the same name.
|
||||||
@@ -147,11 +191,30 @@
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Darwin host table — macOS machines built via mkDarwinHost. The shared
|
||||||
|
# ./lyrathorpe/home modules (shell, git, editor) are reused; the Linux-only
|
||||||
|
# desktop/sway modules are intentionally left out.
|
||||||
|
darwinHosts = {
|
||||||
|
lyrathorpe-mac = {
|
||||||
|
system = "aarch64-darwin";
|
||||||
|
username = "lyrathorpe";
|
||||||
|
fullName = "Lyra Thorpe";
|
||||||
|
modules = [
|
||||||
|
./system/machine/Darwin/configuration.nix
|
||||||
|
];
|
||||||
|
homeModules = [
|
||||||
|
./lyrathorpe/home
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
systems = [
|
systems = [
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
|
"aarch64-darwin"
|
||||||
|
"x86_64-darwin"
|
||||||
];
|
];
|
||||||
|
|
||||||
# perSystem is evaluated once per entry in `systems`; `pkgs` is the
|
# perSystem is evaluated once per entry in `systems`; `pkgs` is the
|
||||||
@@ -180,8 +243,9 @@
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
# Realise the host table: each `hosts` entry becomes a nixosConfiguration.
|
# Realise the host tables: each entry becomes a {nixos,darwin}Configuration.
|
||||||
flake.nixosConfigurations = lib.mapAttrs (_name: mkHost) hosts;
|
flake.nixosConfigurations = lib.mapAttrs (_name: mkHost) hosts;
|
||||||
|
flake.darwinConfigurations = lib.mapAttrs (_name: mkDarwinHost) darwinHosts;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# Default nix-darwin host. Minimal macOS baseline; the user environment
|
||||||
|
# (shell, git, editor) is carried by the shared ./lyrathorpe/home modules,
|
||||||
|
# the same ones used by the Linux hosts. nixpkgs.hostPlatform is set by
|
||||||
|
# mkDarwinHost in flake.nix.
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
programs.zsh.enable = true;
|
||||||
|
environment.systemPackages = [ pkgs.git ];
|
||||||
|
|
||||||
|
# Used for backwards compatibility; read `darwin-rebuild changelog` before changing.
|
||||||
|
system.stateVersion = 5;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user