From 0fbd142a16f1ed3b6576ca4b234c0121263859c3 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Mon, 25 Mar 2024 10:53:26 -0700 Subject: [PATCH] fix(ci): update system list --- .github/workflows/nodes.yml | 51 ++++++++++++++++++++++++++++++++++++ ci/actions-test.sh | 52 +++++++++++++++++++++++++++---------- ci/nix.nix | 1 + ci/nodes.nix | 4 +-- modules/system/access.nix | 5 ++-- 5 files changed, 96 insertions(+), 17 deletions(-) diff --git a/.github/workflows/nodes.yml b/.github/workflows/nodes.yml index 1f739642..0138d89f 100644 --- a/.github/workflows/nodes.yml +++ b/.github/workflows/nodes.yml @@ -436,6 +436,57 @@ jobs: command: ci-build-cache quiet: false stdin: ${{ runner.temp }}/ci.build.cache + utsuho: + name: nodes-utsuho + runs-on: ubuntu-latest + steps: + - id: checkout + name: git clone + uses: actions/checkout@v4 + with: + submodules: false + - id: nix-install + name: nix install + uses: arcnmx/ci/actions/nix/install@v0.7 + - id: ci-dirty + name: nix test dirty + uses: arcnmx/ci/actions/nix/run@v0.7 + with: + attrs: ci.job.utsuho.run.test + command: ci-build-dirty + quiet: false + stdout: ${{ runner.temp }}/ci.build.dirty + - id: ci-test + name: nix test build + uses: arcnmx/ci/actions/nix/run@v0.7 + with: + attrs: ci.job.utsuho.run.test + command: ci-build-realise + ignore-exit-code: true + quiet: false + stdin: ${{ runner.temp }}/ci.build.dirty + - env: + CI_EXIT_CODE: ${{ steps.ci-test.outputs.exit-code }} + id: ci-summary + name: nix test results + uses: arcnmx/ci/actions/nix/run@v0.7 + with: + attrs: ci.job.utsuho.run.test + command: ci-build-summarise + quiet: false + stdin: ${{ runner.temp }}/ci.build.dirty + stdout: ${{ runner.temp }}/ci.build.cache + - env: + CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }} + id: ci-cache + if: always() + name: nix test cache + uses: arcnmx/ci/actions/nix/run@v0.7 + with: + attrs: ci.job.utsuho.run.test + command: ci-build-cache + quiet: false + stdin: ${{ runner.temp }}/ci.build.cache name: nodes 'on': - push diff --git a/ci/actions-test.sh b/ci/actions-test.sh index b42e6119..4416f8f8 100644 --- a/ci/actions-test.sh +++ b/ci/actions-test.sh @@ -11,32 +11,58 @@ NIX_BUILD_ARGS=( --show-trace ) -for nfsystem in "${NF_NIX_SYSTEMS[@]}"; do +init_nfargs() { + nflinksuffix="$1" + shift + nfargs=( "${NIX_BUILD_ARGS[@]}" ) + if [[ -n "${NF_ACTIONS_TEST_OUTLINK-}" || -n "${NF_UPDATE_CACHIX_PUSH-}" ]]; then nfargs+=( - -o "${NF_ACTIONS_TEST_OUTLINK-result}-$nfsystem" + -o "${NF_ACTIONS_TEST_OUTLINK-result}$nflinksuffix" ) else nfargs+=( --no-link ) fi +} - echo "building ${nfsystem}..." >&2 - - nix build \ - "${NF_CONFIG_ROOT}#nixosConfigurations.${nfsystem}.config.system.build.toplevel" \ - "${nfargs[@]}" \ - "$@" - - if [[ -n "${NF_ACTIONS_TEST_GC-}" ]]; then - if [[ -n "${NF_UPDATE_CACHIX_PUSH-}" ]]; then - cachix push gensokyo-infrastructure "./${NF_ACTIONS_TEST_OUTLINK-result}-$nfsystem"*/ - rm -f "./${NF_ACTIONS_TEST_OUTLINK-result}-$nfsystem"* +nfgc() { + if [[ -n ${NF_ACTIONS_TEST_GC-} ]]; then + if [[ -n ${NF_UPDATE_CACHIX_PUSH-} ]]; then + cachix push gensokyo-infrastructure "./${NF_ACTIONS_TEST_OUTLINK-result}$nflinksuffix"*/ + rm -f "./${NF_ACTIONS_TEST_OUTLINK-result}$nflinksuffix"* fi nix-collect-garbage -d fi +} + +for nfsystem in "${NF_NIX_SYSTEMS[@]}"; do + nfinstallable="${NF_CONFIG_ROOT}#nixosConfigurations.${nfsystem}.config.system.build.toplevel" + init_nfargs "-$nfsystem" + + if [[ -n ${NF_ACTIONS_TEST_ASYNC-} ]]; then + NIX_BUILD_ARGS+=("$nfinstallable") + continue + fi + + echo "building ${nfsystem}..." >&2 + + nix build "$nfinstallable" \ + "${nfargs[@]}" \ + "$@" + + nfgc done + +if [[ -n ${NF_ACTIONS_TEST_ASYNC-} ]]; then + init_nfargs "" + nix build \ + "${nfargs[@]}" \ + "$@" + + nfgc +fi diff --git a/ci/nix.nix b/ci/nix.nix index e0b75f01..391ad4c1 100644 --- a/ci/nix.nix +++ b/ci/nix.nix @@ -5,6 +5,7 @@ "flake-cron.nix" ]; nixosSystems = [ + "ct" "hakurei" "reimu" "aya" diff --git a/ci/nodes.nix b/ci/nodes.nix index 5e7697a7..38240ec1 100644 --- a/ci/nodes.nix +++ b/ci/nodes.nix @@ -25,9 +25,9 @@ with lib; { }; jobs = let - enabledHosts = ["hakurei" "reimu" "aya" "tei" "litterbox" "keycloak" "mediabox" "ct"]; + inherit ((import ./nix.nix).ci) nixosSystems; in - mapAttrs' (k: nameValuePair "${k}") (genAttrs enabledHosts (host: { + mapAttrs' (k: nameValuePair "${k}") (genAttrs nixosSystems (host: { tasks.${host}.inputs = channels.nixfiles.nixosConfigurations.${host}.config.system.build.toplevel; })); diff --git a/modules/system/access.nix b/modules/system/access.nix index 6bf7fad9..7aaaff18 100644 --- a/modules/system/access.nix +++ b/modules/system/access.nix @@ -6,6 +6,7 @@ inputs, ... }: let + inherit (inputs.self) nixosConfigurations; inherit (inputs.self.lib) systems; inherit (inputs.self.lib.lib) domain; inherit (lib.options) mkOption mkEnableOption; @@ -94,8 +95,8 @@ in { inherit (cfg) hostnameForNetwork; systemFor = hostName: systems.${hostName}.config; systemForOrNull = hostName: systems.${hostName}.config or null; - nixosFor = hostName: (access.systemFor hostName).built.config; - nixosForOrNull = hostName: (access.systemForOrNull hostName).built.config or null; + nixosFor = hostName: nixosConfigurations.${hostName}.config or (access.systemFor hostName).built.config; + nixosForOrNull = hostName: nixosConfigurations.${hostName}.config or (access.systemForOrNull hostName).built.config or null; }; }; }