No description
Find a file
2024-11-19 15:56:20 +01:00
modules chore: Tweak the generation, to remove one indirection 2024-11-11 21:54:18 +01:00
npins feat(nix-actions): Initial version 2024-11-11 16:32:04 +01:00
.envrc feat(nix-actions): Initial version 2024-11-11 16:32:04 +01:00
.gitignore feat(nix-actions): Initial version 2024-11-11 16:32:04 +01:00
default.nix feat: Add a trivial lib 2024-11-19 15:56:20 +01:00
LICENSE Initial commit 2024-11-10 16:33:05 +01:00
README.md feat: Update README 2024-11-11 21:53:52 +01:00
shell.nix feat(nix-actions): Initial version 2024-11-11 16:32:04 +01:00

Integration of Forgejo/Gitea/GitHub workflows with Nix

Features

  • Provides checked workflow files thanks to action-validator
  • You can use all the power of Nix to declare workflows: genAttrs, readDir, ...

Getting started

npins

  1. Add nix-actions to your sources:
npins add git https://git.dgnum.eu/DGNum/nix-actions
  1. Integrate workflows to shell.nix:
let
    sources = import ./npins;
    workflows = (import sources.nix-actions { }).install {
        src = ./.;

        workflows.build = {
            name = "Build something";
            on = [ "push" ];
            ...
        };
    };
in

with (import sources.nixpkgs { });

mkShell {
    packages = [ ... ];

    inherit (workflows) shellHook;
}

Options

  • src: the root of the project, required for the workflows checks
  • platform: one of forgejo, gitea, or github, this will impact the location of the installed workflow files. Defaults to forgejo.
  • removeUnknown: whether to remove workflow files not created by nix-actions. Defaults to true.

Ensuring all workflows are up to date

Simply add a new workflow for this !

{
  name = "Check workflows";
  on = [
    "pull_request"
    "push"
  ];

  jobs = {
    check_workflows = {
      runs-on = "nix";
      steps = [
        { uses = "actions/checkout@v3"; }
        {
          name = "Check that the workflows are up to date";
          run = "nix-shell --run '[ $(git status --porcelain | wc -l) -eq 0 ]'";
        }
      ];
    };
  };
}

Examples

The main example is used by the DGNum infrastructure, workflows are defined in https://git.dgnum.eu/DGNum/infrastructure/src/branch/main/workflows . Be aware that the runners used there are a bit funky and already come with Lix installed (c.f. https://git.hubrecht.ovh/hubrecht/nix-modules/src/branch/main/services/forgejo-nix-runners/default.nix ).