Skip to content

Commit

Permalink
refactor: GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dvtfl committed Jun 9, 2024
1 parent 9c653e7 commit d90b414
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 125 deletions.
75 changes: 0 additions & 75 deletions .github/workflows/build.yml

This file was deleted.

61 changes: 61 additions & 0 deletions .github/workflows/nix-github-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Nix Flake actions

on:
pull_request:
push:
branches:
- master
- main

jobs:

check-eval:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install nix
uses: cachix/install-nix-action@v27
with:
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Show nixpkgs version
run: nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
- name: Check evaluation
run: |
nix-env -f . -qa \* --meta --xml \
--allowed-uris https://static.rust-lang.org \
--option restrict-eval true \
--option allow-import-from-derivation true \
--drv-path --show-trace \
-I nixpkgs=$(nix-instantiate --find-file nixpkgs) \
-I $PWD
nix-matrix:
needs: check-eval
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- id: set-matrix
name: Generate Nix Matrix
run: |
set -Eeu
matrix="$(nix eval --json '.#githubActions.matrix')"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
nix-build:
needs: nix-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- name: Build "${{ matrix.attr }}"
- run: nix build -L ".#${{ matrix.attr }}"
- name: Trigger NUR update
- run: curl -XPOST "https://nur-update.nix-community.org/update?repo=mur"
70 changes: 51 additions & 19 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 69 additions & 31 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,83 @@
};

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
stable.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-parts.url = "github:hercules-ci/flake-parts";

nix-github-actions = {
url = "github:nix-community/nix-github-actions";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = inputs@{ flake-parts, ... }:
outputs =
inputs@{ self, flake-parts, ... }:
let
overlays = final: prev: import ./overlay.nix final prev;
lib = inputs.nixpkgs.lib;
in
flake-parts.lib.mkFlake { inherit inputs; }
{
flake = {
flake-parts.lib.mkFlake { inherit inputs; } {

flake =

{
overlays.default = overlays;
githubActions =
let
filterPackages =
pkgs:
lib.filterAttrs (
name: pkg:
!(pkg.meta.broken or false) && (pkg.meta.license.free or true) && !(pkg.preferLocalBuild or false)
) pkgs;
cacheablePkgs = {
# aarch64-linux = filterPackages self.packages.aarch64-linux; # FIX:
# x86_64-darwin = filterPackages self.packages.x86_64-darwin;
x86_64-linux = filterPackages self.packages.x86_64-linux;
};
in
inputs.nix-github-actions.lib.mkGithubMatrix { checks = cacheablePkgs; };
};

systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
perSystem = { config, self', inputs', pkgs, system, lib, ... }:
let
mur = import ./default.nix { inherit pkgs; };
packages = lib.filterAttrs (_: v: lib.isDerivation v) mur;
list-repo = pkgs.callPackage ./list-repo.nix { inherit pkgs packages overlays; }; # the binary is called "mur"
in
{
legacyPackages = mur;
packages = packages // {
default = list-repo;
};

devShells.default = pkgs.mkShell {
buildInputs = [
# Package that creates env with all packages. Pretty self-explanatory.
pkgs.buildEnv
{
name = "mur";
paths = (builtins.attrValues packages) ++
[ list-repo ];
}
];
};
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
perSystem =
{
config,
self',
inputs',
pkgs,
system,
lib,
...
}:
let
mur = import ./default.nix { inherit pkgs; };
packages = lib.filterAttrs (_: v: lib.isDerivation v) mur;
list-repo = pkgs.callPackage ./list-repo.nix { inherit pkgs packages overlays; }; # the binary is called "mur"
in
{
legacyPackages = mur;

packages = packages // {
default = list-repo;
};
};
}

devShells.default = pkgs.mkShell {
buildInputs = [
# Package that creates env with all packages. Pretty self-explanatory.
pkgs.buildEnv
{
name = "mur";
paths = (builtins.attrValues packages) ++ [ list-repo ];
}
];
};
};
};
}

0 comments on commit d90b414

Please sign in to comment.