refactor(nix): migrate to flake-parts, drop specialArgs ♻️

- Convert flake.nix to flake-parts.lib.mkFlake; split each host into
  its own module under nixos/flake-modules/.
- Replace zen-browser specialArgs plumbing with a nixpkgs overlay so
  home.nix can just reference pkgs.zen-browser.
This commit is contained in:
DannyDannyDanny 2026-04-18 17:00:19 +02:00
parent b667f7c247
commit c434a479a5
9 changed files with 158 additions and 128 deletions

View file

@ -0,0 +1,31 @@
{ inputs, ... }: {
flake.darwinConfigurations."Daniel-Macbook-Air" = inputs.nix-darwin.lib.darwinSystem {
modules = [
# Overlay: make zen-browser available as pkgs.zen-browser
{ nixpkgs.overlays = [ (final: prev: {
zen-browser = inputs.zen-browser.packages.${final.stdenv.hostPlatform.system}.default;
}) ];
}
../hosts/daniel-macbook-air.nix
../fish.nix
# Home Manager on macOS
inputs.home-manager.darwinModules.home-manager
({ lib, ... }: {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
# Automatically backup files before home-manager overwrites them
home-manager.backupFileExtension = "backup";
home-manager.users.danny = { ... }: {
# Force an absolute path even if another module sets a bad value.
home.username = "danny";
home.homeDirectory = lib.mkForce "/Users/danny";
imports = [
../home/danny/home.nix
];
};
})
];
};
}

View file

@ -0,0 +1,11 @@
{ inputs, self, ... }: {
# Custom minimal installer ISO (build with: nix build .#installer-iso).
# Optional: add ./installer-wifi.nix (gitignored) to modules for live WiFi.
flake.nixosConfigurations.installer-iso = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [ ../installer-iso.nix ];
};
flake.packages.x86_64-linux.installer-iso =
self.nixosConfigurations.installer-iso.config.system.build.isoImage;
}

View file

@ -0,0 +1,22 @@
{ inputs, ... }: {
flake.nixosConfigurations.phantom-ship = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
inputs.nix-openclaw.nixosModules.openclaw-gateway
../hosts/phantom-ship.nix
# Home Manager on NixOS
inputs.home-manager.nixosModules.home-manager
({ lib, ... }: {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "backup";
home-manager.users.danny = { ... }: {
home.username = "danny";
home.homeDirectory = lib.mkForce "/home/danny";
home.stateVersion = "25.11";
};
})
];
};
}

View file

@ -0,0 +1,11 @@
{ inputs, ... }: {
# For disko-install: LUKS + WiFi; hostname/WiFi via --system-config.
flake.nixosConfigurations.server-install = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
inputs.disko.nixosModules.disko
../disko-server.nix
../hosts/server-install.nix
];
};
}

View file

@ -0,0 +1,21 @@
{ inputs, ... }: {
flake.nixosConfigurations.sunken-ship = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
../hosts/sunken-ship.nix
# Home Manager on NixOS
inputs.home-manager.nixosModules.home-manager
({ lib, ... }: {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "backup";
home-manager.users.danny = { ... }: {
home.username = "danny";
home.homeDirectory = lib.mkForce "/home/danny";
home.stateVersion = "25.11";
};
})
];
};
}

View file

@ -0,0 +1,24 @@
{ inputs, ... }: {
flake.nixosConfigurations.wsl = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
inputs.nixos-wsl.nixosModules.default
inputs.vscode-server.nixosModules.default
../hosts/wsl.nix
../fish.nix
# Home Manager on WSL
inputs.home-manager.nixosModules.home-manager
({ lib, ... }: {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "backup";
home-manager.users.dth = { ... }: {
home.username = "dth";
home.homeDirectory = lib.mkForce "/home/dth";
imports = [ ../home/danny/home.nix ];
};
})
];
};
}

21
nixos/flake.lock generated
View file

@ -36,6 +36,26 @@
"type": "github" "type": "github"
} }
}, },
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1775087534,
"narHash": "sha256-91qqW8lhL7TLwgQWijoGBbiD4t7/q75KTi8NxjVmSmA=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "3107b77cd68437b9a76194f0f7f9c55f2329ca5b",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"inputs": { "inputs": {
"systems": "systems" "systems": "systems"
@ -281,6 +301,7 @@
"root": { "root": {
"inputs": { "inputs": {
"disko": "disko", "disko": "disko",
"flake-parts": "flake-parts",
"home-manager": "home-manager", "home-manager": "home-manager",
"nix-darwin": "nix-darwin", "nix-darwin": "nix-darwin",
"nix-openclaw": "nix-openclaw", "nix-openclaw": "nix-openclaw",

View file

@ -4,6 +4,9 @@
nixos-wsl.url = "github:nix-community/NixOS-WSL/main"; nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
vscode-server.url = "github:nix-community/nixos-vscode-server"; vscode-server.url = "github:nix-community/nixos-vscode-server";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
nix-darwin.url = "github:nix-darwin/nix-darwin/master"; nix-darwin.url = "github:nix-darwin/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
@ -20,131 +23,17 @@
nix-openclaw.inputs.nixpkgs.follows = "nixpkgs"; nix-openclaw.inputs.nixpkgs.follows = "nixpkgs";
}; };
outputs = { outputs = inputs @ { flake-parts, ... }:
nixpkgs, flake-parts.lib.mkFlake { inherit inputs; } {
nixos-wsl, systems = [ "x86_64-linux" "aarch64-darwin" ];
vscode-server,
nix-darwin,
self,
home-manager,
zen-browser,
disko,
nix-openclaw,
...
}: {
nixosConfigurations = {
wsl = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
nixos-wsl.nixosModules.default
vscode-server.nixosModules.default
./hosts/wsl.nix
./fish.nix
# Home Manager on WSL imports = [
home-manager.nixosModules.home-manager ./flake-modules/wsl.nix
({ lib, ... }: { ./flake-modules/sunken-ship.nix
home-manager.useGlobalPkgs = true; ./flake-modules/phantom-ship.nix
home-manager.useUserPackages = true; ./flake-modules/daniel-macbook-air.nix
home-manager.backupFileExtension = "backup"; ./flake-modules/server-install.nix
home-manager.users.dth = { ... }: { ./flake-modules/installer-iso.nix
home.username = "dth";
home.homeDirectory = lib.mkForce "/home/dth";
imports = [ ./home/danny/home.nix ];
};
})
];
};
sunken-ship = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./hosts/sunken-ship.nix
# Home Manager on NixOS
home-manager.nixosModules.home-manager
({ lib, ... }: {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "backup";
home-manager.users.danny = { ... }: {
home.username = "danny";
home.homeDirectory = lib.mkForce "/home/danny";
home.stateVersion = "25.11";
};
})
];
};
phantom-ship = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
nix-openclaw.nixosModules.openclaw-gateway
./hosts/phantom-ship.nix
# Home Manager on NixOS
home-manager.nixosModules.home-manager
({ lib, ... }: {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "backup";
home-manager.users.danny = { ... }: {
home.username = "danny";
home.homeDirectory = lib.mkForce "/home/danny";
home.stateVersion = "25.11";
};
})
];
};
# For disko-install: LUKS + WiFi; hostname/WiFi via --system-config.
server-install = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
disko.nixosModules.disko
./disko-server.nix
./hosts/server-install.nix
];
};
# Custom minimal installer ISO (build with: nix build .#installer-iso).
# Optional: add ./installer-wifi.nix (gitignored) to modules for live WiFi.
installer-iso = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [ ./installer-iso.nix ];
};
};
packages.x86_64-linux.installer-iso =
self.nixosConfigurations.installer-iso.config.system.build.isoImage;
# macOS (nix-darwin) configuration
darwinConfigurations."Daniel-Macbook-Air" = nix-darwin.lib.darwinSystem {
specialArgs = { inherit zen-browser; };
modules = [
./hosts/daniel-macbook-air.nix
./fish.nix
# Home Manager on macOS
home-manager.darwinModules.home-manager
({ lib, zen-browser, ... }: {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
# Automatically backup files before home-manager overwrites them
home-manager.backupFileExtension = "backup";
# Pass flake inputs to home-manager modules (e.g. home.nix)
home-manager.extraSpecialArgs = { inherit zen-browser; };
home-manager.users.danny = { ... }: {
# Force an absolute path even if another module sets a bad value.
home.username = "danny";
home.homeDirectory = lib.mkForce "/Users/danny";
imports = [
./home/danny/home.nix
];
};
})
]; ];
}; };
};
} }

View file

@ -1,4 +1,4 @@
{ pkgs, lib, config, zen-browser ? null, ... }: { pkgs, lib, config, ... }:
{ {
# TODO: remove next two lines from here or from flake.nix # TODO: remove next two lines from here or from flake.nix
# home.username = "danny"; # home.username = "danny";
@ -171,9 +171,9 @@
# Fonts # Fonts
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
home.packages = with pkgs; [ home.packages = with pkgs; [
# Zen Browser (Firefox fork; from flake, supports aarch64-darwin) # Zen Browser (Firefox fork; from flake overlay, supports aarch64-darwin)
] ++ (lib.optionals (zen-browser != null) [ ] ++ (lib.optionals (pkgs ? zen-browser) [
zen-browser.packages.${pkgs.stdenv.hostPlatform.system}.default pkgs.zen-browser
]) ++ (with pkgs; [ ]) ++ (with pkgs; [
# Google Fonts (includes Michroma) # Google Fonts (includes Michroma)
google-fonts google-fonts