Merge pull request 'Clan-core: Rename clanName within Machines' (#1851) from hsjobeki/clan-core:hsjobeki-main into main

This commit is contained in:
clan-bot
2024-08-06 10:30:52 +00:00
9 changed files with 37 additions and 23 deletions

View File

@@ -13,7 +13,6 @@ let
specialArgs
;
# Final inventory
inherit (config.clanInternals) inventory;
inherit (clan-core.lib.inventory) buildInventory;
@@ -88,8 +87,8 @@ let
clan.core.clanDir = directory;
# Inherited from clan wide settings
# TODO: remove these
clan.core.clanName = config.inventory.meta.name;
clan.core.clanIcon = config.inventory.meta.icon;
clan.core.name = config.inventory.meta.name;
clan.core.icon = config.inventory.meta.icon;
# Machine specific settings
clan.core.machineName = name;

View File

@@ -10,7 +10,6 @@ let
inherit lib nixpkgs clan-core;
self = ./.;
};
in
#######
{

View File

@@ -12,7 +12,7 @@ let
imports = (import (pkgs.path + "/nixos/modules/module-list.nix")) ++ [
{
nixpkgs.hostPlatform = "x86_64-linux";
clan.core.clanName = "dummy";
clan.core.name = "dummy";
}
];
};

View File

@@ -1,11 +1,33 @@
{ lib, pkgs, ... }:
{
imports = [
(lib.mkRemovedOptionModule [
"clan"
"core"
"clanName"
] "clanName has been removed. Use clan.core.name instead.")
(lib.mkRemovedOptionModule [
"clan"
"core"
"clanIcon"
] "clanIcon has been removed. Use clan.core.icon instead.")
];
options.clan.core = {
clanName = lib.mkOption {
name = lib.mkOption {
type = lib.types.str;
description = ''
the name of the clan
'';
# Set by the flake, so it's read-only in the maschine
readOnly = true;
};
icon = lib.mkOption {
type = lib.types.nullOr lib.types.path;
description = ''
the location of the clan icon
'';
# Set by the flake, so it's read-only in the maschine
readOnly = true;
};
machineIcon = lib.mkOption {
type = lib.types.nullOr lib.types.path;
@@ -28,12 +50,6 @@
the location of the flake repo, used to calculate the location of facts and secrets
'';
};
clanIcon = lib.mkOption {
type = lib.types.nullOr lib.types.path;
description = ''
the location of the clan icon
'';
};
machineName = lib.mkOption {
type = lib.types.str;
default = "nixos";

View File

@@ -249,8 +249,8 @@ in
config = {
# for clan vm inspect
clan.core.vm.inspect = {
clan_name = config.clan.core.clanName;
machine_icon = config.clan.core.machineIcon or config.clan.core.clanIcon;
clan_name = config.clan.core.name;
machine_icon = config.clan.core.machineIcon or config.clan.core.icon;
machine_name = config.clan.core.machineName;
machine_description = config.clan.core.machineDescription;
memory_size = config.clan.virtualisation.memorySize;

View File

@@ -23,8 +23,8 @@ in
};
name = lib.mkOption {
type = lib.types.str;
default = config.clan.core.clanName;
defaultText = "config.clan.core.clanName";
default = config.clan.core.name;
defaultText = "config.clan.core.name";
description = ''
zerotier network name
'';

View File

@@ -57,7 +57,7 @@ def inspect_flake(flake_url: str | Path, machine_name: str) -> FlakeConfig:
# Get the Clan name
cmd = nix_eval(
[
f'{flake_url}#clanInternals.machines."{system}"."{machine_name}".config.clan.core.clanName'
f'{flake_url}#clanInternals.machines."{system}"."{machine_name}".config.clan.core.name'
]
)
res = run_cmd(cmd)
@@ -66,7 +66,7 @@ def inspect_flake(flake_url: str | Path, machine_name: str) -> FlakeConfig:
# Get the clan icon path
cmd = nix_eval(
[
f'{flake_url}#clanInternals.machines."{system}"."{machine_name}".config.clan.core.clanIcon'
f'{flake_url}#clanInternals.machines."{system}"."{machine_name}".config.clan.core.icon'
]
)
res = run_cmd(cmd)
@@ -79,9 +79,9 @@ def inspect_flake(flake_url: str | Path, machine_name: str) -> FlakeConfig:
cmd = nix_build(
[
f'{flake_url}#clanInternals.machines."{system}"."{machine_name}".config.clan.core.clanIcon'
f'{flake_url}#clanInternals.machines."{system}"."{machine_name}".config.clan.core.icon'
],
machine_gcroot(flake_url=str(flake_url)) / "clanIcon",
machine_gcroot(flake_url=str(flake_url)) / "icon",
)
run_cmd(cmd)

View File

@@ -18,7 +18,7 @@ def verify_machine_config(
) -> str | None:
"""
Verify that the machine evaluates successfully
Returns a tuple of (success, error_message)
Returns None, in case of success, or a String containing the error_message
"""
if config is None:
config = config_for_machine(flake_dir, machine_name)

View File

@@ -90,7 +90,7 @@ def machine_schema(
# potentially the config might affect submodule options,
# therefore we need to import it
config
{{ clan.core.clanName = "fakeClan"; }}
{{ clan.core.name = "fakeClan"; }}
]
# add all clan modules specified via clanImports
++ (map (name: clan-core.clanModules.${{name}}) config.clanImports or []);