Expose and use checks for vmOptions and nixosConfigurations
All checks were successful
/ check-pre-commit (pull_request) Successful in 15s
/ check-data-model (pull_request) Successful in 35s
/ check-mastodon (pull_request) Successful in 22s
/ check-peertube (pull_request) Successful in 21s
/ check-panel (pull_request) Successful in 1m31s
/ check-deployment-basic (pull_request) Successful in 34s
/ check-deployment-cli (pull_request) Successful in 43s
/ check-deployment-panel (pull_request) Successful in 1m52s
/ check-resources (pull_request) Successful in 4m12s

This commit is contained in:
Nicolas Jeannerod 2025-07-31 00:36:50 +02:00
parent 6ec14e4a75
commit 9d539d790d
Signed by: Niols
GPG key ID: 35DB9EC8886E1CB8
2 changed files with 50 additions and 9 deletions

View file

@ -69,9 +69,16 @@ jobs:
- uses: actions/checkout@v4
- run: |
set -euC
echo ==================== [ VM Options ] ====================
machines=$(nix eval --impure --raw --expr 'with builtins; toString (attrNames (getFlake (toString ./.)).vmOptions)')
for machine in $machines; do
echo ~~~~~~~~~~~~~~~~~~~~~: $machine :~~~~~~~~~~~~~~~~~~~~~
nix build .#checks.x86_64-linux.vmOptions-$machine
done
echo
echo ==================== [ NixOS Configurations ] ====================
machines=$(nix eval --impure --raw --expr 'with builtins; toString (attrNames (getFlake (toString ./.)).nixosConfigurations)')
for machine in $machines; do
echo ==================== [ $machine ] ====================
nix eval .#vmOptions.$machine
nix build .#nixosConfigurations.$machine.config.system.build.toplevel
echo ~~~~~~~~~~~~~~~~~~~~~: $machine :~~~~~~~~~~~~~~~~~~~~~
nix build .#checks.x86_64-linux.nixosConfigurations-$machine
done

View file

@ -14,6 +14,10 @@ let
mkOption
evalModules
filterAttrs
attrsToList
map
listToAttrs
deepSeq
;
inherit (lib.attrsets) genAttrs;
@ -160,6 +164,13 @@ let
machines = listSubdirectories ../machines/dev;
testMachines = listSubdirectories ../machines/operator;
nixosConfigurations =
genAttrs machines (makeConfiguration false)
// genAttrs testMachines (makeConfiguration true);
vmOptions =
filterAttrs (_: value: value != null) # Filter out non-Fediversity VMs
(genAttrs machines (makeVmOptions false) // genAttrs testMachines (makeVmOptions true));
in
{
_class = "flake";
@ -183,10 +194,33 @@ in
)
);
};
flake.nixosConfigurations =
genAttrs machines (makeConfiguration false)
// genAttrs testMachines (makeConfiguration true);
flake.vmOptions =
filterAttrs (_: value: value != null) # Filter out non-Fediversity VMs
(genAttrs machines (makeVmOptions false) // genAttrs testMachines (makeVmOptions true));
flake = { inherit nixosConfigurations vmOptions; };
perSystem =
{ pkgs, ... }:
{
checks =
listToAttrs (
map (
{ name, value }:
{
name = "nixosConfigurations-${name}";
value = value.config.system.build.toplevel;
}
) (attrsToList nixosConfigurations)
)
// listToAttrs (
map (
{ name, value }:
{
name = "vmOptions-${name}";
## Check that VM options builds/evaluates correctly. `deepSeq e1
## e2` evaluates `e1` strictly in depth before returning `e2`. We
## use this trick because checks need to be derivations, which VM
## options are not.
value = deepSeq value pkgs.hello;
}
) (attrsToList vmOptions)
);
};
}