diff --git a/nixos/flake-modules/daniel-macbook-air.nix b/nixos/flake-modules/daniel-macbook-air.nix new file mode 100644 index 0000000..68ede41 --- /dev/null +++ b/nixos/flake-modules/daniel-macbook-air.nix @@ -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 + ]; + }; + }) + ]; + }; +} diff --git a/nixos/flake-modules/installer-iso.nix b/nixos/flake-modules/installer-iso.nix new file mode 100644 index 0000000..f2f7163 --- /dev/null +++ b/nixos/flake-modules/installer-iso.nix @@ -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; +} diff --git a/nixos/flake-modules/phantom-ship.nix b/nixos/flake-modules/phantom-ship.nix new file mode 100644 index 0000000..24d1d2d --- /dev/null +++ b/nixos/flake-modules/phantom-ship.nix @@ -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"; + }; + }) + ]; + }; +} diff --git a/nixos/flake-modules/server-install.nix b/nixos/flake-modules/server-install.nix new file mode 100644 index 0000000..1366ae9 --- /dev/null +++ b/nixos/flake-modules/server-install.nix @@ -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 + ]; + }; +} diff --git a/nixos/flake-modules/sunken-ship.nix b/nixos/flake-modules/sunken-ship.nix new file mode 100644 index 0000000..3a78476 --- /dev/null +++ b/nixos/flake-modules/sunken-ship.nix @@ -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"; + }; + }) + ]; + }; +} diff --git a/nixos/flake-modules/wsl.nix b/nixos/flake-modules/wsl.nix new file mode 100644 index 0000000..711a66e --- /dev/null +++ b/nixos/flake-modules/wsl.nix @@ -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 ]; + }; + }) + ]; + }; +} diff --git a/nixos/flake.lock b/nixos/flake.lock index acb3cba..fbc9b8f 100644 --- a/nixos/flake.lock +++ b/nixos/flake.lock @@ -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", diff --git a/nixos/flake.nix b/nixos/flake.nix index 0f757d3..c9ab314 100644 --- a/nixos/flake.nix +++ b/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 - ]; - }; - }) + imports = [ + ./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 ]; }; - }; } diff --git a/nixos/home/danny/home.nix b/nixos/home/danny/home.nix index 35b6a09..d3f346d 100644 --- a/nixos/home/danny/home.nix +++ b/nixos/home/danny/home.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