diff --git a/README.md b/README.md index e38e368..1610dcc 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,23 @@ SPDX-FileCopyrightText: 2024 Tom Hubrecht SPDX-License-Identifier: EUPL-1.2 --> -# Integration of [Forgejo](https://forgejo.org/docs/latest/user/actions/)/[Gitea](https://docs.gitea.com/usage/actions/overview)/[GitHub](https://docs.github.com/en/actions/writing-workflows) workflows with [Nix](https://lix.systems/) +# Integration of [reuse](https://reuse.software) with [Nix](https://lix.systems/) ## Features -- Provides checked workflow files thanks to [action-validator](https://github.com/mpalmer/action-validator) -- You can use all the power of Nix to declare workflows: `genAttrs`, `readDir`, ... +- Provides a shell hook to generate the `REUSE.toml` file +- Provides a hook to be used with [git-hooks.nix](https://github.com/cachix/git-hooks.nix) ## Getting started -### npins +### `REUSE.toml` generation -1. Add `nix-actions` to your sources: +#### npins + +1. Add `nix-reuse` to your sources: ```bash -npins add git https://git.dgnum.eu/DGNum/nix-actions +npins add git https://git.dgnum.eu/DGNum/nix-reuse ``` 2. Integrate workflows to `shell.nix`: @@ -26,13 +28,64 @@ npins add git https://git.dgnum.eu/DGNum/nix-actions ```nix let sources = import ./npins; - workflows = (import sources.nix-actions { }).install { + reuse = (import sources.nix-reuse { }).install { + defaultLicense = "EUPL-1.2"; + defaultCopyright = "Jane Doe "; + + annotations = [ + { + path = [ + ".envrc" + ".gitignore" + "REUSE.toml" + ]; + } + { + path = "npins/*"; + license = "EUPL-1.2"; + copyright = "The [npins](https://github.com/andir/npins) contributors"; + } + ]; + }; +in + +with (import sources.nixpkgs { }); + +mkShell { + packages = [ ... ]; + + inherit (reuse) shellHook; +} +``` + +#### Options + +- `defaultLicense`: the default license SPDX identifier used accross the project. +- `defaultCopyright`: the default copyright text used accross the project. +- `annotations`: The list of [annotations](https://reuse.software/spec-3.3/#reusetoml) for this project + +### reuse git-hook + +#### npins + +1. Add `nix-reuse` to your sources: + +```bash +npins add git https://git.dgnum.eu/DGNum/nix-reuse +``` + +2. Integrate reuse to git hooks: + +```nix +let + sources = import ./npins; + git-checks = (import sources."git-hooks.nix").run { src = ./.; - workflows.build = { - name = "Build something"; - on = [ "push" ]; - ... + hooks = { + reuse = (import sources.nix-reuse { }).hook { + enable = true; + }; }; }; in @@ -42,44 +95,6 @@ with (import sources.nixpkgs { }); mkShell { packages = [ ... ]; - inherit (workflows) shellHook; + inherit (git-checks) 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 ! - -```nix -{ - 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 ).