From 5e550368b1846ca011a8c04cedc9a676b743b8e5 Mon Sep 17 00:00:00 2001 From: Zynh Ludwig <Zynh0722@gmail.com> Date: Wed, 26 Feb 2025 05:11:50 -0800 Subject: [PATCH] WIP: builders flake module --- flake.nix | 2 + flakeModules/builders/default.nix | 135 ++++++++++++++++++ .../builders/util.nix | 0 3 files changed, 137 insertions(+) create mode 100644 flakeModules/builders/default.nix rename builders.nix => flakeModules/builders/util.nix (100%) diff --git a/flake.nix b/flake.nix index 5c62dc4..ab1a3f0 100644 --- a/flake.nix +++ b/flake.nix @@ -30,6 +30,8 @@ outputs = inputs@{ flake-parts, deploy-rs, nixpkgs, self, ... }: flake-parts.lib.mkFlake { inherit inputs; } { + # imports = [ ./flakeModules/builders.nix ]; + # flake = let builders = import ./builders.nix inputs; in { diff --git a/flakeModules/builders/default.nix b/flakeModules/builders/default.nix new file mode 100644 index 0000000..8baad6c --- /dev/null +++ b/flakeModules/builders/default.nix @@ -0,0 +1,135 @@ +{ lib, config, ... }: + +{ + options.builders = + let + inherit (lib) mkOption; + inherit (lib.types) listOf deferredModule submodule; + in + { + nixosModules = mkOption { + type = listOf deferredModule; + default = [ ]; + description = '' + nixos modules to be used by all nixosConfigurations + ''; + }; + + darwinModules = mkOption { + type = listOf deferredModule; + default = [ ]; + description = '' + nix-darwin modules to be used by all darwinConfigurations + ''; + }; + + homeModules = mkOption { + type = listOf deferredModule; + default = [ ]; + description = '' + home-manager modules to be used by all homeConfigurations + ''; + }; + + configurations = mkOption { + type = submodule { + options = { + nixos = mkOption { + type = listOf (submodule { + options = { + hostname = mkOption { + type = lib.types.str; + example = "snowhawk"; + description = '' + nixos configuration hostname + ''; + }; + + system = mkOption { + type = lib.types.str; + default = "x86_64-linux"; + example = "aarch64-linux"; + description = '' + nixos configuration architecture + ''; + }; + }; + }); + }; + + darwin = mkOption { + type = listOf (submodule { + options = { + hostname = mkOption { + type = lib.types.str; + example = "lynx"; + description = '' + nix-darwin configuration hostname + ''; + }; + + system = mkOption { + type = lib.types.str; + default = "aarch64-darwin"; + example = "x86_64-darwin"; + description = '' + nix-darwin configuration architecture + + Note: default is aarch64-darwin not x86_64-darwin + ''; + }; + }; + }); + }; + + home = mkOption { + type = listOf (submodule { + options = { + user = mkOption { + type = lib.types.str; + example = "ravenshade"; + description = '' + home-manager configuration architecture + ''; + }; + + system = mkOption { + type = lib.types.str; + default = "x86_64-linux"; + example = "aarch64-darwin"; + description = '' + home-manager configuration architecture + ''; + }; + + hostname = lib.types.nullOr (mkOption { + type = lib.types.str; + default = ""; + example = "permafrost"; + description = '' + home-manager configuration hostname + + Note: one of `hostname` or `configHostname` must be defined + ''; + }); + + configHostname = lib.types.nullOr (mkOption { + type = lib.types.str; + default = ""; + example = "permafrost"; + description = '' + home-manager configuration hostname + + Note: one of `hostname` or `configHostname` must be defined + ''; + }); + }; + }); + }; + }; + }; + }; + }; + + config = { }; +} diff --git a/builders.nix b/flakeModules/builders/util.nix similarity index 100% rename from builders.nix rename to flakeModules/builders/util.nix