diff --git a/flake.nix b/flake.nix index dfb62c2..be0f9da 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,8 @@ description = "NixOS configuration"; inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-25.05"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; @@ -40,83 +42,10 @@ }; }; - outputs = - inputs@{ - nixpkgs-stable, - nixpkgs-unstable, - disko-stable, - disko-unstable, - home-manager-unstable, - dotfiles, - ... - }: - let - mkHost = { - hostPath, - nixpkgs, - disko, - lolcat, - }: - nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { - inputs = inputs // { "lolcat++" = lolcat; }; - }; - modules = [ - disko.nixosModules.disko - hostPath - ]; - }; - mkDesktopHost = { - hostPath, - nixpkgs, - disko, - lolcat, - }: - nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { - inputs = inputs // { "lolcat++" = lolcat; }; - }; - modules = [ - disko.nixosModules.disko - home-manager-unstable.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.backupFileExtension = "hm-backup"; - home-manager.users.love = import "${dotfiles}/home.nix"; - } - hostPath - ]; - }; - in - { - nixosConfigurations = { - Kronos = mkDesktopHost { - hostPath = ./hosts/kronos; - nixpkgs = nixpkgs-unstable; - disko = disko-unstable; - lolcat = inputs."lolcat++-unstable"; - }; - kronos = mkDesktopHost { - hostPath = ./hosts/kronos; - nixpkgs = nixpkgs-unstable; - disko = disko-unstable; - lolcat = inputs."lolcat++-unstable"; - }; - Hermes = mkHost { - hostPath = ./hosts/hermes; - nixpkgs = nixpkgs-stable; - disko = disko-stable; - lolcat = inputs."lolcat++-stable"; - }; - hermes = mkHost { - hostPath = ./hosts/hermes; - nixpkgs = nixpkgs-stable; - disko = disko-stable; - lolcat = inputs."lolcat++-stable"; - }; - }; + outputs = inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + ./modules/flake/parts.nix + ]; }; } diff --git a/modules/flake/lib.nix b/modules/flake/lib.nix new file mode 100644 index 0000000..7f93d4f --- /dev/null +++ b/modules/flake/lib.nix @@ -0,0 +1,45 @@ +{ + inputs, + ... +}: +let + inherit (inputs) dotfiles home-manager-unstable; +in +{ + mkHost = { + nixpkgs, + disko, + lolcat, + modules ? [ ], + }: + nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { + inputs = inputs // { "lolcat++" = lolcat; }; + }; + modules = [ disko.nixosModules.disko ] ++ modules; + }; + + mkDesktopHost = { + nixpkgs, + disko, + lolcat, + modules ? [ ], + }: + nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { + inputs = inputs // { "lolcat++" = lolcat; }; + }; + modules = [ + disko.nixosModules.disko + home-manager-unstable.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.backupFileExtension = "hm-backup"; + home-manager.users.love = import "${dotfiles}/home.nix"; + } + ] ++ modules; + }; +} diff --git a/modules/flake/nixos-configurations.nix b/modules/flake/nixos-configurations.nix new file mode 100644 index 0000000..ff74410 --- /dev/null +++ b/modules/flake/nixos-configurations.nix @@ -0,0 +1,6 @@ +{ inputs }: +let + modules = import ../nixos; + flakeLib = import ./lib.nix { inherit inputs; }; +in +import ../hosts ({ inherit inputs modules; } // flakeLib) diff --git a/modules/flake/parts.nix b/modules/flake/parts.nix new file mode 100644 index 0000000..f90bcec --- /dev/null +++ b/modules/flake/parts.nix @@ -0,0 +1,9 @@ +{ inputs, ... }: +{ + systems = [ "x86_64-linux" ]; + + flake = { + nixosModules = import ../nixos; + nixosConfigurations = import ./nixos-configurations.nix { inherit inputs; }; + }; +} diff --git a/modules/hosts/default.nix b/modules/hosts/default.nix new file mode 100644 index 0000000..e8f0415 --- /dev/null +++ b/modules/hosts/default.nix @@ -0,0 +1,2 @@ +args: +(import ./hermes args) // (import ./kronos args) diff --git a/hosts/hermes/default.nix b/modules/hosts/hermes/configuration.nix similarity index 80% rename from hosts/hermes/default.nix rename to modules/hosts/hermes/configuration.nix index dcc45f8..8d6efcc 100644 --- a/hosts/hermes/default.nix +++ b/modules/hosts/hermes/configuration.nix @@ -2,6 +2,7 @@ inputs, config, pkgs, + modules, ... }: let @@ -24,14 +25,12 @@ in imports = [ inputs.mailserver.nixosModules.default - ./hardware-configuration.nix ./disko.nix - ./mail.nix - ./roundcube.nix - ../../modules/base.nix - ../../modules/zfs-root.nix - ../../modules/desktop-hyprland.nix - ../../modules/bin-bash-wrapper.nix + modules.base + modules.zfsRoot + modules.desktopHyprland + modules.mailServer + modules.binBashWrapper ]; my.binBashWrapper.enable = true; diff --git a/modules/hosts/hermes/default.nix b/modules/hosts/hermes/default.nix new file mode 100644 index 0000000..f041709 --- /dev/null +++ b/modules/hosts/hermes/default.nix @@ -0,0 +1,20 @@ +{ + inputs, + mkHost, + ... +}: +{ + Hermes = mkHost { + nixpkgs = inputs.nixpkgs-stable; + disko = inputs.disko-stable; + lolcat = inputs."lolcat++-stable"; + modules = [ ./configuration.nix ]; + }; + + hermes = mkHost { + nixpkgs = inputs.nixpkgs-stable; + disko = inputs.disko-stable; + lolcat = inputs."lolcat++-stable"; + modules = [ ./configuration.nix ]; + }; +} diff --git a/hosts/hermes/disko.nix b/modules/hosts/hermes/disko.nix similarity index 100% rename from hosts/hermes/disko.nix rename to modules/hosts/hermes/disko.nix diff --git a/hosts/kronos/default.nix b/modules/hosts/kronos/configuration.nix similarity index 88% rename from hosts/kronos/default.nix rename to modules/hosts/kronos/configuration.nix index 0f9e0c9..4c2793c 100644 --- a/hosts/kronos/default.nix +++ b/modules/hosts/kronos/configuration.nix @@ -1,6 +1,7 @@ { config, pkgs, + modules, ... }: let @@ -22,12 +23,12 @@ in }; imports = [ - ./hardware-configuration.nix + ./hardware.nix ./disko.nix - ../../modules/base.nix - ../../modules/zfs-root.nix - ../../modules/desktop-hyprland.nix - ../../modules/bin-bash-wrapper.nix + modules.base + modules.zfsRoot + modules.desktopHyprland + modules.binBashWrapper ]; my.binBashWrapper.enable = true; diff --git a/modules/hosts/kronos/default.nix b/modules/hosts/kronos/default.nix new file mode 100644 index 0000000..adfc9a4 --- /dev/null +++ b/modules/hosts/kronos/default.nix @@ -0,0 +1,20 @@ +{ + inputs, + mkDesktopHost, + ... +}: +{ + Kronos = mkDesktopHost { + nixpkgs = inputs.nixpkgs-unstable; + disko = inputs.disko-unstable; + lolcat = inputs."lolcat++-unstable"; + modules = [ ./configuration.nix ]; + }; + + kronos = mkDesktopHost { + nixpkgs = inputs.nixpkgs-unstable; + disko = inputs.disko-unstable; + lolcat = inputs."lolcat++-unstable"; + modules = [ ./configuration.nix ]; + }; +} diff --git a/hosts/kronos/disko.nix b/modules/hosts/kronos/disko.nix similarity index 100% rename from hosts/kronos/disko.nix rename to modules/hosts/kronos/disko.nix diff --git a/hosts/kronos/hardware-configuration.nix b/modules/hosts/kronos/hardware.nix similarity index 100% rename from hosts/kronos/hardware-configuration.nix rename to modules/hosts/kronos/hardware.nix diff --git a/modules/base.nix b/modules/nixos/base.nix similarity index 100% rename from modules/base.nix rename to modules/nixos/base.nix diff --git a/modules/bin-bash-wrapper.nix b/modules/nixos/bin-bash-wrapper.nix similarity index 100% rename from modules/bin-bash-wrapper.nix rename to modules/nixos/bin-bash-wrapper.nix diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix new file mode 100644 index 0000000..efef5e5 --- /dev/null +++ b/modules/nixos/default.nix @@ -0,0 +1,7 @@ +{ + base = import ./base.nix; + binBashWrapper = import ./bin-bash-wrapper.nix; + desktopHyprland = import ./desktop-hyprland.nix; + mailServer = import ./mail-server; + zfsRoot = import ./zfs-root.nix; +} diff --git a/modules/desktop-hyprland.nix b/modules/nixos/desktop-hyprland.nix similarity index 100% rename from modules/desktop-hyprland.nix rename to modules/nixos/desktop-hyprland.nix diff --git a/modules/nixos/mail-server/default.nix b/modules/nixos/mail-server/default.nix new file mode 100644 index 0000000..d433a16 --- /dev/null +++ b/modules/nixos/mail-server/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./mail.nix + ./roundcube.nix + ]; +} diff --git a/hosts/hermes/mail.nix b/modules/nixos/mail-server/mail.nix similarity index 88% rename from hosts/hermes/mail.nix rename to modules/nixos/mail-server/mail.nix index b2b24ad..3456467 100644 --- a/hosts/hermes/mail.nix +++ b/modules/nixos/mail-server/mail.nix @@ -16,7 +16,7 @@ # nix-shell -p mkpasswd --run 'mkpasswd -s' accounts = { "love@billenius.com" = { - hashedPasswordFile = ./mail-password-hash/love@billenius.com; + hashedPasswordFile = ../../../resources/mail-server/love@billenius.com; aliases = [ "postmaster@billenius.com" ]; }; }; diff --git a/hosts/hermes/roundcube.nix b/modules/nixos/mail-server/roundcube.nix similarity index 100% rename from hosts/hermes/roundcube.nix rename to modules/nixos/mail-server/roundcube.nix diff --git a/modules/zfs-root.nix b/modules/nixos/zfs-root.nix similarity index 100% rename from modules/zfs-root.nix rename to modules/nixos/zfs-root.nix diff --git a/hosts/hermes/mail-password-hash/love@billenius.com b/resources/mail-server/love@billenius.com similarity index 100% rename from hosts/hermes/mail-password-hash/love@billenius.com rename to resources/mail-server/love@billenius.com