templates: allow specifying from flake-parts module
This commit is contained in:
@@ -43,10 +43,6 @@
|
||||
meta.name = "clan-core";
|
||||
};
|
||||
|
||||
flake = {
|
||||
clan.templates = import ./templates { };
|
||||
};
|
||||
|
||||
systems = import systems;
|
||||
imports =
|
||||
# only importing existing paths allows to minimize the flake for test
|
||||
|
||||
@@ -27,9 +27,13 @@ in
|
||||
};
|
||||
|
||||
options.flake = flake-parts-lib.mkSubmoduleOptions {
|
||||
clan = lib.mkOption { type = types.raw; };
|
||||
clanInternals = lib.mkOption { type = types.raw; };
|
||||
};
|
||||
config = {
|
||||
flake.clan = {
|
||||
inherit (config.clan.clanInternals) templates;
|
||||
};
|
||||
flake.clanInternals = config.clan.clanInternals;
|
||||
flake.nixosConfigurations = config.clan.nixosConfigurations;
|
||||
};
|
||||
|
||||
@@ -69,6 +69,15 @@ in
|
||||
```
|
||||
'';
|
||||
};
|
||||
|
||||
templates = lib.mkOption {
|
||||
type = types.submodule { imports = [ ./templates/interface.nix ]; };
|
||||
default = { };
|
||||
description = ''
|
||||
Define Clan templates.
|
||||
'';
|
||||
};
|
||||
|
||||
inventory = lib.mkOption {
|
||||
type = types.submodule { imports = [ ../inventory/build-inventory/interface.nix ]; };
|
||||
description = ''
|
||||
@@ -112,11 +121,11 @@ in
|
||||
type = types.lazyAttrsOf types.raw;
|
||||
default = { };
|
||||
};
|
||||
|
||||
# flake.clanInternals
|
||||
clanInternals = lib.mkOption {
|
||||
# Hide from documentation. Exposes internals to the cli.
|
||||
visible = false;
|
||||
# type = types.raw;
|
||||
# ClanInternals
|
||||
type = types.submodule {
|
||||
options = {
|
||||
|
||||
57
lib/build-clan/templates/interface.nix
Normal file
57
lib/build-clan/templates/interface.nix
Normal file
@@ -0,0 +1,57 @@
|
||||
{
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) types;
|
||||
|
||||
templateType = types.submodule (
|
||||
{ name, ... }:
|
||||
{
|
||||
options.description = lib.mkOption {
|
||||
type = types.str;
|
||||
default = name;
|
||||
description = ''
|
||||
The name of the template.
|
||||
'';
|
||||
};
|
||||
|
||||
options.path = lib.mkOption {
|
||||
type = types.path;
|
||||
description = ''
|
||||
Holds the path to the clan template.
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
options = {
|
||||
# clan.templates.clan
|
||||
clan = lib.mkOption {
|
||||
type = types.attrsOf templateType;
|
||||
default = { };
|
||||
description = ''
|
||||
Holds the different clan templates.
|
||||
'';
|
||||
};
|
||||
|
||||
# clan.templates.disko
|
||||
disko = lib.mkOption {
|
||||
type = types.attrsOf templateType;
|
||||
default = { };
|
||||
description = ''
|
||||
Holds different disko templates.
|
||||
'';
|
||||
};
|
||||
|
||||
# clan.templates.machine
|
||||
machine = lib.mkOption {
|
||||
type = types.attrsOf templateType;
|
||||
default = { };
|
||||
description = ''
|
||||
Holds the different machine templates.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
{ ... }:
|
||||
{
|
||||
disko = {
|
||||
single-disk = {
|
||||
description = "A simple ext4 disk with a single partition";
|
||||
path = ./disk/single-disk;
|
||||
};
|
||||
};
|
||||
|
||||
machine = {
|
||||
flash-installer = {
|
||||
description = "Initialize a new flash-installer machine";
|
||||
path = ./clan/machineTemplates/machines/flash-installer;
|
||||
};
|
||||
new-machine = {
|
||||
description = "Initialize a new machine";
|
||||
path = ./clan/machineTemplates/machines/new-machine;
|
||||
};
|
||||
};
|
||||
|
||||
clan = {
|
||||
default = {
|
||||
description = "Initialize a new clan flake";
|
||||
path = ./clan/new-clan;
|
||||
};
|
||||
minimal = {
|
||||
description = "for clans managed via (G)UI";
|
||||
path = ./clan/minimal;
|
||||
};
|
||||
flake-parts = {
|
||||
description = "Flake-parts";
|
||||
path = ./clan/flake-parts;
|
||||
};
|
||||
minimal-flake-parts = {
|
||||
description = "Minimal flake-parts clan template";
|
||||
path = ./clan/minimal-flake-parts;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,45 @@
|
||||
{ self, inputs, ... }:
|
||||
{
|
||||
clan.templates = {
|
||||
disko = {
|
||||
single-disk = {
|
||||
description = "A simple ext4 disk with a single partition";
|
||||
path = ./disk/single-disk;
|
||||
};
|
||||
};
|
||||
|
||||
machine = {
|
||||
flash-installer = {
|
||||
description = "Initialize a new flash-installer machine";
|
||||
path = ./clan/machineTemplates/machines/flash-installer;
|
||||
};
|
||||
|
||||
new-machine = {
|
||||
description = "Initialize a new machine";
|
||||
path = ./clan/machineTemplates/machines/new-machine;
|
||||
};
|
||||
};
|
||||
|
||||
clan = {
|
||||
default = {
|
||||
description = "Initialize a new clan flake";
|
||||
path = ./clan/new-clan;
|
||||
};
|
||||
minimal = {
|
||||
description = "for clans managed via (G)UI";
|
||||
path = ./clan/minimal;
|
||||
};
|
||||
flake-parts = {
|
||||
description = "Flake-parts";
|
||||
path = ./clan/flake-parts;
|
||||
};
|
||||
minimal-flake-parts = {
|
||||
description = "Minimal flake-parts clan template";
|
||||
path = ./clan/minimal-flake-parts;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
flake = {
|
||||
checks.x86_64-linux.template-minimal =
|
||||
let
|
||||
|
||||
Reference in New Issue
Block a user