diff --git a/pkgs/clan-cli/clan_cli/clan/create.py b/pkgs/clan-cli/clan_cli/clan/create.py index 8d8cf2def..c4beeccd5 100644 --- a/pkgs/clan-cli/clan_cli/clan/create.py +++ b/pkgs/clan-cli/clan_cli/clan/create.py @@ -4,6 +4,7 @@ import logging from pathlib import Path from clan_lib.clan.create import CreateOptions, create_clan +from clan_lib.errors import ClanError log = logging.getLogger(__name__) @@ -26,10 +27,10 @@ def register_create_parser(parser: argparse.ArgumentParser) -> None: ) parser.add_argument( - "path", - type=Path, - help="Path where to write the clan template to", - default=Path(), + "name", + type=str, + nargs="?", + help="Name of the clan to create. If not provided, will prompt for a name.", ) parser.add_argument( @@ -40,9 +41,18 @@ def register_create_parser(parser: argparse.ArgumentParser) -> None: ) def create_flake_command(args: argparse.Namespace) -> None: + # Ask for a path interactively if none provided + if args.name is None: + user_input = input("Enter a name for the new clan: ").strip() + if not user_input: + msg = "Error: name is required." + raise ClanError(msg) + + args.name = Path(user_input) + create_clan( CreateOptions( - dest=args.path, + dest=Path(args.name), template=args.template, setup_git=not args.no_git, src_flake=args.flake, diff --git a/pkgs/clan-cli/clan_lib/templates/filesystem.py b/pkgs/clan-cli/clan_lib/templates/filesystem.py index aa2779f21..1b3187cbc 100644 --- a/pkgs/clan-cli/clan_lib/templates/filesystem.py +++ b/pkgs/clan-cli/clan_lib/templates/filesystem.py @@ -1,3 +1,4 @@ +import shutil from pathlib import Path from clan_lib.flake import Flake @@ -35,7 +36,7 @@ def copy_from_nixstore(src: Path, dest: Path) -> None: Uses `cp -r` to recursively copy the directory. Ensures the destination directory is writable by the user. """ - run(["cp", "-r", str(src / "."), str(dest)]) # Copy contents of src to dest + shutil.copytree(src, dest, dirs_exist_ok=True, symlinks=True) run( ["chmod", "-R", "u+w", str(dest)] ) # Ensure the destination is writable by the user diff --git a/templates/clan/default/clan.nix b/templates/clan/default/clan.nix index f18dd7a8a..9ac930a7e 100644 --- a/templates/clan/default/clan.nix +++ b/templates/clan/default/clan.nix @@ -2,6 +2,11 @@ # Ensure this is unique among all clans you want to use. meta.name = "__CHANGE_ME__"; + inventory.machines = { + # Define machines here. + # jon = { }; + }; + # Docs: See https://docs.clan.lol/reference/clanServices inventory.instances = { diff --git a/templates/clan/flake-parts/clan.nix b/templates/clan/flake-parts/clan.nix index f18dd7a8a..9ac930a7e 100644 --- a/templates/clan/flake-parts/clan.nix +++ b/templates/clan/flake-parts/clan.nix @@ -2,6 +2,11 @@ # Ensure this is unique among all clans you want to use. meta.name = "__CHANGE_ME__"; + inventory.machines = { + # Define machines here. + # jon = { }; + }; + # Docs: See https://docs.clan.lol/reference/clanServices inventory.instances = {