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:
parent
b667f7c247
commit
c434a479a5
9 changed files with 158 additions and 128 deletions
31
nixos/flake-modules/daniel-macbook-air.nix
Normal file
31
nixos/flake-modules/daniel-macbook-air.nix
Normal 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
|
||||
];
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
11
nixos/flake-modules/installer-iso.nix
Normal file
11
nixos/flake-modules/installer-iso.nix
Normal 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;
|
||||
}
|
||||
22
nixos/flake-modules/phantom-ship.nix
Normal file
22
nixos/flake-modules/phantom-ship.nix
Normal 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";
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
11
nixos/flake-modules/server-install.nix
Normal file
11
nixos/flake-modules/server-install.nix
Normal 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
|
||||
];
|
||||
};
|
||||
}
|
||||
21
nixos/flake-modules/sunken-ship.nix
Normal file
21
nixos/flake-modules/sunken-ship.nix
Normal 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";
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
24
nixos/flake-modules/wsl.nix
Normal file
24
nixos/flake-modules/wsl.nix
Normal 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
21
nixos/flake.lock
generated
|
|
@ -36,6 +36,26 @@
|
|||
"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": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
|
|
@ -281,6 +301,7 @@
|
|||
"root": {
|
||||
"inputs": {
|
||||
"disko": "disko",
|
||||
"flake-parts": "flake-parts",
|
||||
"home-manager": "home-manager",
|
||||
"nix-darwin": "nix-darwin",
|
||||
"nix-openclaw": "nix-openclaw",
|
||||
|
|
|
|||
135
nixos/flake.nix
135
nixos/flake.nix
|
|
@ -4,6 +4,9 @@
|
|||
nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
|
||||
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.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
|
|
@ -20,131 +23,17 @@
|
|||
nix-openclaw.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
nixos-wsl,
|
||||
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
|
||||
outputs = inputs @ { flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [ "x86_64-linux" "aarch64-darwin" ];
|
||||
|
||||
# Home Manager on WSL
|
||||
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 ];
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
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
|
||||
./flake-modules/wsl.nix
|
||||
./flake-modules/sunken-ship.nix
|
||||
./flake-modules/phantom-ship.nix
|
||||
./flake-modules/daniel-macbook-air.nix
|
||||
./flake-modules/server-install.nix
|
||||
./flake-modules/installer-iso.nix
|
||||
];
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs, lib, config, zen-browser ? null, ... }:
|
||||
{ pkgs, lib, config, ... }:
|
||||
{
|
||||
# TODO: remove next two lines from here or from flake.nix
|
||||
# home.username = "danny";
|
||||
|
|
@ -171,9 +171,9 @@
|
|||
# Fonts
|
||||
fonts.fontconfig.enable = true;
|
||||
home.packages = with pkgs; [
|
||||
# Zen Browser (Firefox fork; from flake, supports aarch64-darwin)
|
||||
] ++ (lib.optionals (zen-browser != null) [
|
||||
zen-browser.packages.${pkgs.stdenv.hostPlatform.system}.default
|
||||
# Zen Browser (Firefox fork; from flake overlay, supports aarch64-darwin)
|
||||
] ++ (lib.optionals (pkgs ? zen-browser) [
|
||||
pkgs.zen-browser
|
||||
]) ++ (with pkgs; [
|
||||
# Google Fonts (includes Michroma)
|
||||
google-fonts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue