clan-config: init

- nixos-modules to jsonschema converter
- nix unit testing via adisbladis/nix-unit
- clan config: configuration CLI for nixos-modules
This commit is contained in:
DavHau
2023-08-02 20:04:16 +02:00
parent 5268ecb595
commit b88ac7a2bf
12 changed files with 668 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
{ self, ... }: {
perSystem = { self', pkgs, ... }: {
perSystem = { inputs', self', pkgs, ... }: {
devShells.clan = pkgs.callPackage ./shell.nix {
inherit self;
inherit (self'.packages) clan;
@@ -18,14 +18,34 @@
openssh
sshpass
zbar
tor
sops
age;
# Override license so that we can build zerotierone without
tor;
# Override license so that we can build zerotierone without
# having to re-import nixpkgs.
zerotierone = pkgs.zerotierone.overrideAttrs (_old: { meta = { }; });
## End optional dependencies
};
checks = self'.packages.clan.tests;
# check if the `clan config` example jsonschema and data is valid
checks.clan-config-example-schema-valid = pkgs.runCommand "clan-config-example-schema-valid" { } ''
echo "Checking that example-schema.json is valid"
${pkgs.check-jsonschema}/bin/check-jsonschema \
--check-metaschema ${./.}/tests/config/example-schema.json
echo "Checking that example-data.json is valid according to example-schema.json"
${pkgs.check-jsonschema}/bin/check-jsonschema \
--schemafile ${./.}/tests/config/example-schema.json \
${./.}/tests/config/example-data.json
touch $out
'';
# check if the `clan config` nix jsonschema converter unit tests succeed
checks.clan-config-nix-unit-tests = pkgs.runCommand "clan-edit-unit-tests" { } ''
export NIX_PATH=nixpkgs=${pkgs.path}
${inputs'.nix-unit.packages.nix-unit}/bin/nix-unit \
${./.}/tests/config/test.nix \
--eval-store $(realpath .)
touch $out
'';
};
}