modules/nilla: configurations -> systems

This commit is contained in:
Nikodem Rabuliński 2025-04-01 17:48:58 +02:00
parent 75ca1eb38f
commit 696be4cada
Signed by: nrabulinski
SSH key fingerprint: SHA256:AZZVyfKStaCo8sbJB+3Rr/CRrlym1oEgw7vMnynJeR8
11 changed files with 64 additions and 58 deletions

View file

@ -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;
};
};
}

View file

@ -2,7 +2,7 @@
includes = [
./builders
./services.nix
./configurations.nix
./systems.nix
./modules.nix
./flake.nix
];

View file

@ -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;

52
modules/nilla/systems.nix Normal file
View file

@ -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";
};
};
}