Skip to content

Commit

Permalink
make ci better
Browse files Browse the repository at this point in the history
thanks getchoo :3
  • Loading branch information
uku3lig committed Jan 7, 2024
1 parent f591dc8 commit e2e5339
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 62 deletions.
28 changes: 5 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
name: build overlay
name: build packages

on:
push:

jobs:
eval:
name: eval flake
runs-on: ubuntu-latest

outputs:
matrix: ${{ steps.eval.outputs.matrix }}

steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v9

- name: evaluate packages
id: eval
run: echo "matrix=$(nix eval --json .#ghaMatrix)" >> "$GITHUB_OUTPUT"

build:
needs: eval
strategy:
matrix: ${{ fromJson(needs.eval.outputs.matrix) }}

name: build ${{ matrix.pkg }}
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
Expand All @@ -38,4 +18,6 @@ jobs:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: build
run: nix build -L --accept-flake-config .#${{ matrix.pkg }}
run: |
nix run --inputs-from . --override-input nixpkgs nixpkgs github:Mic92/nix-fast-build -- \
--no-nom --skip-cached --option accept-flake-config true --flake '.#hydraJobs'
44 changes: 5 additions & 39 deletions ci.nix
Original file line number Diff line number Diff line change
@@ -1,45 +1,11 @@
{
self,
inputs,
lib,
...
}: {
perSystem = {
lib,
pkgs,
system,
...
}: {
packages = let
overlay = lib.fix (final: (import ./exprs/overlay.nix final pkgs));

# do not include a package if it's not available on the system or if it's broken
isValid = _: v:
lib.elem pkgs.system (v.meta.platforms or [pkgs.system]) && !(v.meta.broken or false);
in
lib.filterAttrs isValid overlay;
flake.hydraJobs = let
mapCfgsToDerivs = lib.mapAttrs (_: cfg: cfg.activationPackage or cfg.config.system.build.toplevel);
in {
nixosConfigurations = mapCfgsToDerivs self.nixosConfigurations;
};

flake.ghaMatrix.include = let
inherit (inputs.nixpkgs) lib;

platforms = {
"x86_64-linux" = {
os = "ubuntu-latest";
};
};
in
lib.pipe platforms [
builtins.attrNames # get systems
(systems: lib.getAttrs systems self.packages) # get packages of each system
(lib.mapAttrs (_: builtins.attrNames)) # keep only the name of each package

# map each package in each system to an attrset
(lib.mapAttrsToList (system:
builtins.map (pkg: {
inherit (platforms.${system}) os;
pkg = "packages.${system}.${pkg}";
})))

lib.flatten
];
}

0 comments on commit e2e5339

Please sign in to comment.