Merge pull request 'templates: rename 'new_clan' to default' (#4244) from templates into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/4244
This commit is contained in:
hsjobeki
2025-07-08 07:31:22 +00:00
22 changed files with 17 additions and 107 deletions

View File

@@ -105,7 +105,7 @@ git+file:///home/lhebendanz/Projects/clan-core
│ ├───editor omitted (use '--all-systems' to show) │ ├───editor omitted (use '--all-systems' to show)
└───templates └───templates
├───default: template: Initialize a new clan flake ├───default: template: Initialize a new clan flake
└───new-clan: template: Initialize a new clan flake └───default: template: Initialize a new clan flake
``` ```
You can execute every test separately by following the tree path `nix run .#checks.x86_64-linux.clan-pytest -L` for example. You can execute every test separately by following the tree path `nix run .#checks.x86_64-linux.clan-pytest -L` for example.

View File

@@ -45,7 +45,6 @@ def test_clan_core_templates(
"default", "default",
"flake-parts", "flake-parts",
"minimal", "minimal",
"minimal-flake-parts",
] ]
# clan.default # clan.default
@@ -55,18 +54,18 @@ def test_clan_core_templates(
template_path = default_template.get("path", None) template_path = default_template.get("path", None)
assert template_path is not None assert template_path is not None
new_clan = temporary_home / "new_clan" my_clan = temporary_home / "my_clan"
copy_from_nixstore( copy_from_nixstore(
Path(template_path), Path(template_path),
new_clan, my_clan,
) )
flake_nix = new_clan / "flake.nix" flake_nix = my_clan / "flake.nix"
assert (flake_nix).exists() assert (flake_nix).exists()
assert (flake_nix).is_file() assert (flake_nix).is_file()
assert (new_clan / "machines").is_dir() assert (my_clan / "machines").is_dir()
# Test if we can write to the flake.nix file # Test if we can write to the flake.nix file
with flake_nix.open("r+") as f: with flake_nix.open("r+") as f:

View File

@@ -78,6 +78,10 @@ def create_clan(opts: CreateOptions) -> None:
if opts.update_clan: if opts.update_clan:
run(nix_command(["flake", "update"]), RunOpts(cwd=dest)) run(nix_command(["flake", "update"]), RunOpts(cwd=dest))
if opts.setup_git:
run(git_command(dest, "add", "."))
run(git_command(dest, "commit", "-m", "Initial commit"))
if opts.initial: if opts.initial:
inventory_store = InventoryStore(flake=Flake(str(opts.dest))) inventory_store = InventoryStore(flake=Flake(str(opts.dest)))
inventory_store.write(opts.initial, message="Init inventory") inventory_store.write(opts.initial, message="Init inventory")

View File

@@ -131,7 +131,7 @@ def test_clan_create_api(
assert public_key.exists() assert public_key.exists()
assert public_key.is_file() assert public_key.is_file()
dest_clan_dir = Path("~/new-clan").expanduser() dest_clan_dir = Path("~/default").expanduser()
# ===== CREATE CLAN ====== # ===== CREATE CLAN ======
# TODO: We need to generate a lock file for the templates # TODO: We need to generate a lock file for the templates

2
templates/clan/default/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
result
.direnv/

2
templates/clan/flake-parts/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
result
.direnv/

View File

@@ -1,2 +0,0 @@
result
.direnv/

View File

@@ -1,22 +0,0 @@
{ self, ... }:
{
perSystem =
{
self',
lib,
system,
...
}:
{
checks =
let
nixosMachines = lib.mapAttrs' (
name: config: lib.nameValuePair "nixos-${name}" config.config.system.build.toplevel
) ((lib.filterAttrs (_: config: config.pkgs.system == system)) self.nixosConfigurations);
packages = lib.mapAttrs' (n: lib.nameValuePair "package-${n}") self'.packages;
devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self'.devShells;
in
nixosMachines // packages // devShells;
};
}

View File

@@ -1,13 +0,0 @@
{ self, inputs, ... }:
{
imports = [
inputs.clan.flakeModules.default
];
clan = {
meta.name = "__CHANGE_ME__";
inherit self;
specialArgs = {
inherit inputs;
};
};
}

View File

@@ -1,17 +0,0 @@
_: {
perSystem =
{
pkgs,
inputs',
...
}:
{
devShells = {
default = pkgs.mkShellNoCC {
packages = [
inputs'.clan.packages.default
];
};
};
};
}

View File

@@ -1,31 +0,0 @@
{
inputs = {
clan.url = "https://git.clan.lol/clan/clan-core/archive/main.tar.gz";
nixpkgs.follows = "clan/nixpkgs";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "clan/nixpkgs";
};
outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } (
{ ... }:
{
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
imports = [
./checks.nix
./clan.nix
./devshells.nix
./formatter.nix
];
}
);
}

View File

@@ -1,10 +0,0 @@
_: {
perSystem =
{
pkgs,
...
}:
{
formatter = pkgs.nixfmt;
};
}

2
templates/clan/minimal/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
result
.direnv/

View File

@@ -25,7 +25,7 @@
clan = { clan = {
default = { default = {
description = "Initialize a new clan flake"; description = "Initialize a new clan flake";
path = ./clan/new-clan; path = ./clan/default;
}; };
minimal = { minimal = {
description = "for clans managed via (G)UI"; description = "for clans managed via (G)UI";
@@ -35,10 +35,6 @@
description = "Flake-parts"; description = "Flake-parts";
path = ./clan/flake-parts; path = ./clan/flake-parts;
}; };
minimal-flake-parts = {
description = "Minimal flake-parts clan template";
path = ./clan/minimal-flake-parts;
};
}; };
}; };
in in