diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7b4e174..a946ac0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -10,3 +10,30 @@ jobs: - uses: actions/checkout@v3 - uses: ./.github/actions/install-nix - run: nix flake check + + matrix: + runs-on: ubuntu-latest + outputs: + aarch64-darwin: ${{ steps.generate_matrix.outputs.aarch64-darwin }} + aarch64-linux: ${{ steps.generate_matrix.outputs.aarch64-linux }} + x86_64-linux: ${{ steps.generate_matrix.outputs.x86_64-linux }} + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/install-nix + - id: generate_matrix + run: | + nix eval --raw .#github-matrix >> $GITHUB_OUTPUT + + build-x86_64-linux: + runs-on: ubuntu-latest + needs: [matrix] + if: ${{ needs.matrix.outputs.x86_64-linux != '[]' && needs.matrix.outputs.x86_64-linux != '' }} + strategy: + fail-fast: false + matrix: + output: ${{ fromJson(needs.matrix.outputs.x86_64-linux )}} + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/install-nix + - name: Build output + run: nix build .#${{ matrix.output }} -L diff --git a/effects.nix b/effects.nix index 670955c..06a5f75 100644 --- a/effects.nix +++ b/effects.nix @@ -2,8 +2,33 @@ config, lib, withSystem, + self, ... -}: { +}: let + collectFlakeOutputs = { + config, + pkgs, + }: let + inherit (pkgs) lib; + collectDrvs = prefix: attrs: let + drvs = lib.pipe attrs [ + (lib.filterAttrs (_: lib.isDerivation)) + (lib.mapAttrsToList (name: drv: { + name = lib.concatStringsSep "." (prefix ++ [name]); + inherit drv; + })) + ]; + recursed = lib.pipe attrs [ + (lib.filterAttrs (_: val: + (!lib.isDerivation val) && (lib.isAttrs val) && (val.recurseForDerivations or true))) + (lib.mapAttrsToList (name: collectDrvs (prefix ++ [name]))) + ]; + in + drvs ++ (lib.flatten recursed); + rootOutputs = builtins.removeAttrs config.onPush.default.outputs ["effects"]; + in + collectDrvs [] rootOutputs; +in { defaultEffectSystem = "aarch64-linux"; hercules-ci = { @@ -21,23 +46,10 @@ hci-effects, ... }: let - collectDrvs = prefix: attrs: let - drvs = lib.pipe attrs [ - (lib.filterAttrs (_: lib.isDerivation)) - (lib.mapAttrsToList (name: drv: { - name = "${prefix}.${name}"; - inherit drv; - })) - ]; - recursed = lib.pipe attrs [ - (lib.filterAttrs (_: val: - (!lib.isDerivation val) && (lib.isAttrs val) && (val.recurseForDerivations or true))) - (lib.mapAttrsToList (name: collectDrvs "${prefix}.${name}")) - ]; - in - drvs ++ (lib.flatten recursed); - rootOutputs = builtins.removeAttrs herculesCI.config.onPush.default.outputs ["effects"]; - collected = collectDrvs "outputs" rootOutputs; + collected = collectFlakeOutputs { + inherit (herculesCI) config; + inherit pkgs; + }; cachixCommands = lib.concatMapStringsSep "\n" @@ -61,4 +73,28 @@ }; }; }; + + perSystem = { + pkgs, + lib, + ... + }: rec { + legacyPackages.outputsList = let + config = self.herculesCI { + primaryRepo = {}; + herculesCI = {}; + }; + in + collectFlakeOutputs {inherit config pkgs;}; + + legacyPackages.github-matrix = let + systems = lib.groupBy ({drv, ...}: drv.system) legacyPackages.outputsList; + in + lib.concatMapStringsSep "\n" ({ + name, + value, + }: '' + ${name}=${builtins.toJSON (map (d: d.name) value)} + '') (lib.attrsToList systems); + }; } diff --git a/modules/system/common/hercules.nix b/modules/system/common/hercules.nix index c00fb57..d084ba1 100644 --- a/modules/system/common/hercules.nix +++ b/modules/system/common/hercules.nix @@ -17,28 +17,33 @@ in { inherit options; - config = lib.mkIf false /* config.common.hercules.enable */ { - age.secrets.hercules-token = { - file = ../../../secrets/hercules-token.age; - owner = herculesUser; - }; - age.secrets.hercules-cache = { - file = ../../../secrets/hercules-cache.age; - owner = herculesUser; - }; - age.secrets.hercules-secrets = { - file = ../../../secrets/hercules-secrets.age; - owner = herculesUser; - }; + config = + lib.mkIf false + /* + config.common.hercules.enable + */ + { + age.secrets.hercules-token = { + file = ../../../secrets/hercules-token.age; + owner = herculesUser; + }; + age.secrets.hercules-cache = { + file = ../../../secrets/hercules-cache.age; + owner = herculesUser; + }; + age.secrets.hercules-secrets = { + file = ../../../secrets/hercules-secrets.age; + owner = herculesUser; + }; - services.hercules-ci-agent = { - enable = true; - settings = { - clusterJoinTokenPath = config.age.secrets.hercules-token.path; - concurrentTasks = lib.mkDefault 4; - binaryCachesPath = config.age.secrets.hercules-cache.path; - secretsJsonPath = config.age.secrets.hercules-secrets.path; + services.hercules-ci-agent = { + enable = true; + settings = { + clusterJoinTokenPath = config.age.secrets.hercules-token.path; + concurrentTasks = lib.mkDefault 4; + binaryCachesPath = config.age.secrets.hercules-cache.path; + secretsJsonPath = config.age.secrets.hercules-secrets.path; + }; }; }; - }; }