Merge pull request 'Update clan templates' (#4099) from update-templates-services into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/4099
This commit is contained in:
hsjobeki
2025-06-27 17:25:22 +00:00
30 changed files with 194 additions and 616 deletions

View File

@@ -93,7 +93,7 @@ def test_clan_core_templates(
]
clan_core_template_keys = list(clan_core_templates.keys())
expected_templates = ["default", "flake-parts", "minimal", "minimal-flake-parts"]
expected_templates = ["classic", "default", "minimal"]
assert clan_core_template_keys == expected_templates
vlist_temps = list_templates("clan", clan_dir)
@@ -112,17 +112,16 @@ def test_clan_core_templates(
Path(default_template.src["path"]),
new_clan,
)
assert (new_clan / "flake.nix").exists()
assert (new_clan / "machines").is_dir()
assert (new_clan / "machines" / "jon").is_dir()
config_nix_p = new_clan / "machines" / "jon" / "configuration.nix"
assert (config_nix_p).is_file()
flake_file = new_clan / "flake.nix"
# Test if we can write to the configuration.nix file
with config_nix_p.open("r+") as f:
assert (flake_file).exists()
# Test if we can read + write files after the template was copied
with flake_file.open("r+") as f:
data = f.read()
f.write(data)
assert (new_clan / "machines").is_dir()
# Test Case 1: Minimal input with empty templates
@pytest.mark.with_core

View File

@@ -23,8 +23,7 @@ def test_create_flake(
cli.run(["flakes", "create", str(flake_dir), "--template=default", "--no-update"])
assert (flake_dir / ".clan-flake").exists()
# Replace the inputs.clan.url in the template flake.nix
# Replace the inputs.clan-core.url in the template flake.nix
substitute(
flake_dir / "flake.nix",
clan_core,
@@ -35,13 +34,6 @@ def test_create_flake(
cli.run(["machines", "create", "machine1"])
# create a hardware-configuration.nix that doesn't throw an eval error
for patch_machine in ["jon", "sara"]:
(
flake_dir / "machines" / f"{patch_machine}/hardware-configuration.nix"
).write_text("{}")
with capture_output as output:
cli.run(["machines", "list"])
assert "machine1" in output.out
@@ -68,8 +60,7 @@ def test_create_flake_existing_git(
cli.run(["flakes", "create", str(flake_dir), "--template=default", "--no-update"])
assert (flake_dir / ".clan-flake").exists()
# Replace the inputs.clan.url in the template flake.nix
# Replace the inputs.clan-core.url in the template flake.nix
substitute(
flake_dir / "flake.nix",
clan_core,
@@ -79,13 +70,6 @@ def test_create_flake_existing_git(
monkeypatch.chdir(flake_dir)
cli.run(["machines", "create", "machine1"])
# create a hardware-configuration.nix that doesn't throw an eval error
for patch_machine in ["jon", "sara"]:
(
flake_dir / "machines" / f"{patch_machine}/hardware-configuration.nix"
).write_text("{}")
with capture_output as output:
cli.run(["machines", "list"])
assert "machine1" in output.out
@@ -111,7 +95,7 @@ def test_ui_template(
cli.run(["flakes", "create", str(flake_dir), "--template=minimal", "--no-update"])
# Replace the inputs.clan.url in the template flake.nix
# Replace the inputs.clan-core.url in the template flake.nix
substitute(
flake_dir / "flake.nix",
clan_core,