2024-12-12 10:17:26 +01:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: EUPL-1.2
|
|
|
|
-->
|
|
|
|
|
2024-12-12 10:34:37 +01:00
|
|
|
# Integration of [reuse](https://reuse.software) with [Nix](https://lix.systems/)
|
2024-12-12 10:17:26 +01:00
|
|
|
|
|
|
|
## Features
|
|
|
|
|
2024-12-12 10:34:37 +01:00
|
|
|
- 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)
|
2024-12-12 10:17:26 +01:00
|
|
|
|
|
|
|
## Getting started
|
|
|
|
|
2024-12-12 10:34:37 +01:00
|
|
|
### `REUSE.toml` generation
|
2024-12-12 10:17:26 +01:00
|
|
|
|
2024-12-12 10:34:37 +01:00
|
|
|
#### npins
|
|
|
|
|
|
|
|
1. Add `nix-reuse` to your sources:
|
2024-12-12 10:17:26 +01:00
|
|
|
|
|
|
|
```bash
|
2024-12-12 10:34:37 +01:00
|
|
|
npins add git https://git.dgnum.eu/DGNum/nix-reuse
|
2024-12-12 10:17:26 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
2. Integrate workflows to `shell.nix`:
|
|
|
|
|
|
|
|
```nix
|
|
|
|
let
|
|
|
|
sources = import ./npins;
|
2024-12-12 10:34:37 +01:00
|
|
|
reuse = (import sources.nix-reuse { }).install {
|
|
|
|
defaultLicense = "EUPL-1.2";
|
|
|
|
defaultCopyright = "Jane Doe <jane.doe@example.com>";
|
|
|
|
|
|
|
|
annotations = [
|
|
|
|
{
|
|
|
|
path = [
|
|
|
|
".envrc"
|
|
|
|
".gitignore"
|
|
|
|
"REUSE.toml"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
{
|
|
|
|
path = "npins/*";
|
|
|
|
license = "EUPL-1.2";
|
|
|
|
copyright = "The [npins](https://github.com/andir/npins) contributors";
|
|
|
|
}
|
|
|
|
];
|
2024-12-12 10:17:26 +01:00
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
with (import sources.nixpkgs { });
|
|
|
|
|
|
|
|
mkShell {
|
|
|
|
packages = [ ... ];
|
|
|
|
|
2024-12-12 10:34:37 +01:00
|
|
|
inherit (reuse) shellHook;
|
2024-12-12 10:17:26 +01:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-12-12 10:34:37 +01:00
|
|
|
#### Options
|
|
|
|
|
|
|
|
- `defaultLicense`: the default license SPDX identifier used accross the project.
|
|
|
|
- `defaultCopyright`: the default copyright text used accross the project.
|
2024-12-12 10:45:46 +01:00
|
|
|
- `downloadLicenses`: whether to download automatically the missing licenses detectd in the project.
|
2024-12-12 10:34:37 +01:00
|
|
|
- `annotations`: The list of [annotations](https://reuse.software/spec-3.3/#reusetoml) for this project
|
|
|
|
|
|
|
|
### reuse git-hook
|
2024-12-12 10:17:26 +01:00
|
|
|
|
2024-12-12 10:34:37 +01:00
|
|
|
#### npins
|
2024-12-12 10:17:26 +01:00
|
|
|
|
2024-12-12 10:34:37 +01:00
|
|
|
1. Add `nix-reuse` to your sources:
|
2024-12-12 10:17:26 +01:00
|
|
|
|
2024-12-12 10:34:37 +01:00
|
|
|
```bash
|
|
|
|
npins add git https://git.dgnum.eu/DGNum/nix-reuse
|
|
|
|
```
|
|
|
|
|
|
|
|
2. Integrate reuse to git hooks:
|
2024-12-12 10:17:26 +01:00
|
|
|
|
|
|
|
```nix
|
2024-12-12 10:34:37 +01:00
|
|
|
let
|
|
|
|
sources = import ./npins;
|
|
|
|
git-checks = (import sources."git-hooks.nix").run {
|
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
hooks = {
|
|
|
|
reuse = (import sources.nix-reuse { }).hook {
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
};
|
2024-12-12 10:17:26 +01:00
|
|
|
};
|
2024-12-12 10:34:37 +01:00
|
|
|
in
|
2024-12-12 10:17:26 +01:00
|
|
|
|
2024-12-12 10:34:37 +01:00
|
|
|
with (import sources.nixpkgs { });
|
2024-12-12 10:17:26 +01:00
|
|
|
|
2024-12-12 10:34:37 +01:00
|
|
|
mkShell {
|
|
|
|
packages = [ ... ];
|
|
|
|
|
|
|
|
inherit (git-checks) shellHook;
|
|
|
|
}
|
|
|
|
```
|