initial gha implementation
This commit is contained in:
parent
941af36317
commit
eb269e7a67
3 changed files with 107 additions and 39 deletions
27
.github/workflows/build.yaml
vendored
27
.github/workflows/build.yaml
vendored
|
@ -10,3 +10,30 @@ jobs:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: ./.github/actions/install-nix
|
- uses: ./.github/actions/install-nix
|
||||||
- run: nix flake check
|
- 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
|
||||||
|
|
72
effects.nix
72
effects.nix
|
@ -2,8 +2,33 @@
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
withSystem,
|
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";
|
defaultEffectSystem = "aarch64-linux";
|
||||||
|
|
||||||
hercules-ci = {
|
hercules-ci = {
|
||||||
|
@ -21,23 +46,10 @@
|
||||||
hci-effects,
|
hci-effects,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
collectDrvs = prefix: attrs: let
|
collected = collectFlakeOutputs {
|
||||||
drvs = lib.pipe attrs [
|
inherit (herculesCI) config;
|
||||||
(lib.filterAttrs (_: lib.isDerivation))
|
inherit pkgs;
|
||||||
(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;
|
|
||||||
cachixCommands =
|
cachixCommands =
|
||||||
lib.concatMapStringsSep
|
lib.concatMapStringsSep
|
||||||
"\n"
|
"\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);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,28 +17,33 @@ in {
|
||||||
|
|
||||||
inherit options;
|
inherit options;
|
||||||
|
|
||||||
config = lib.mkIf false /* config.common.hercules.enable */ {
|
config =
|
||||||
age.secrets.hercules-token = {
|
lib.mkIf false
|
||||||
file = ../../../secrets/hercules-token.age;
|
/*
|
||||||
owner = herculesUser;
|
config.common.hercules.enable
|
||||||
};
|
*/
|
||||||
age.secrets.hercules-cache = {
|
{
|
||||||
file = ../../../secrets/hercules-cache.age;
|
age.secrets.hercules-token = {
|
||||||
owner = herculesUser;
|
file = ../../../secrets/hercules-token.age;
|
||||||
};
|
owner = herculesUser;
|
||||||
age.secrets.hercules-secrets = {
|
};
|
||||||
file = ../../../secrets/hercules-secrets.age;
|
age.secrets.hercules-cache = {
|
||||||
owner = herculesUser;
|
file = ../../../secrets/hercules-cache.age;
|
||||||
};
|
owner = herculesUser;
|
||||||
|
};
|
||||||
|
age.secrets.hercules-secrets = {
|
||||||
|
file = ../../../secrets/hercules-secrets.age;
|
||||||
|
owner = herculesUser;
|
||||||
|
};
|
||||||
|
|
||||||
services.hercules-ci-agent = {
|
services.hercules-ci-agent = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
clusterJoinTokenPath = config.age.secrets.hercules-token.path;
|
clusterJoinTokenPath = config.age.secrets.hercules-token.path;
|
||||||
concurrentTasks = lib.mkDefault 4;
|
concurrentTasks = lib.mkDefault 4;
|
||||||
binaryCachesPath = config.age.secrets.hercules-cache.path;
|
binaryCachesPath = config.age.secrets.hercules-cache.path;
|
||||||
secretsJsonPath = config.age.secrets.hercules-secrets.path;
|
secretsJsonPath = config.age.secrets.hercules-secrets.path;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue