Commit Graph

1541 Commits

Author SHA1 Message Date
Michael Hoang
83a2de0f47 cli: don't update macOS machines 2025-04-08 08:53:29 +02:00
Michael Hoang
b5a57a72a0 build-clan: support constructing darwinConfigurations 2025-04-08 08:53:29 +02:00
DavHau
d7c3039666 add CLAN_NO_COMMIT env var to disable committing
This is required when calling vars generators for generating vars for
tests
2025-04-07 18:59:19 +07:00
Jörg Thalheim
721f61eaed only compute final_script and validation hashes once 2025-04-04 18:31:12 +02:00
Jörg Thalheim
340bf4752f ssh/upload: fix shell quoting 2025-04-04 15:10:09 +00:00
Michael Hoang
7b456be472 cli: managed by clan -> managed by Clan 2025-04-03 00:25:51 +09:00
Michael Hoang
c7ba642a38 cli: machines update [MACHINE] -> machines update [MACHINES] 2025-04-03 00:25:51 +09:00
Qubasa
fb1cea261e clan-cli: Fix deployment as non root edgecase 2025-03-31 20:25:05 +02:00
Johannes Kirschbauer
ae8e7edac0 feat(clanLib): expose clanInternals.clanLib
This is usefully for:
- As api via python
- for testing clanLib downstream
2025-03-30 17:07:11 +02:00
Jonathan Thiessen
89379f103a Make Generator's validation dynamic
* Switch `Generator`'s `validation` from a regular property to
  an `@property` annotated method backed by `Machine`'s `eval_nix()`.
* Ensure that `Machine`'s flake cache is flushed after each
  effectful generator execution (rather than only after all
  generators have been executed).
2025-03-30 04:33:30 +00:00
Jonathan Thiessen
3c0c2ce9d6 Fix cached None support in FlakeCacheEntry
Previously, you could cache None values; however,
insertion wasn't idempotent/identical reinsertion
would lead to errors due to missing None checks.
2025-03-30 04:33:30 +00:00
Jonathan Thiessen
d4fa480262 Add overlapping (consistent) flake cache insert test
* Additionally, update `insert`'s input type hint to support None values
  (as they are already selectable and (one shot) insertable).
  This is necessary to appease the linter wrt the added test.
2025-03-30 04:33:30 +00:00
Luis Hebendanz
3b2ed4e6ab Merge pull request 'clan-cli: Fix deployment as non root with a buildHost set' (#3132) from Qubasa/clan-core:fix_target_host_as_non_root into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3132
2025-03-29 16:56:49 +00:00
Johannes Kirschbauer
12b88cd19b feat(classgen): convert only certain attributes 2025-03-29 14:22:34 +01:00
Johannes Kirschbauer
16644309b4 fix(cli/inventory): update classes 2025-03-29 13:25:19 +01:00
Qubasa
a992484fb9 clan-cli: Fix deployment as non root with a buildHost set 2025-03-28 18:47:36 +01:00
Jörg Thalheim
eaf20ae09a tests: add fake_sudo to sshd fixture
This allows to use the same code for both testing and real-world.
2025-03-28 17:14:22 +00:00
Qubasa
2406a62ce0 test_secrets_upload: Don't prepend sudo inside test; Improve secret upload test 2025-03-28 17:14:22 +00:00
Qubasa
0afbf9dd45 checks/installation-without-system: modify to install through normal user instead of root 2025-03-26 18:37:31 +01:00
RTUnreal
0ea9b45838 clan_cli: fix support for non-root deployment user 2025-03-26 18:37:31 +01:00
DavHau
48fa29afad vars/prompts: print var name even if custom description is set 2025-03-26 10:48:05 +00:00
Jörg Thalheim
d3a1b29c6b make gnupg a dependency of sops
if anything uses a gnupg key, we need the gnupg binary.
Sucks a bit, but at least it makes it work everywhere.
2025-03-25 18:30:18 +01:00
Qubasa
dfd550f9be clan-cli: cleanup broken deployment cache 2025-03-20 00:17:36 -07:00
Jörg Thalheim
43035b85a5 always resolve symlinks for TemporaryDirectory
On macOS mktemp returns a temporary directory in a symlink.
Nix has a bug where it won't accept path:// located in a symlink.
This avoid this issue by always resolving symlinks as returned by
TemporaryDirectory.
2025-03-19 16:47:18 +01:00
Louis Opter
b52ec05497 clan-cli: don't try to delete a dir that doesn't exist in the pass vars backend
Do not crash in `delete_store`, if the machine has no vars, or the store
has been deleted already.
2025-03-19 10:53:38 +00:00
Louis Opter
4120a89115 clan-cli: do not crash if a machine being deleted is missing from the inventory
We implement that by actually raising `KeyError` in `inventory.delete_by_path`
(as advertised in the docstring), since it makes more sense to catch a
`KeyError` than a generic `ClanError`.
2025-03-19 10:53:38 +00:00
Louis Opter
cd248b69db clan-cli: machines delete: delete the machine's vars and secrets
When a machine is deleted with `clan machines delete`, remove its
vars and legacy secrets, and update any secrets that reference the
machine's key.

This command is a superset of `clan secrets machine delete`, and I am
wondering if we could remove the `clan secrets machine` subcommand,
unless there is an use case for having a machine defined without its
key, and any secrets/vars?

Note:

- This deletes the `ListSecretsOptions` dataclass, as it did not seem to
  bring any value, especially since `list_secrets` was receiving its
  individual members instead of the whole dataclass. We can always bring
  it back if complexity grows to demand it.
2025-03-19 10:53:38 +00:00
Louis Opter
f7bec766bc clan-cli: add delete and delete_store to StoreBase
- `delete` lets you delete a specific var under a specific generator;
- `delete_store` deletes an entire store.

The `delete` method could be useful to "garbage-collect" unused vars as
a machine's configuration changes.

The `delete_store` method can be used to delete all the vars for a
machine when the machine is deleted. The current behavior is to leave
everything behind.

Important point:

- `delete_store` needs to be idempotent because public and
  "private"/"secret" vars for a machine can share the same physical
  store (directory), and deleting either type of store (public or
  private) will delete both.
2025-03-19 10:53:38 +00:00
Qubasa
63a0e5f35d clan-cli: Fix templates not downloading template, Make templates use Flake cache, Fix flake cache exception on conditional attribute, add more tests 2025-03-19 10:30:52 +00:00
Jörg Thalheim
527154070c use pathlib.iterdir() everywhere 2025-03-18 15:34:06 +01:00
Jörg Thalheim
10c89fe9f9 fix only the first generator of each machine beeing re-encrypted 2025-03-11 12:09:00 +01:00
Jörg Thalheim
903831acaf don't log cache miss by default
This is expected and happens regular, so there is no value in logging
this.
2025-03-11 12:03:55 +01:00
Michael Hoang
d79d1811d6 install: let nixos-anywhere determine where to build automatically
This fixes installing machines that don't have `system` defined i.e.
when running `clan machines install` with `--update-hardware-config`.
2025-03-10 12:30:03 +09:00
DavHau
db2e2e974c vars+facts: use bwrap only if supported 2025-03-09 13:52:15 +07:00
Qubasa
5c4fc7b852 clan-cli: Make Lix compatible again 2025-03-07 14:06:35 +01:00
Qubasa
4c138c6377 clan-cli: Revert generating facts in clan facts list, for consistency 2025-03-03 01:40:40 +01:00
Qubasa
0602b9d01c clan-cli: Fix wrong clan vars generate regression added by 4ff5acfe29 2025-03-02 19:53:17 +01:00
Qubasa
75dc906183 clan-cli: Fix get_all_facts forgetting to generate facts before getting them 2025-03-02 15:07:57 +01:00
Michael Hoang
f0e5b14846 vars/sops: fix clan vars fix missing machine name in error message 2025-03-02 08:22:23 +07:00
Qubasa
a0aaa5fc69 clan-cli: Remove can_build_locally and replace with nixos-anywhere --build-on auto 2025-03-01 17:52:41 +01:00
Qubasa
eb9b4bdb6b clan-cli: Make host upload function support uploading single files too 2025-03-01 17:10:42 +01:00
lassulus
669a28c4e5 clan-cli: set ssh port for nix copy 2025-02-28 04:58:42 +00:00
lassulus
0104c41921 clan-cli: another try to fix the CI bug 2025-02-27 08:24:28 +01:00
lassulus
e3ce93a6ff clan-cli: check if paths exist in cache check 2025-02-27 02:53:41 +01:00
Qubasa
ba2865e940 clan-cli: Fix flake.py missing cache eviction if there is a garbage collected path 2025-02-27 01:01:50 +01:00
r17x
e9ffd923d5 fix(clan-cli): fix cross system 2025-02-26 14:27:00 +07:00
Pablo Ovelleiro Corral
8aab746bd0 Apply suggestion 2025-02-25 08:51:51 +01:00
Pablo Ovelleiro Corral
d9e0741329 Fix exists() check for age files 2025-02-25 08:51:51 +01:00
Qubasa
d7c4a5d59d clan-cli: Remove allow_uknown_placeholders flag. With upcoming nixos-anywhere patch this is not needed anymore. 2025-02-23 21:50:21 +01:00
Qubasa
ad3786ad76 clan-cli: Add an optional reference to an AsyncFuture to track origin of task. 2025-02-23 21:44:00 +01:00