diff --git a/docs/site/guides/contributing/debugging.md b/docs/site/guides/contributing/debugging.md index 7298648f2..f084cecb8 100644 --- a/docs/site/guides/contributing/debugging.md +++ b/docs/site/guides/contributing/debugging.md @@ -105,7 +105,7 @@ git+file:///home/lhebendanz/Projects/clan-core │ ├───editor omitted (use '--all-systems' to show) └───templates ├───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. diff --git a/pkgs/clan-cli/clan_cli/tests/test_clan_nix_attrset.py b/pkgs/clan-cli/clan_cli/tests/test_clan_nix_attrset.py index 2b8a99269..458185d7e 100644 --- a/pkgs/clan-cli/clan_cli/tests/test_clan_nix_attrset.py +++ b/pkgs/clan-cli/clan_cli/tests/test_clan_nix_attrset.py @@ -45,7 +45,6 @@ def test_clan_core_templates( "default", "flake-parts", "minimal", - "minimal-flake-parts", ] # clan.default @@ -55,18 +54,18 @@ def test_clan_core_templates( template_path = default_template.get("path", None) assert template_path is not None - new_clan = temporary_home / "new_clan" + my_clan = temporary_home / "my_clan" copy_from_nixstore( 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).is_file() - assert (new_clan / "machines").is_dir() + assert (my_clan / "machines").is_dir() # Test if we can write to the flake.nix file with flake_nix.open("r+") as f: diff --git a/pkgs/clan-cli/clan_lib/clan/create.py b/pkgs/clan-cli/clan_lib/clan/create.py index c00f9f131..1538d6ca3 100644 --- a/pkgs/clan-cli/clan_lib/clan/create.py +++ b/pkgs/clan-cli/clan_lib/clan/create.py @@ -78,6 +78,10 @@ def create_clan(opts: CreateOptions) -> None: if opts.update_clan: 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: inventory_store = InventoryStore(flake=Flake(str(opts.dest))) inventory_store.write(opts.initial, message="Init inventory") diff --git a/pkgs/clan-cli/clan_lib/tests/test_create.py b/pkgs/clan-cli/clan_lib/tests/test_create.py index 58809bd7e..7a0a23311 100644 --- a/pkgs/clan-cli/clan_lib/tests/test_create.py +++ b/pkgs/clan-cli/clan_lib/tests/test_create.py @@ -131,7 +131,7 @@ def test_clan_create_api( assert public_key.exists() assert public_key.is_file() - dest_clan_dir = Path("~/new-clan").expanduser() + dest_clan_dir = Path("~/default").expanduser() # ===== CREATE CLAN ====== # TODO: We need to generate a lock file for the templates diff --git a/templates/clan/new-clan/.clan-flake b/templates/clan/default/.clan-flake similarity index 100% rename from templates/clan/new-clan/.clan-flake rename to templates/clan/default/.clan-flake diff --git a/templates/clan/new-clan/.envrc b/templates/clan/default/.envrc similarity index 100% rename from templates/clan/new-clan/.envrc rename to templates/clan/default/.envrc diff --git a/templates/clan/default/.gitignore b/templates/clan/default/.gitignore new file mode 100644 index 000000000..76570c15f --- /dev/null +++ b/templates/clan/default/.gitignore @@ -0,0 +1,2 @@ +result +.direnv/ \ No newline at end of file diff --git a/templates/clan/new-clan/flake.nix b/templates/clan/default/flake.nix similarity index 100% rename from templates/clan/new-clan/flake.nix rename to templates/clan/default/flake.nix diff --git a/templates/clan/new-clan/machines/jon/configuration.nix b/templates/clan/default/machines/jon/configuration.nix similarity index 100% rename from templates/clan/new-clan/machines/jon/configuration.nix rename to templates/clan/default/machines/jon/configuration.nix diff --git a/templates/clan/new-clan/machines/sara/configuration.nix b/templates/clan/default/machines/sara/configuration.nix similarity index 100% rename from templates/clan/new-clan/machines/sara/configuration.nix rename to templates/clan/default/machines/sara/configuration.nix diff --git a/templates/clan/new-clan/modules/disko.nix b/templates/clan/default/modules/disko.nix similarity index 100% rename from templates/clan/new-clan/modules/disko.nix rename to templates/clan/default/modules/disko.nix diff --git a/templates/clan/new-clan/modules/gnome.nix b/templates/clan/default/modules/gnome.nix similarity index 100% rename from templates/clan/new-clan/modules/gnome.nix rename to templates/clan/default/modules/gnome.nix diff --git a/templates/clan/new-clan/modules/shared.nix b/templates/clan/default/modules/shared.nix similarity index 100% rename from templates/clan/new-clan/modules/shared.nix rename to templates/clan/default/modules/shared.nix diff --git a/templates/clan/flake-parts/.gitignore b/templates/clan/flake-parts/.gitignore new file mode 100644 index 000000000..76570c15f --- /dev/null +++ b/templates/clan/flake-parts/.gitignore @@ -0,0 +1,2 @@ +result +.direnv/ \ No newline at end of file diff --git a/templates/clan/minimal-flake-parts/.gitignore b/templates/clan/minimal-flake-parts/.gitignore deleted file mode 100644 index 4812d58f9..000000000 --- a/templates/clan/minimal-flake-parts/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -result -.direnv/ diff --git a/templates/clan/minimal-flake-parts/checks.nix b/templates/clan/minimal-flake-parts/checks.nix deleted file mode 100644 index 8de32fa02..000000000 --- a/templates/clan/minimal-flake-parts/checks.nix +++ /dev/null @@ -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; - }; -} diff --git a/templates/clan/minimal-flake-parts/clan.nix b/templates/clan/minimal-flake-parts/clan.nix deleted file mode 100644 index 507900c94..000000000 --- a/templates/clan/minimal-flake-parts/clan.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ self, inputs, ... }: -{ - imports = [ - inputs.clan.flakeModules.default - ]; - clan = { - meta.name = "__CHANGE_ME__"; - inherit self; - specialArgs = { - inherit inputs; - }; - }; -} diff --git a/templates/clan/minimal-flake-parts/devshells.nix b/templates/clan/minimal-flake-parts/devshells.nix deleted file mode 100644 index 43a2d86db..000000000 --- a/templates/clan/minimal-flake-parts/devshells.nix +++ /dev/null @@ -1,17 +0,0 @@ -_: { - perSystem = - { - pkgs, - inputs', - ... - }: - { - devShells = { - default = pkgs.mkShellNoCC { - packages = [ - inputs'.clan.packages.default - ]; - }; - }; - }; -} diff --git a/templates/clan/minimal-flake-parts/flake.nix b/templates/clan/minimal-flake-parts/flake.nix deleted file mode 100644 index 63afbb405..000000000 --- a/templates/clan/minimal-flake-parts/flake.nix +++ /dev/null @@ -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 - ]; - } - ); -} diff --git a/templates/clan/minimal-flake-parts/formatter.nix b/templates/clan/minimal-flake-parts/formatter.nix deleted file mode 100644 index ec092fae4..000000000 --- a/templates/clan/minimal-flake-parts/formatter.nix +++ /dev/null @@ -1,10 +0,0 @@ -_: { - perSystem = - { - pkgs, - ... - }: - { - formatter = pkgs.nixfmt; - }; -} diff --git a/templates/clan/minimal/.gitignore b/templates/clan/minimal/.gitignore new file mode 100644 index 000000000..76570c15f --- /dev/null +++ b/templates/clan/minimal/.gitignore @@ -0,0 +1,2 @@ +result +.direnv/ \ No newline at end of file diff --git a/templates/flake.nix b/templates/flake.nix index c7e76fb92..f905c53b3 100644 --- a/templates/flake.nix +++ b/templates/flake.nix @@ -25,7 +25,7 @@ clan = { default = { description = "Initialize a new clan flake"; - path = ./clan/new-clan; + path = ./clan/default; }; minimal = { description = "for clans managed via (G)UI"; @@ -35,10 +35,6 @@ description = "Flake-parts"; path = ./clan/flake-parts; }; - minimal-flake-parts = { - description = "Minimal flake-parts clan template"; - path = ./clan/minimal-flake-parts; - }; }; }; in