Skip to content

Commit

Permalink
treewide: rework CI, allow skipping some hosts
Browse files Browse the repository at this point in the history
some of the hosts aren't actually deployed that often, while building
their configuration is long (eg. kernel rebuilds).
  • Loading branch information
arachnist committed Jul 29, 2024
1 parent 5bf73fc commit 0320d68
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 10 deletions.
18 changes: 11 additions & 7 deletions .ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ set -x
while read hostOutput; do
echo "${hostOutput}"
nixos-rebuild build --verbose --flake ".#${hostOutput}"
done < <(nix eval -I nixpkgs=$(nix flake metadata nixpkgs --json | jq -r .path) --raw --impure --expr '
with import <nixpkgs> { };
(lib.strings.concatStringsSep "\n"
(lib.mapAttrsToList (n: v: n)
(lib.attrsets.filterAttrs (n: v: v.pkgs.system == pkgs.system)
(builtins.getFlake(builtins.toString ./.)).outputs.nixosConfigurations)))
'; echo "")
done < <(nix eval --raw --impure --expr '
let
hosts = (import ./meta.nix).hosts;
filterHosts = hosts: (
builtins.filter (h: !hosts.${h}.ciSkip && hosts.${h}.system == builtins.currentSystem)
(builtins.attrNames hosts)
);
in
builtins.concatStringsSep "\n" (filterHosts hosts)
'; echo ""
)
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ jobs:
echo -n "matrix="
nix eval --raw --impure --expr '
let
f = configs: builtins.groupBy (n: configs.${n}.pkgs.system) (builtins.attrNames configs);
groupHosts = hosts:
builtins.groupBy (n: hosts.${n}.system)
(builtins.filter (h: !hosts.${h}.ciSkip)
(builtins.attrNames hosts));
hosts = (import ./meta.nix).hosts;
in
builtins.toJSON (f (builtins.getFlake(builtins.toString ./.)).outputs.nixosConfigurations)'
builtins.toJSON (groupHosts hosts)'
echo ""
} >> "$GITHUB_OUTPUT"
Expand Down
1 change: 1 addition & 0 deletions meta.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ in {
hosts = builtins.mapAttrs (name: value:
{
targetHost = name + "." + defaultDomain;
ciSkip = false;
}
// builtins.fromJSON (builtins.readFile (./nixos/. + "/${name}/meta.json")))
(builtins.readDir ./nixos);
Expand Down
3 changes: 2 additions & 1 deletion nixos/akamanto/meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"publicKey": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKb4i+BmIb2wiT4y5uWsCOmSo1dRp6Ql36toUsRHN6pC",
"ciSkip": true,
"system": "aarch64-linux"
}
}
1 change: 1 addition & 0 deletions nixos/amanojaku/meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"publicKey": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE4rFVYs5t4uBpZK9kmDQkr9ONLDE41jOCP/tMmM+SMb",
"ciSkip": true,
"system": "x86_64-linux"
}
1 change: 1 addition & 0 deletions nixos/kamaitachi/meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"publicKey": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKb4i+BmIb2wiT4y5uWsCOmSo1dRp6Ql36toUsRHN6pC",
"ciSkip": true,
"system": "aarch64-linux"
}
1 change: 1 addition & 0 deletions nixos/khas/meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"publicKey": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAs/jPJBvAVB+BgkywNDSUqcuqzFaWTmBn5hTnKm1wjF",
"ciSkip": true,
"system": "x86_64-linux"
}

0 comments on commit 0320d68

Please sign in to comment.