Merge pull request 'fix(checks/inventory): use buildClan instead of buildInventory' (#3267) from hsjobeki/clan-core:lib-cleanup into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3267
This commit is contained in:
hsjobeki
2025-04-09 16:14:06 +00:00
22 changed files with 134 additions and 89 deletions

View File

@@ -1,5 +1,5 @@
(import ../lib/test-inventory.nix) ( (import ../lib/test-inventory.nix) (
{ self, lib, ... }: { lib, ... }:
let let
machines = [ machines = [
@@ -21,9 +21,6 @@
roles.signer.machines = [ "signer" ]; roles.signer.machines = [ "signer" ];
}; };
}; };
modules = {
data-mesher = self.clanModules.data-mesher;
};
}; };
directory = ./.; directory = ./.;
}; };

View File

@@ -1,6 +1,10 @@
(import ../lib/test-inventory.nix) ( (import ../lib/test-inventory.nix) (
{ ... }: { ... }:
{ {
# This tests the compatibility of the inventory
# With the test framework
# - legacy-modules
# - clan.service modules
name = "dummy-inventory-test"; name = "dummy-inventory-test";
inventory.directory = ./.; inventory.directory = ./.;
@@ -8,22 +12,54 @@
machines.peer1 = { }; machines.peer1 = { };
machines.admin1 = { }; machines.admin1 = { };
services = { services = {
dummy-module.default = { legacy-module.default = {
roles.peer.machines = [ "peer1" ]; roles.peer.machines = [ "peer1" ];
roles.admin.machines = [ "admin1" ]; roles.admin.machines = [ "admin1" ];
}; };
}; };
instances."test" = {
module.name = "new-service";
roles.peer.machines.peer1 = { };
};
modules = { modules = {
dummy-module = ./dummy-module; legacy-module = ./legacy-module;
new-service = {
_class = "clan.service";
manifest.name = "new-service";
roles.peer = { };
perMachine = {
nixosModule = {
# This should be generated by:
# ./pkgs/scripts/update-vars.py inventory-test-framework-compatibility-test
clan.core.vars.generators.new-service = {
files.hello = {
secret = false;
deploy = true;
};
script = ''
# This is a dummy script that does nothing
echo "This is a dummy script" > $out/hello
'';
};
};
};
};
}; };
}; };
testScript = '' testScript =
{ nodes, ... }:
''
start_all() start_all()
admin1.wait_for_unit("multi-user.target") admin1.wait_for_unit("multi-user.target")
peer1.wait_for_unit("multi-user.target") peer1.wait_for_unit("multi-user.target")
# Provided by the legacy module
print(admin1.succeed("systemctl status dummy-service")) print(admin1.succeed("systemctl status dummy-service"))
print(peer1.succeed("systemctl status dummy-service")) print(peer1.succeed("systemctl status dummy-service"))
# peer1 should have the 'hello' file
peer1.succeed("cat ${nodes.peer1.clan.core.vars.generators.new-service.files.hello.path}")
''; '';
} }
) )

View File

@@ -1,4 +1,6 @@
[
{ {
"publickey": "age17fkfrtwwaxx6nhgnrh2vyzpejesyucng90f6y2j48yt96vspwyrsqhknpj", "publickey": "age1hd2exjq88h7538y6mvjvexx3u5gp6a03yfn5nj32h2667yyksyaqcuk5qs",
"type": "age" "type": "age"
} }
]

View File

@@ -1,4 +1,6 @@
[
{ {
"publickey": "age1uehj0t7lhprwenmfvsamrja8xs9uvruw830nfll7m0pmuhddqd9sdwke7q", "publickey": "age19urkt89q45a2wk6a4yaramzufjtnw6nq2snls0v7hmf7tqf73axsfx50tk",
"type": "age" "type": "age"
} }
]

View File

@@ -1,20 +1,15 @@
{ {
"data": "ENC[AES256_GCM,data:uIzee4V2eBKH+1FR+BvrdyMg1SIpSshdAD0Yl1g5WMBrknvhGaQczaVzzwBBmorhmM2qUyS99F5CnSxx9JsF1ojnHrH1QWe9GzI=,iv:LCTp/3dWDVuxcLzQt8LI8gTNzYkG2rymNBkKD/clnw8=,tag:M32g0FuAvZ+nnGq/VSGYEQ==,type:str]", "data": "ENC[AES256_GCM,data:hhuFgZcPqht0h3tKxGtheS4GlrVDo4TxH0a9lxgPYj2i12QUmE04rB07A+hu4Z8WNWLYvdM5069mEOZYm3lSeTzBHQPxYZRuVj0=,iv:sA1srRFQqsMlJTAjFcb09tI/Jg2WjOVJL5NZkPwiLoU=,tag:6xXo9FZpmAJw6hCBsWzf8Q==,type:str]",
"sops": { "sops": {
"kms": null,
"gcp_kms": null,
"azure_kv": null,
"hc_vault": null,
"age": [ "age": [
{ {
"recipient": "age1qm0p4vf9jvcnn43s6l4prk8zn6cx0ep9gzvevxecv729xz540v8qa742eg", "recipient": "age1qm0p4vf9jvcnn43s6l4prk8zn6cx0ep9gzvevxecv729xz540v8qa742eg",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBrTkwxeUlCTTNUWjVsMThT\nZ3l5emRDL2t0cHhIQ1hiNGRCU3lDQXA0c1NnCnZPUm15RXVkTFhmdXZtdURPcE40\nVHgyK2N1dW9LRGw5ZzRNUW8wWmtkZ00KLS0tIE8yQU1GaXNVM0ZRdk1CWXpjU1Aw\nSWZKWEUza00yL3QxNEEvb21LT05zdkkKMXkIG2IroZ3Fb+4JiGMkspgHaQF5ZYhM\nt2HjXDP+H4J2Mi3WN17aXpZNzeEJeRYZzhQZp/2RN8fucGtjOvgTHw==\n-----END AGE ENCRYPTED FILE-----\n" "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBGaGVHeTgrN3dJQ2VITFBM\neWVzbDhjb0pwNUhBUjdUc0p5OTVta1dvSno4ClJxeUc4Z0hiaFRkVlJ1YTA4Lyta\neWdwV005WGYvMUNRVG1qOVdicTk0NUkKLS0tIFQvaDNFS1JMSFlHRXlhc3lsZm03\nYVhDaHNsam5wN1VqdzA3WTZwM1JwV2sKZk/SiZJgjllADdfHLSWuQcU4+LttDpt/\nqqDUATEuqYaALljC/y3COT+grTM2bwGjj6fsfsfiO/EL9iwzD3+7oA==\n-----END AGE ENCRYPTED FILE-----\n"
} }
], ],
"lastmodified": "2025-04-08T14:05:14Z", "lastmodified": "2025-04-09T15:10:16Z",
"mac": "ENC[AES256_GCM,data:fMscucQv/EpEY5jaOqDS7CGfQnhRTNhIJprIYX2JoiQoTdZo2yP/h8wZnvKBCAWKut5KRj3VRENPjAiKq31UhWtEU271fqzHeOadrLQ9VD7DK31qFSXgYGLBn51rlewQd3I+VXXRCfNJRFcE8i38YAMKbDsKRuqUdh8b4V7ernw=,iv:rslGG25fVSVl3li/vZGriy/QsSCWNkBUzKvHBhxwj+I=,tag:Cg0j6Ea9OpgUfEo7/+QJ8w==,type:str]", "mac": "ENC[AES256_GCM,data:xuXj4833G6nhvcRo2ekDxz8G5phltmU8h1GgGofH9WndzrqLKeRSqm/n03IHRW0f4F68XxnyAkfvokVh6vW3LRQAFkqIlXz5U4+zFNcaVaPobS5gHTgxsCoTUoalWPvHWtXd50hUVXeAt8rPfTfeveVGja8bOERk8mvwUPxb6h4=,iv:yP1usA9m8tKl6Z/UK9PaVMJlZlF5qpY4EiM4+ByVlik=,tag:8DgoIhLstp3MRki90VfEvw==,type:str]",
"pgp": null,
"unencrypted_suffix": "_unencrypted", "unencrypted_suffix": "_unencrypted",
"version": "3.9.4" "version": "3.10.1"
} }
} }

View File

@@ -1,20 +1,15 @@
{ {
"data": "ENC[AES256_GCM,data:FfuscjTuIoAdSt9JU1mxeMlXGyGb57wtYPvi3HEMVY6xM4XcVNI0HwIVj+rAR02ae/DxUppq4t+UWb/Hm4un98UNUoksSWV1cpA=,iv:RJGGTIg/Qn+oLub+i7CGxj1wT1kggKhCriTwBkwXzgQ=,tag:8js1JJGW37IwgR25Vw0LKg==,type:str]", "data": "ENC[AES256_GCM,data:rwPhbayGf6mE1E9NCN+LuL7VfWWOfhoJW6H2tNSoyebtyTpM3GO2jWca1+N7hI0juhNkUk+rIsYQYbCa/5DZQiV0/2Jgu4US1XY=,iv:B5mcaQsDjb6BacxGB4Kk88/qLCpVOjQNRvGN+fgUiEo=,tag:Uz0A8kAF5NzFetbv9yHIjQ==,type:str]",
"sops": { "sops": {
"kms": null,
"gcp_kms": null,
"azure_kv": null,
"hc_vault": null,
"age": [ "age": [
{ {
"recipient": "age1qm0p4vf9jvcnn43s6l4prk8zn6cx0ep9gzvevxecv729xz540v8qa742eg", "recipient": "age1qm0p4vf9jvcnn43s6l4prk8zn6cx0ep9gzvevxecv729xz540v8qa742eg",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB0dDgwcEkwNFBVa3NEZnM2\nWjk4YWxJZkoydFhKMEprWDRJZTluajV1b0drCnlzKytwaHNEenZaSFJhZ0daQWpB\nMzU2MStFU3pTbjk4d1Jjc2tkS2VVT3cKLS0tIFF1QW5hdkQzK0ZtallIcU11aFE5\nM2FWU05pazZYNHM3dDRRZmhyRmpya3MKuzKn13nDHDJI4I6Hdwg3/zAh9xSm8N6n\nDTN7nyWO4E9NRJiqAyjq+Ivfi22/mx0eBww/odGASRHGogZyNB6Fkg==\n-----END AGE ENCRYPTED FILE-----\n" "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBWY0hKQ1dnV0tMYytDMCtj\nTDV4Zk5NeVN0bCtqaWRQV3d4M0VlcGVZMkhZCm02dHZyOGVlYzJ5Z3FlUWNXMVQ0\nb2ZrTXZQRzRNdzFDeWZCVGhlTS9rMm8KLS0tIEJkY1QwOENRYWw3cjIwd3I0bzdz\nOEtQNm1saE5wNWt2UUVnYlN4NWtGdFkKmWHU5ttZoQ3NZu/zkX5VxfC2sMpSOyod\neb7LRhFqPfo5N1XphJcCqr5QUoZOfnH0xFhZ2lxWUS3ItiRpU4VDwg==\n-----END AGE ENCRYPTED FILE-----\n"
} }
], ],
"lastmodified": "2025-04-08T14:05:32Z", "lastmodified": "2025-04-09T15:10:41Z",
"mac": "ENC[AES256_GCM,data:NDcR67xbWQOnSJ04ytFMW0wXqKYo99f5Qxtv3vyiGb6GD1rvzI05EYhzc0ZEQRxjcSV5Qm5UbDG4h7P3fZ1UhmeErtN+0gKrQY3t+Q6sZ5w/JwgLxIzS5D37T2INHuPdBfZbA3xoK/fq3soObxOhYcOWlFH8JWruTFcukRoeh0Q=,iv:WiD5qMzil3S3ufSIkzvm9QAoQJ32rRCyTvtl9NagI4c=,tag:1cf3PVABwHor7nMhrjlq9Q==,type:str]", "mac": "ENC[AES256_GCM,data:pab0G2GPjgs59sbiZ8XIV5SdRtq5NPU0yq18FcqiMV8noAL94fyVAY7fb+9HILQWQsEjcykgk9mA2MQ0KpK/XG8+tDQKcBH+F+2aQnw5GJevXmfi7KLTU0P224SNo7EnKlfFruB/+NZ0WBtkbbg1OzekrbplchpSI6BxWz/jASE=,iv:TCj9FCxgfMF2+PJejr67zgGnF+CFS+YeJiejnHbf7j0=,tag:s7r9SqxeqpAkncohYvIQ2Q==,type:str]",
"pgp": null,
"unencrypted_suffix": "_unencrypted", "unencrypted_suffix": "_unencrypted",
"version": "3.9.4" "version": "3.10.1"
} }
} }

View File

@@ -1,24 +1,19 @@
{ {
"data": "ENC[AES256_GCM,data:WSKPca2m,iv:HLdB11pEOW06u1YKHl8zrEzmnAiYvZ7muKIDnoTQ2/w=,tag:Jnf1k27hE96+p6OTjGSYbA==,type:str]", "data": "ENC[AES256_GCM,data:bxM9aYMK,iv:SMNYtk9FSyZ1PIfEzayTKKdCnZWdhcyUEiTwFUNb988=,tag:qJYW4+VQyhF1tGPQPTKlOQ==,type:str]",
"sops": { "sops": {
"kms": null,
"gcp_kms": null,
"azure_kv": null,
"hc_vault": null,
"age": [ "age": [
{ {
"recipient": "age17fkfrtwwaxx6nhgnrh2vyzpejesyucng90f6y2j48yt96vspwyrsqhknpj", "recipient": "age1hd2exjq88h7538y6mvjvexx3u5gp6a03yfn5nj32h2667yyksyaqcuk5qs",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSByM1Zqc1o0WG9RUFRsdEhk\nclVwd2YwVUZrSzJscnJSWG1VYlJ5TTV3Y3drCnRMMlpyenJJTUNDZ3phbWdScTU5\neUhtc0svbTE3aGRtTmFyYUpOVGR1VkUKLS0tIHBMVjdLZU51aFpqUysrdnRROVV1\nZy9OcnBseE0ycHI5OEFLQzYwQXBGMEUK3JsnrTRbxVvD4j14WZ2ZNcMTvfamQvJL\ni3TE2rOe1sB2J0n58hlx8UxoBd6+LI/q4V0H6FSHG2Yswi0G/tGlaA==\n-----END AGE ENCRYPTED FILE-----\n" "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAvZDZYYXdpcXVqRFRnQ2Jx\nTFhFWEJTR290cHZhTXZadFFvcHM4MHVIN3lFCmJhOEZrL3g4TFBZVllxdDFZakJn\nR3NxdXo0eE8vTDh3QlhWOFpVZ0lNUHcKLS0tIEE4dkpCalNzaXJ0Qks3VHJSUzZF\nb2N3NGdjNHJnSUN6bW8welZ1VDdJakEKGKZ7nn1p11IyJB6DMxu2HJMvZ+0+5WpE\nPLWh2NlGJO3XrrL4Fw7xetwbqE+QUZPNl/JbEbu4KLIUGLjqk9JDhQ==\n-----END AGE ENCRYPTED FILE-----\n"
}, },
{ {
"recipient": "age1qm0p4vf9jvcnn43s6l4prk8zn6cx0ep9gzvevxecv729xz540v8qa742eg", "recipient": "age1qm0p4vf9jvcnn43s6l4prk8zn6cx0ep9gzvevxecv729xz540v8qa742eg",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBZOWd6c01pZ01RcmFXQXRR\ndnpNdW84T3VCNnVKVHM3a2YwS2t6LzByQ3lBCnJqcTR4QUlqU3hkTGVuMGViR3ZS\ncG85Zy9LdDE4TGRuNHExN2trT2h3c2sKLS0tIDZtM3JFbWFOeXB2QzFyQ2VKZ0hJ\nSXpLc1hKTytXSk1FUXoycmJBVHBVQ3MKP444/bnDxNHLnC9vWhKfUyaMPnCTTItn\nifeT3KAvjZ9JfMygh1y24GRAE8D1ECo7Wz6fnQmivFurhft4kff+wg==\n-----END AGE ENCRYPTED FILE-----\n" "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBHckJCQVFyb21aT1R0d2Rr\nMWxNMHVqcGxabHBmS0RibW9sN0gyZDI1b1dFCnRWUk5LSWdxV3c4RWVZdUtEN1Fv\nRk4xVmwwT2xrdWVERkJXUVVlVXJjTVUKLS0tIC9ERG9KMGxTNEsrbzFHUGRiVUlm\nRi9qakxoc1FOVVV1TkUrckwxRUVnajQKE8ms/np2NMswden3xkjdC8cXccASLOoN\nu+EaEk69UvBvnOg9VBjyPAraIKgNrTc4WWwz+DOBj1pCwVbu9XxUlA==\n-----END AGE ENCRYPTED FILE-----\n"
} }
], ],
"lastmodified": "2025-04-08T14:05:23Z", "lastmodified": "2025-04-09T15:10:30Z",
"mac": "ENC[AES256_GCM,data:CFR43lubMAh7Oa/QF4rtqVrw8HWehGp+keTgsmIKsDK7SbKh1InbUX3mvBqlOk684f6l3uco3R9whh4WDKx24cqIrqo/aExM/9cq73Bw0IlZGlnpQLA43YUsXbBAy1gV1QB2nP/8T+X4cOB3ZE4KL9B5lzHBcqilzMQWz2cwR50=,iv:nB16rMtgjOnOTWL0E/VP7dQjcNLZasSH3MuEHdM7CeM=,tag:eyBHqnAJNJMlW2Zq8aFwog==,type:str]", "mac": "ENC[AES256_GCM,data:cIwWctUbAFI8TRMxYWy5xqlKDVLMqBIxVv4LInnLqi3AauL0rJ3Z7AxK/wb2dCQM07E1N7YaORNqgUpFC1xo0hObAA8mrPaToPotKDkjua0zuyTUNS1COoraYjZpI/LKwmik/qtk399LMhiC7aHs+IliT9Dd41B8LSMBXwdMldY=,iv:sZ+//BrYH5Ay2JJAGs7K+WfO2ASK82syDlilQjGmgFs=,tag:nY+Af9eQRLwkiHZe85dQ9A==,type:str]",
"pgp": null,
"unencrypted_suffix": "_unencrypted", "unencrypted_suffix": "_unencrypted",
"version": "3.9.4" "version": "3.10.1"
} }
} }

View File

@@ -1,24 +1,19 @@
{ {
"data": "ENC[AES256_GCM,data:D3aHBQ==,iv:tKAbvLTJGX3uy7GbGv0Ar6ZirIkcAsvcOKA3nN4wIh4=,tag:gAZBZWEpbHYWrZxyEAwwMQ==,type:str]", "data": "ENC[AES256_GCM,data:ImlGIKxE,iv:UUWxjLNRKJCD2WHNpw8lfvCc8rnXPCqc2pni1ODckjE=,tag:HFCqiv31E9bShIIaAEjF0A==,type:str]",
"sops": { "sops": {
"kms": null,
"gcp_kms": null,
"azure_kv": null,
"hc_vault": null,
"age": [ "age": [
{ {
"recipient": "age1qm0p4vf9jvcnn43s6l4prk8zn6cx0ep9gzvevxecv729xz540v8qa742eg", "recipient": "age19urkt89q45a2wk6a4yaramzufjtnw6nq2snls0v7hmf7tqf73axsfx50tk",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBtUDFSTTdJeTdFd284Z094\nZUhCRnBiUlVCUURtSFVBb2JXT2dDcVI5b1FnCmdNRkVJbU9aRnFER1VUZnFMSmVy\nblVsTEt5VVhxTEQrNWpyaUgyV0ljL2cKLS0tIDdJNWQrZXpRT3NFclZmVDRhazRC\nU2FVMTVkTEE4TEVuQ29jamwzWGZaeTgK/ehUsaFUgHvQFtS7GMmx22PkgmdDnewS\nmwvy7HSGYXrUjJQVpb2/KtB2dbhEHcv4CGXLBq7FjKVgdLR8EnSsIQ==\n-----END AGE ENCRYPTED FILE-----\n" "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBpTEROZjh6NjBhSlJSc1Av\nSHhjdkhwVUd3VzBZemhQb3dhMlJXalBmZlFjCkZPYkhZZGVOVTNjUWdFU0s4cWFn\nL2NXbkRCdUlMdElnK2lGbG5iV0w1cHMKLS0tIFREcmxDdHlUNVBFVGRVZSt0c0E5\nbnpHaW1Vb3R3ZFFnZVMxY3djSjJmOU0KIwqCSQf5S9oA59BXu7yC/V6yqvCh88pa\nYgmNyBjulytPh1aAfOuNWIGdIxBpcEf+gFjz3EiJY9Kft3fTmhp2bw==\n-----END AGE ENCRYPTED FILE-----\n"
}, },
{ {
"recipient": "age1uehj0t7lhprwenmfvsamrja8xs9uvruw830nfll7m0pmuhddqd9sdwke7q", "recipient": "age1qm0p4vf9jvcnn43s6l4prk8zn6cx0ep9gzvevxecv729xz540v8qa742eg",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBDc3kwWnYxa3ZCVUNLSXlO\nZ0JwY0xHR3U4TG1LUXQrblVzem13a3EyMlRrCmtEbWRPTDc3akRpUFdOZjNrdWtT\nYTRQandScHpRNTljTUJvZWpEbEd1SlkKLS0tIGIvU2F3aTgwUkRycGdLVmdDNWc0\nNG5sd3VoZWxFbjNudXMyc3JlYnpHTkkK8MIKY3dhpW0B59aWl3Q1aVWilEKs5KQ/\nGILM5YxSB8HfslC2SxdTVY2bGgFnOCU09nQCv7y1vqyqvvZVJLfviQ==\n-----END AGE ENCRYPTED FILE-----\n" "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSArN3R4TThibjdYbE9TMDE1\naUhuNDlscExjaktIR2VmTk1OMWtVM0NpTUJZClJUNEcwVDlibExWQk84TTNEWFhp\nMjYyZStHc1N0ZTh1S3VTVk45WGxlWWMKLS0tIHFab25LY1R1d1l6NE5XbHJvQ3lj\nNGsxUldFVHQ5RVJERDlGbi9NY29hNWsKENBTcAS/R/dTGRYdaWv5Mc/YG4bkah5w\nb421ZMQF+r4CYnzUqnwivTG8TMRMqJLavfkutE6ZUfJbbLufrTk5Lw==\n-----END AGE ENCRYPTED FILE-----\n"
} }
], ],
"lastmodified": "2025-04-08T14:05:41Z", "lastmodified": "2025-04-09T15:11:04Z",
"mac": "ENC[AES256_GCM,data:OeNZkdkKiosQlhKxQ3XlIJqpxPiEzu9MYHNFNol5TKzlLBLrNbbeoBO5qDyY4dJLzbqYWeUakG9L1UVuCZ3WIZYqO0R4W2JM5Y6IvYVxhLm0uqrjYRvZJgRajm2LFLcNed3ZLHQDWsdTkJ4aBnv1cqz/ACq+vrHe5lhCLDrijRE=,iv:ZLn8pRiKzy/vYx+cSlGCF5owVq8yWUQaSP7rf3sdqtI=,tag:VO79CECmhdJv3WGU3VIZNw==,type:str]", "mac": "ENC[AES256_GCM,data:JdJzocQZWVprOmZ4Ni04k1tpD1TpFcK5neKy3+0/c3+uPBwjwaMayISKRaa/ILUXlalg60oTqxB4fUFoYVm8KGQVhDwPhO/T1hyYVQqidonrcYfJfCYg00mVSREV/AWqXb7RTnaEBfrdnRJvaAQF9g2qDXGVgzp3eACdlItclv4=,iv:nOw1jQjIWHWwU3SiKpuQgMKXyu8MZYI+zI9UYYd9fCI=,tag:ewUkemIPm/5PkmuUD0EcAQ==,type:str]",
"pgp": null,
"unencrypted_suffix": "_unencrypted", "unencrypted_suffix": "_unencrypted",
"version": "3.9.4" "version": "3.10.1"
} }
} }

View File

@@ -0,0 +1 @@
This is a dummy script

View File

@@ -4,13 +4,13 @@ let
inherit (pkgs) lib; inherit (pkgs) lib;
inherit (lib) mkOption flip mapAttrs; inherit (lib) mkOption flip mapAttrs;
inherit (lib.types) path raw; inherit (lib.types) path raw;
inherit (self.clanLib.inventory) buildInventory; inherit (self.clanLib) buildClan;
nixos-lib = import (pkgs.path + "/nixos/lib") { }; nixos-lib = import (pkgs.path + "/nixos/lib") { };
in in
(nixos-lib.runTest ( (nixos-lib.runTest (
{ config, ... }: { config, ... }:
let let
serviceConfigs = buildInventory { result = buildClan {
inventory = config.inventory.inventory; inventory = config.inventory.inventory;
# TODO: make directory argument optional in buildInventory # TODO: make directory argument optional in buildInventory
directory = config.inventory.directory; directory = config.inventory.directory;
@@ -29,7 +29,7 @@ in
}; };
}; };
config = { config = {
nodes = flip mapAttrs serviceConfigs.machines ( nodes = flip mapAttrs result.clanInternals.inventoryClass.machines (
machineName: attrs: { machineName: attrs: {
imports = attrs.machineImports ++ [ self.nixosModules.clanCore ]; imports = attrs.machineImports ++ [ self.nixosModules.clanCore ];
clan.core.settings.directory = "${config.inventory.directory}"; clan.core.settings.directory = "${config.inventory.directory}";

View File

@@ -162,8 +162,6 @@ in
inventoryFile = lib.mkOption { type = lib.types.raw; }; inventoryFile = lib.mkOption { type = lib.types.raw; };
# The machine 'imports' generated by the inventory per machine # The machine 'imports' generated by the inventory per machine
inventoryClass = lib.mkOption { type = lib.types.raw; }; inventoryClass = lib.mkOption { type = lib.types.raw; };
# new attribute
distributedServices = lib.mkOption { type = lib.types.raw; };
# clan-core's modules # clan-core's modules
clanModules = lib.mkOption { type = lib.types.raw; }; clanModules = lib.mkOption { type = lib.types.raw; };
source = lib.mkOption { type = lib.types.raw; }; source = lib.mkOption { type = lib.types.raw; };

View File

@@ -46,6 +46,7 @@ let
inventoryClass = ( inventoryClass = (
buildInventory { buildInventory {
inherit inventory directory; inherit inventory directory;
flakeInputs = config.self.inputs;
} }
); );
@@ -76,19 +77,16 @@ let
clan-core.nixosModules.clanCore clan-core.nixosModules.clanCore
extraConfig extraConfig
(machines.${name} or { }) (machines.${name} or { })
# Inherit the inventory assertions ?
# { inherit (mergedInventory) assertions; }
{ imports = inventoryClass.machines.${name}.machineImports or [ ]; } { imports = inventoryClass.machines.${name}.machineImports or [ ]; }
# Import the distribute services
{ imports = config.clanInternals.distributedServices.allMachines.${name} or [ ]; }
( (
{ {
# Settings # Settings
clan.core.settings = { clan.core.settings = {
inherit directory;
inherit (config.inventory.meta) name icon; inherit (config.inventory.meta) name icon;
inherit directory;
machine = { machine = {
inherit name; inherit name;
}; };
@@ -254,12 +252,14 @@ in
inherit darwinConfigurations; inherit darwinConfigurations;
clanInternals = { clanInternals = {
moduleSchemas = clan-core.clanLib.modules.getModulesSchema config.inventory.modules; moduleSchemas = clan-core.clanLib.modules.getModulesSchema {
inherit inventoryClass; modules = config.inventory.modules;
distributedServices = clan-core.clanLib.inventory.mapInstances { # TODO: make this function system agnostic
inherit inventory; pkgs = nixpkgs.legacyPackages."x86_64-linux";
flakeInputs = config.self.inputs; inherit clan-core;
}; };
inherit inventoryClass;
# TODO: unify this interface # TODO: unify this interface
# We should have only clan.modules. (consistent with clan.templates) # We should have only clan.modules. (consistent with clan.templates)
inherit (clan-core) clanModules clanLib; inherit (clan-core) clanModules clanLib;

View File

@@ -9,6 +9,9 @@ in
directory = mkOption { directory = mkOption {
type = types.path; type = types.path;
}; };
distributedServices = mkOption {
type = types.raw;
};
inventory = mkOption { inventory = mkOption {
type = types.raw; type = types.raw;
}; };

View File

@@ -8,7 +8,11 @@ let
machinesFromInventory :: Inventory -> { ${machine_name} :: NixOSConfiguration } machinesFromInventory :: Inventory -> { ${machine_name} :: NixOSConfiguration }
*/ */
buildInventory = buildInventory =
{ inventory, directory }: {
inventory,
directory,
flakeInputs,
}:
(lib.evalModules { (lib.evalModules {
specialArgs = { specialArgs = {
inherit clanLib; inherit clanLib;
@@ -16,6 +20,19 @@ let
modules = [ modules = [
./builder ./builder
{ inherit directory inventory; } { inherit directory inventory; }
(
# config.distributedServices.allMachines.${name} or [ ];
{ config, ... }:
{
distributedServices = clanLib.inventory.mapInstances {
inherit (config) inventory;
inherit flakeInputs;
};
machines = lib.mapAttrs (_machineName: v: {
machineImports = v;
}) config.distributedServices.allMachines;
}
)
]; ];
}).config; }).config;
in in

View File

@@ -114,7 +114,7 @@ let
inherit (instance) module; inherit (instance) module;
inherit resolvedModule instanceRoles; inherit resolvedModule instanceRoles;
} }
) inventory.instances; ) inventory.instances or { };
# TODO: Eagerly check the _class of the resolved module # TODO: Eagerly check the _class of the resolved module
importedModulesEvaluated = lib.mapAttrs ( importedModulesEvaluated = lib.mapAttrs (

View File

@@ -12,6 +12,7 @@ in
test_inventory_a = test_inventory_a =
let let
compiled = buildInventory { compiled = buildInventory {
flakeInputs = { };
inventory = { inventory = {
machines = { machines = {
A = { }; A = { };
@@ -41,6 +42,7 @@ in
test_inventory_empty = test_inventory_empty =
let let
compiled = buildInventory { compiled = buildInventory {
flakeInputs = { };
inventory = { }; inventory = { };
directory = ./.; directory = ./.;
}; };
@@ -53,6 +55,7 @@ in
test_inventory_role_resolve = test_inventory_role_resolve =
let let
compiled = buildInventory { compiled = buildInventory {
flakeInputs = { };
directory = ./.; directory = ./.;
inventory = { inventory = {
modules = clan-core.clanModules; modules = clan-core.clanModules;
@@ -111,6 +114,7 @@ in
test_inventory_tag_resolve = test_inventory_tag_resolve =
let let
configs = buildInventory { configs = buildInventory {
flakeInputs = { };
directory = ./.; directory = ./.;
inventory = { inventory = {
modules = clan-core.clanModules; modules = clan-core.clanModules;
@@ -151,6 +155,7 @@ in
test_inventory_multiple_roles = test_inventory_multiple_roles =
let let
configs = buildInventory { configs = buildInventory {
flakeInputs = { };
directory = ./.; directory = ./.;
inventory = { inventory = {
modules = clan-core.clanModules; modules = clan-core.clanModules;
@@ -177,6 +182,7 @@ in
test_inventory_module_doesnt_exist = test_inventory_module_doesnt_exist =
let let
configs = buildInventory { configs = buildInventory {
flakeInputs = { };
directory = ./.; directory = ./.;
inventory = { inventory = {
modules = clan-core.clanModules; modules = clan-core.clanModules;
@@ -203,6 +209,7 @@ in
test_inventory_role_doesnt_exist = test_inventory_role_doesnt_exist =
let let
configs = buildInventory { configs = buildInventory {
flakeInputs = { };
directory = ./.; directory = ./.;
inventory = { inventory = {
modules = clan-core.clanModules; modules = clan-core.clanModules;
@@ -230,6 +237,7 @@ in
test_inventory_tag_doesnt_exist = test_inventory_tag_doesnt_exist =
let let
configs = buildInventory { configs = buildInventory {
flakeInputs = { };
directory = ./.; directory = ./.;
inventory = { inventory = {
modules = clan-core.clanModules; modules = clan-core.clanModules;
@@ -258,6 +266,7 @@ in
test_inventory_disabled_service = test_inventory_disabled_service =
let let
configs = buildInventory { configs = buildInventory {
flakeInputs = { };
directory = ./.; directory = ./.;
inventory = { inventory = {
modules = clan-core.clanModules; modules = clan-core.clanModules;