From 696be4cadacc22feca2e09df742129094fa6f9e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikodem=20Rabuli=C5=84ski?= Date: Tue, 1 Apr 2025 17:48:58 +0200 Subject: [PATCH] modules/nilla: configurations -> systems --- hosts/default.nix | 2 +- hosts/hijiri-vm/default.nix | 2 +- hosts/hijiri/default.nix | 2 +- hosts/kazuki/default.nix | 2 +- hosts/kogata/default.nix | 2 +- hosts/ude/default.nix | 2 +- hosts/youko/default.nix | 2 +- modules/nilla/configurations.nix | 47 ----------------------------- modules/nilla/default.nix | 2 +- modules/nilla/flake.nix | 7 +++-- modules/nilla/systems.nix | 52 ++++++++++++++++++++++++++++++++ 11 files changed, 64 insertions(+), 58 deletions(-) delete mode 100644 modules/nilla/configurations.nix create mode 100644 modules/nilla/systems.nix diff --git a/hosts/default.nix b/hosts/default.nix index 3c8b713..843a8d1 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -16,7 +16,7 @@ in ./youko ]; - config.configBuilders = + config.systems.builders = let sharedOptions = { _file = ./default.nix; diff --git a/hosts/hijiri-vm/default.nix b/hosts/hijiri-vm/default.nix index 5f6d088..94350be 100644 --- a/hosts/hijiri-vm/default.nix +++ b/hosts/hijiri-vm/default.nix @@ -1,5 +1,5 @@ { - config.configurations.nixos.hijiri-vm = + config.systems.nixos.hijiri-vm.module = { modulesPath, lib, diff --git a/hosts/hijiri/default.nix b/hosts/hijiri/default.nix index a0e6857..66defb4 100644 --- a/hosts/hijiri/default.nix +++ b/hosts/hijiri/default.nix @@ -1,5 +1,5 @@ { - config.configurations.darwin.hijiri = + config.systems.darwin.hijiri.module = { config, pkgs, diff --git a/hosts/kazuki/default.nix b/hosts/kazuki/default.nix index 64fc67f..e4a51ad 100644 --- a/hosts/kazuki/default.nix +++ b/hosts/kazuki/default.nix @@ -1,5 +1,5 @@ { - config.configurations.nixos.kazuki = + config.systems.nixos.kazuki.module = { modulesPath, ... diff --git a/hosts/kogata/default.nix b/hosts/kogata/default.nix index 3e7c21f..d5ac7cb 100644 --- a/hosts/kogata/default.nix +++ b/hosts/kogata/default.nix @@ -1,5 +1,5 @@ { - config.configurations.darwin.kogata = + config.systems.darwin.kogata.module = { pkgs, ... }: { nixpkgs.system = "aarch64-darwin"; diff --git a/hosts/ude/default.nix b/hosts/ude/default.nix index fd3e19b..62ffb2e 100644 --- a/hosts/ude/default.nix +++ b/hosts/ude/default.nix @@ -1,5 +1,5 @@ { - config.configurations.nixos.ude = + config.systems.nixos.ude.module = { config, modulesPath, diff --git a/hosts/youko/default.nix b/hosts/youko/default.nix index b801507..7f39ac5 100644 --- a/hosts/youko/default.nix +++ b/hosts/youko/default.nix @@ -1,5 +1,5 @@ { - config.configurations.nixos.youko = + config.systems.nixos.youko.module = { config, lib, diff --git a/modules/nilla/configurations.nix b/modules/nilla/configurations.nix deleted file mode 100644 index 6f02f7e..0000000 --- a/modules/nilla/configurations.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ config, lib }: -{ - options = { - configBuilders = { - nixos = lib.options.create { - type = lib.types.function lib.types.raw; - default.value = _name: config.inputs.nixpkgs.result.lib.nixosSystem; - }; - darwin = lib.options.create { - type = lib.types.function lib.types.raw; - default.value = _name: config.inputs.darwin.result.lib.darwinSystem; - }; - home = lib.options.create { - type = lib.types.function lib.types.raw; - default.value = _name: config.inputs.home-manager.result.lib.homeManagerConfiguration; - }; - }; - - configurations = { - nixos = lib.options.create { - type = lib.types.attrs.lazy lib.types.raw; - default.value = { }; - }; - darwin = lib.options.create { - type = lib.types.attrs.lazy lib.types.raw; - default.value = { }; - }; - home = lib.options.create { - type = lib.types.attrs.lazy lib.types.raw; - default.value = { }; - }; - }; - - nixosConfigurations = lib.options.create { - type = lib.types.attrs.lazy lib.types.raw; - default.value = builtins.mapAttrs config.configBuilders.nixos config.configurations.nixos; - }; - darwinConfigurations = lib.options.create { - type = lib.types.attrs.lazy lib.types.raw; - default.value = builtins.mapAttrs config.configBuilders.darwin config.configurations.darwin; - }; - homeConfigurations = lib.options.create { - type = lib.types.attrs.lazy lib.types.raw; - default.value = builtins.mapAttrs config.configBuilders.home config.configurations.home; - }; - }; -} diff --git a/modules/nilla/default.nix b/modules/nilla/default.nix index 71aed0d..0cab965 100644 --- a/modules/nilla/default.nix +++ b/modules/nilla/default.nix @@ -2,7 +2,7 @@ includes = [ ./builders ./services.nix - ./configurations.nix + ./systems.nix ./modules.nix ./flake.nix ]; diff --git a/modules/nilla/flake.nix b/modules/nilla/flake.nix index f3fe6f1..0193f2d 100644 --- a/modules/nilla/flake.nix +++ b/modules/nilla/flake.nix @@ -18,11 +18,12 @@ in nixosModules darwinModules homeModules - nixosConfigurations - darwinConfigurations - homeConfigurations ; + nixosConfigurations = builtins.mapAttrs (_: system: system.result) config.systems.nixos; + darwinConfigurations = builtins.mapAttrs (_: system: system.result) config.systems.darwin; + homeConfigurations = builtins.mapAttrs (_: system: system.result) config.systems.home; + devShells = transpose config.shells; packages = transpose config.packages; diff --git a/modules/nilla/systems.nix b/modules/nilla/systems.nix new file mode 100644 index 0000000..63b349a --- /dev/null +++ b/modules/nilla/systems.nix @@ -0,0 +1,52 @@ +{ config, lib }: +let + mkBuilderOption = + typ: + lib.options.create { + type = lib.types.function (lib.types.function lib.types.raw); + default.value = _name: _module: throw "Builder for systems.${typ} is not implemented"; + }; + inherit (config.systems) builders; + mkSystemModule = + typ: + { config, name }: + { + options = { + name = lib.options.create { + type = lib.types.string; + default.value = name; + }; + module = lib.options.create { + type = lib.types.raw; + default.value = { }; + }; + builder = lib.options.create { + type = lib.types.function (lib.types.function lib.types.raw); + default.value = builders.${typ}; + }; + result = lib.options.create { + type = lib.types.raw; + writable = false; + default.value = config.builder config.name config.module; + }; + }; + }; + mkSystemOption = + typ: + lib.options.create { + type = lib.types.attrs.of (lib.types.submodule (mkSystemModule typ)); + default.value = { }; + }; +in +{ + options = { + systems = { + builders.nixos = mkBuilderOption "nixos"; + builders.darwin = mkBuilderOption "darwin"; + builders.home = mkBuilderOption "home"; + nixos = mkSystemOption "nixos"; + darwin = mkSystemOption "darwin"; + home = mkSystemOption "home"; + }; + }; +}