diff --git a/docs/quickstart.md b/docs/quickstart.md index 5daadefa..1894ffed 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -91,6 +91,7 @@ Absolutely, let's break down the migration step by step, explaining each action # this needs to point at the repository root directory = self; specialArgs = {}; + clanName = "NEEDS_TO_BE_UNIQUE"; # TODO: Changeme machines = { example-desktop = { nixpkgs.hostPlatform = "x86_64-linux"; @@ -107,6 +108,7 @@ Absolutely, let's break down the migration step by step, explaining each action - Inside `machines`, a new machine configuration is defined (in this case, `example-desktop`). - Inside `example-desktop` which is the target machine hostname, `nixpkgs.hostPlatform` specifies the host platform as `x86_64-linux`. - `clanInternals`: Is required to enable evaluation of the secret generation/upload script on every architecture + - `clanName`: Is required and needs to be globally unique, as else we have a cLAN name clash 4. **Rebuild and Switch**: Rebuild your NixOS configuration using the updated flake: diff --git a/lib/build-clan/default.nix b/lib/build-clan/default.nix index 1a141955..f7d05b2d 100644 --- a/lib/build-clan/default.nix +++ b/lib/build-clan/default.nix @@ -2,6 +2,7 @@ { directory # The directory containing the machines subdirectory , specialArgs ? { } # Extra arguments to pass to nixosSystem i.e. useful to make self available , machines ? { } # allows to include machine-specific modules i.e. machines.${name} = { ... } +, clanName # Needs to be (globally) unique, as this determines the folder name where the flake gets downloaded to. }: let machinesDirs = lib.optionalAttrs (builtins.pathExists "${directory}/machines") (builtins.readDir (directory + /machines)); @@ -73,6 +74,7 @@ in clanInternals = { machines = configsPerSystem; + clanName = clanName; all-machines-json = lib.mapAttrs (system: configs: nixpkgs.legacyPackages.${system}.writers.writeJSON "machines.json" (lib.mapAttrs (_: m: m.config.system.clan.deployment.data) configs)) configsPerSystem; diff --git a/pkgs/clan-cli/clan_cli/task_manager.py b/pkgs/clan-cli/clan_cli/task_manager.py index 79b71a7e..b2573e0f 100644 --- a/pkgs/clan-cli/clan_cli/task_manager.py +++ b/pkgs/clan-cli/clan_cli/task_manager.py @@ -63,6 +63,7 @@ class Command: os.set_blocking(self.p.stdout.fileno(), False) os.set_blocking(self.p.stderr.fileno(), False) + while self.p.poll() is None: # Check if stderr is ready to be read from rlist, _, _ = select.select([self.p.stderr, self.p.stdout], [], [], 0) @@ -70,10 +71,10 @@ class Command: try: for line in fd: if fd == self.p.stderr: - print(f"[{cmd[0]}] stderr: {line.rstrip()}") + self.log.debug(f"[{cmd[0]}] stderr: {line}") self.stderr.append(line) else: - print(f"[{cmd[0]}] stdout: {line.rstrip()}") + self.log.debug(f"[{cmd[0]}] stdout: {line}") self.stdout.append(line) self._output.put(line) except BlockingIOError: diff --git a/pkgs/clan-cli/clan_cli/vms/create.py b/pkgs/clan-cli/clan_cli/vms/create.py index 5e85d1d9..8cc12f12 100644 --- a/pkgs/clan-cli/clan_cli/vms/create.py +++ b/pkgs/clan-cli/clan_cli/vms/create.py @@ -48,6 +48,7 @@ class BuildVmTask(BaseTask): # TODO: We should get this from the vm argument vm_config = self.get_vm_create_info(cmds) + # TODO: Don't use a temporary directory, instead create a new flake directory with tempfile.TemporaryDirectory() as tmpdir_: tmpdir = Path(tmpdir_) xchg_dir = tmpdir / "xchg" diff --git a/pkgs/clan-cli/tests/test_flake_with_core/flake.nix b/pkgs/clan-cli/tests/test_flake_with_core/flake.nix index b7b980c2..0c287e45 100644 --- a/pkgs/clan-cli/tests/test_flake_with_core/flake.nix +++ b/pkgs/clan-cli/tests/test_flake_with_core/flake.nix @@ -9,6 +9,7 @@ let clan = clan-core.lib.buildClan { directory = self; + clanName = "test_with_core_clan"; machines = { vm1 = { lib, ... }: { clan.networking.deploymentAddress = "__CLAN_DEPLOYMENT_ADDRESS__"; diff --git a/pkgs/clan-cli/tests/test_flake_with_core_and_pass/flake.nix b/pkgs/clan-cli/tests/test_flake_with_core_and_pass/flake.nix index 38346de6..39a01f06 100644 --- a/pkgs/clan-cli/tests/test_flake_with_core_and_pass/flake.nix +++ b/pkgs/clan-cli/tests/test_flake_with_core_and_pass/flake.nix @@ -9,6 +9,7 @@ let clan = clan-core.lib.buildClan { directory = self; + clanName = "test_with_core_and_pass_clan"; machines = { vm1 = { lib, ... }: { clan.networking.deploymentAddress = "__CLAN_DEPLOYMENT_ADDRESS__"; diff --git a/pkgs/clan-cli/tests/test_flake_with_core_dynamic_machines/flake.nix b/pkgs/clan-cli/tests/test_flake_with_core_dynamic_machines/flake.nix index 7c4558db..13c30ea0 100644 --- a/pkgs/clan-cli/tests/test_flake_with_core_dynamic_machines/flake.nix +++ b/pkgs/clan-cli/tests/test_flake_with_core_dynamic_machines/flake.nix @@ -9,6 +9,7 @@ let clan = clan-core.lib.buildClan { directory = self; + clanName = "core_dynamic_machine_clan"; machines = let machineModules = builtins.readDir (self + "/machines"); diff --git a/templates/new-clan/flake.nix b/templates/new-clan/flake.nix index fca91ed0..38acce83 100644 --- a/templates/new-clan/flake.nix +++ b/templates/new-clan/flake.nix @@ -9,6 +9,7 @@ pkgs = clan-core.inputs.nixpkgs.legacyPackages.${system}; clan = clan-core.lib.buildClan { directory = self; + clanName = "__CHANGE_ME__"; }; in {