1

Initialize nix-darwin config for darwinix

This commit is contained in:
2026-03-21 12:47:53 +01:00
parent 3573a705af
commit 602aa4cd56
7 changed files with 440 additions and 6 deletions

30
flake.lock generated
View File

@ -522,6 +522,27 @@
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1773000227,
"narHash": "sha256-zm3ftUQw0MPumYi91HovoGhgyZBlM4o3Zy0LhPNwzXE=",
"owner": "nix-darwin",
"repo": "nix-darwin",
"rev": "da529ac9e46f25ed5616fd634079a5f3c579135f",
"type": "github"
},
"original": {
"owner": "nix-darwin",
"ref": "master",
"repo": "nix-darwin",
"type": "github"
}
},
"nix-flatpak": {
"locked": {
"lastModified": 1767983141,
@ -593,16 +614,16 @@
},
"nixpkgs-stable_2": {
"locked": {
"lastModified": 1767313136,
"narHash": "sha256-16KkgfdYqjaeRGBaYsNrhPRRENs0qzkQVUooNHtoy2w=",
"lastModified": 1773814637,
"narHash": "sha256-GNU+ooRmrHLfjlMsKdn0prEKVa0faVanm0jrgu1J/gY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "ac62194c3917d5f474c1a844b6fd6da2db95077d",
"rev": "fea3b367d61c1a6592bc47c72f40a9f3e6a53e96",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-25.05",
"ref": "nixos-25.11",
"repo": "nixpkgs",
"type": "github"
}
@ -824,6 +845,7 @@
"masssprings": "masssprings",
"niri": "niri",
"nix-alien": "nix-alien",
"nix-darwin": "nix-darwin",
"nix-flatpak": "nix-flatpak",
"nixpkgs": "nixpkgs_6",
"nixpkgs-stable": "nixpkgs-stable_2",

View File

@ -12,8 +12,12 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
hardware.url = "github:nixos/nixos-hardware";
# Darwin
nix-darwin.url = "github:nix-darwin/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
# NOTE: Update this after May and November
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-25.05";
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-25.11";
# Home Manager
home-manager.url = "github:nix-community/home-manager";
@ -91,12 +95,14 @@
outputs = {
self,
nixpkgs,
nix-darwin,
...
} @ inputs: let
# Our configuration is buildable on the following system/platform.
# Configs can support more than a single system simultaneously,
# e.g. NixOS (linux) and MacOS (darwin) or Arm.
system = "x86_64-linux";
darwinSystem = "aarch64-darwin";
# We configure our global packages here.
# Usually, "nixpkgs.legacyPackages.${system}" is used (and more efficient),
@ -139,6 +145,16 @@
];
};
darwinPkgs = import nixpkgs {
system = darwinSystem;
hostPlatform = darwinSystem;
config.allowUnfree = true;
config.allowUnfreePredicate = pkg: true;
overlays = [];
};
# My own library functions are imported here.
# They are made available to the system and HM configs by inheriting mylib.
mylib = import ./lib {
@ -153,6 +169,14 @@
inherit (nixpkgs) lib;
};
darwinMylib = import ./lib {
inherit inputs darwinPkgs;
inherit (nixpkgs) lib;
pkgs = darwinPkgs;
};
# NOTE: Keep public keys here so they're easy to rotate
publicKeys.christoph = {
# /home/christoph/.ssh/id_ed25519.pub
@ -177,6 +201,19 @@
# Local shell for NixFlake directory
devShells.${system}.default = import ./shell.nix {inherit pkgs;};
# Usage: sudo darwin-rebuild switch --flake .#darwinix
darwinConfigurations = {
darwinix = darwinMylib.nixos.mkDarwinConfigWithHomeManagerModule {
inherit publicKeys;
system = darwinSystem;
mylib = darwinMylib;
hostname = "darwinix";
username = "christoph";
extraModules = [];
};
};
# We give each configuration a (host)name to choose a configuration when rebuilding.
# This makes it easy to add different configurations (e.g. for a laptop).
# Usage: sudo nixos-rebuild switch --flake .#nixinator

View File

@ -0,0 +1,225 @@
{
pkgs,
nixosConfig,
config,
lib,
mylib,
username,
inputs,
...
}: {
config = {
paths = rec {
nixflake = "${config.home.homeDirectory}/NixFlake";
dotfiles = "${nixflake}/config";
};
homemodules = {
color = {
scheme = "catppuccin-mocha";
accent = "mauve";
accentHl = "pink";
accentDim = "lavender";
accentText = "base";
font = "MonoLisa Alt Script";
};
fish.enable = true;
git = {
enable = true;
userName = "Christoph Urlacher";
userEmail = "christoph.urlacher@protonmail.com";
signCommits = true;
};
kitty.enable = true;
lazygit.enable = true;
neovim = {
enable = true;
alias = true;
neovide = true;
};
yazi.enable = true;
};
home = {
inherit username;
homeDirectory = "/Users/${config.home.username}";
enableNixpkgsReleaseCheck = true;
packages = with pkgs; [
(ripgrep.override {withPCRE2 = true;})
gdu
duf
sd
cachix
];
stateVersion = "25.11";
};
programs = {
home-manager.enable = true;
# TODO: Module
fastfetch = {
enable = true;
settings = {
logo = {
padding = {
top = 4;
left = 1;
right = 2;
};
};
display = {
separator = "";
key.width = 17;
};
# Box Drawing: ╭ ─ ╮ ╰ ╯ │
modules = [
# Title
{
type = "title";
format = "{#1} {#}{user-name-colored}";
}
# System Information
{
type = "custom";
format = "{#1} {#}System Information";
}
{
type = "os";
key = "{#separator} {#keys}󰍹 OS";
}
{
type = "kernel";
key = "{#separator} {#keys}󰒋 Kernel";
}
{
type = "bootmgr";
key = "{#separator} {#keys}󰒋 BootMGR";
}
{
type = "uptime";
key = "{#separator} {#keys}󰅐 Uptime";
}
{
type = "packages";
key = "{#separator} {#keys}󰏖 Packages";
# format = "{all}";
}
{
type = "custom";
format = "{#1}";
}
# Desktop Environment
{
type = "custom";
format = "{#1} {#}Desktop Environment";
}
{
type = "de";
key = "{#separator} {#keys}󰧨 DE";
}
{
type = "wm";
key = "{#separator} {#keys}󱂬 WM";
}
{
type = "wmtheme";
key = "{#separator} {#keys}󰉼 Theme";
}
{
type = "display";
key = "{#separator} {#keys}󰹑 Resolution";
}
{
type = "shell";
key = "{#separator} {#keys}󰞷 Shell";
}
{
type = "terminalfont";
key = "{#separator} {#keys}󰛖 Font";
}
{
type = "icons";
key = "{#separator} {#keys} Icons";
}
{
type = "cursor";
key = "{#separator} {#keys}󰆽 Cursor";
}
{
type = "custom";
format = "{#1}";
}
# Hardware Information
{
type = "custom";
format = "{#1} {#}Hardware Information";
}
{
type = "board";
key = "{#separator} {#keys} Board";
}
{
type = "cpu";
key = "{#separator} {#keys}󰻠 CPU";
}
{
type = "gpu";
key = "{#separator} {#keys}󰢮 GPU";
}
{
type = "memory";
key = "{#separator} {#keys}󰍛 Memory";
}
# {
# type = "disk";
# key = "{#separator}│ {#keys}󰋊 Disk (/)";
# folders = "/";
# }
# {
# type = "disk";
# key = "{#separator}│ {#keys}󰋊 Disk (~/Games)";
# folders = "/home/christoph/Games";
# }
{
type = "btrfs";
key = "{#separator} {#keys}󰋊 BTRFS";
}
{
type = "custom";
format = "{#1}";
}
# Colors Footer
{
type = "colors";
key = "{#separator} {#1}";
keyWidth = 6;
symbol = "circle";
}
];
};
};
};
services = {
};
};
}

View File

@ -0,0 +1,17 @@
{inputs, ...}: {
imports = [
# My own HM modules
./color
./fish
./git
./kitty
./lazygit
./neovim
./paths
./yazi
# HM modules imported from the flake inputs
inputs.nixvim.homeModules.nixvim
inputs.textfox.homeManagerModules.default
];
}

View File

@ -80,6 +80,74 @@
];
};
mkDarwinConfigWithHomeManagerModule = {
system,
mylib,
hostname,
username,
publicKeys,
extraModules ? [],
}:
inputs.nix-darwin.lib.darwinSystem {
inherit system;
# Values in "specialArgs" are propagated to all system modules.
specialArgs = {
inherit inputs system hostname mylib username publicKeys;
};
modules = builtins.concatLists [
[
# Replace the default "pkgs" with my configured version
# to allow installation of unfree software and my own overlays.
{nixpkgs.pkgs = pkgs;}
# Import the toplevel system configuration module.
../system/cachix.nix
# Host specific configuration
../system/${hostname}
# Import all of my custom system modules
# ../system/systemmodules # TODO:
]
extraModules
# HM is installed as a system module when using mkNixosConfigWithHomeManagerModule.
[
inputs.home-manager.darwinModules.home-manager
{
home-manager = {
# Values in "extraSpecialArgs" are propagated to all HM modules.
extraSpecialArgs = {
inherit inputs system hostname mylib username publicKeys;
};
# Use the "pkgs" from the system configuration.
# This disables "nixpkgs.*" options in HM modules.
useGlobalPkgs = true;
# Packages in "users.${username}.packages" will be installed
# to /etc/profiles instead of ~/.nix-profile.
useUserPackages = true;
users.${username}.imports = [
# Host specific configuration
../home/${username}/${hostname}
];
sharedModules = [
# Import all of my custom HM modules.
# Putting them into sharedModules enables correct nixd completions.
../home/homemodules/darwin.nix
];
};
}
]
];
};
mkNixosSystemConfig = {
system,
mylib,

View File

@ -0,0 +1,65 @@
{
self,
lib,
mylib,
pkgs,
username,
config,
inputs,
publicKeys,
...
}: {
nix = {
package = pkgs.nixVersions.stable;
extraOptions = ''
experimental-features = nix-command flakes pipe-operators
'';
settings.trusted-users = ["root" "${username}"];
gc.automatic = false;
gc.options = "--delete-older-than 5d";
settings.auto-optimise-store = true;
optimise.automatic = true;
registry = lib.mapAttrs' (n: v: lib.nameValuePair n {flake = v;}) inputs;
nixPath = [
"nixpkgs=${inputs.nixpkgs.outPath}"
"home-manager=${inputs.home-manager.outPath}"
];
};
users.users.${username} = {
isHidden = false;
description = "Christoph";
home = "/Users/${username}";
createHome = false;
# NOTE: Not set if the user already exists on darwin, so use chsh for the root user
shell = pkgs.fish;
openssh.authorizedKeys.keys = [
publicKeys.${username}.ssh
];
# packages = with pkgs; [];
};
environment.systemPackages = with pkgs; [
alejandra
neovim
wget
];
programs = {
fish.enable = true;
};
# Set Git commit hash for darwin-version.
# system.configurationRevision = self.rev or self.dirtyRev or null;
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 6;
}

View File

@ -276,7 +276,7 @@ with mylib.networking; {
shell = pkgs.fish;
openssh.authorizedKeys.keys = [
publicKeys.christoph.ssh
publicKeys.${username}.ssh
];
# We do this with HomeManager