Merge pull request 'Ensure all clan modules are compatible with clan config
' (#123) from DavHau-clan-config into main
All checks were successful
build / test (push) Successful in 20s
All checks were successful
build / test (push) Successful in 20s
This commit is contained in:
commit
8c00a400a5
5
checks/flake-module.nix
Normal file
5
checks/flake-module.nix
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
imports = [
|
||||
./schema.nix
|
||||
];
|
||||
}
|
50
checks/schema.nix
Normal file
50
checks/schema.nix
Normal file
@ -0,0 +1,50 @@
|
||||
{ self, lib, inputs, ... }:
|
||||
let
|
||||
inherit (builtins)
|
||||
mapAttrs
|
||||
toJSON
|
||||
toFile
|
||||
;
|
||||
inherit (lib)
|
||||
mapAttrs'
|
||||
;
|
||||
clanLib = self.lib;
|
||||
clanModules = self.clanModules;
|
||||
|
||||
baseModule = {
|
||||
imports =
|
||||
(import (inputs.nixpkgs + "/nixos/modules/module-list.nix"))
|
||||
++ [{
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
}];
|
||||
};
|
||||
|
||||
optionsFromModule = module:
|
||||
let
|
||||
evaled = lib.evalModules {
|
||||
modules = [ module baseModule ];
|
||||
};
|
||||
in
|
||||
evaled.options.clan.networking;
|
||||
|
||||
clanModuleSchemas = mapAttrs (_: module: clanLib.jsonschema.parseOptions (optionsFromModule module)) clanModules;
|
||||
|
||||
in
|
||||
{
|
||||
perSystem = { pkgs, ... }:
|
||||
let
|
||||
mkTest = name: schema: pkgs.runCommand "schema-${name}" { } ''
|
||||
${pkgs.check-jsonschema}/bin/check-jsonschema \
|
||||
--check-metaschema ${toFile "schema-${name}" (toJSON schema)}
|
||||
touch $out
|
||||
'';
|
||||
in
|
||||
{
|
||||
checks = mapAttrs'
|
||||
(name: schema: {
|
||||
name = "schema-${name}";
|
||||
value = mkTest name schema;
|
||||
})
|
||||
clanModuleSchemas;
|
||||
};
|
||||
}
|
@ -22,7 +22,7 @@
|
||||
"aarch64-linux"
|
||||
];
|
||||
imports = [
|
||||
# ./checks/flake-module.nix
|
||||
./checks/flake-module.nix
|
||||
./devShell.nix
|
||||
./formatter.nix
|
||||
./templates/flake-module.nix
|
||||
|
@ -29,10 +29,19 @@ let
|
||||
];
|
||||
|
||||
checkPython = python3.withPackages (_ps: dependencies ++ testDependencies);
|
||||
|
||||
# - vendor the jsonschema nix lib (copy instead of symlink).
|
||||
# - lib.cleanSource prevents unnecessary rebuilds when `self` changes.
|
||||
source = runCommand "clan-cli-source" { } ''
|
||||
cp -r ${lib.cleanSource ./.} $out
|
||||
chmod -R +w $out
|
||||
rm $out/clan_cli/config/jsonschema
|
||||
cp -r ${lib.cleanSource (self + /lib/jsonschema)} $out/clan_cli/config/jsonschema
|
||||
'';
|
||||
in
|
||||
python3.pkgs.buildPythonPackage {
|
||||
name = "clan-cli";
|
||||
src = lib.cleanSource ./.;
|
||||
src = source;
|
||||
format = "pyproject";
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
@ -40,16 +49,11 @@ python3.pkgs.buildPythonPackage {
|
||||
];
|
||||
propagatedBuildInputs = dependencies;
|
||||
|
||||
preBuild = ''
|
||||
rm ./clan_cli/config/jsonschema
|
||||
cp -r ${self}/lib/jsonschema ./clan_cli/config/jsonschema
|
||||
'';
|
||||
|
||||
passthru.tests = {
|
||||
clan-mypy = runCommand "clan-mypy" { } ''
|
||||
cp -r ${self} ./flake
|
||||
chmod +w -R ./flake
|
||||
cd ./flake/pkgs/clan-cli
|
||||
cp -r ${source} ./src
|
||||
chmod +w -R ./src
|
||||
cd ./src
|
||||
${checkPython}/bin/mypy .
|
||||
touch $out
|
||||
'';
|
||||
@ -57,9 +61,9 @@ python3.pkgs.buildPythonPackage {
|
||||
{
|
||||
nativeBuildInputs = [ age zerotierone bubblewrap sops nix ];
|
||||
} ''
|
||||
cp -r ${self} ./flake
|
||||
chmod +w -R ./flake
|
||||
cd ./flake/pkgs/clan-cli
|
||||
cp -r ${source} ./src
|
||||
chmod +w -R ./src
|
||||
cd ./src
|
||||
${checkPython}/bin/python -m pytest ./tests
|
||||
touch $out
|
||||
'';
|
||||
|
Loading…
Reference in New Issue
Block a user