feat(nix-reuse): Add downloadLicenses option

When set to true, entering the shell will download all missing licenses
from the project
This commit is contained in:
Tom Hubrecht 2024-12-12 10:45:46 +01:00
parent 6fb00a6f15
commit 139caccebb
Signed by: thubrecht
SSH key fingerprint: SHA256:CYNvFo44Ar9qCNnWNnvJVhs0QXO9AZjOLlPeWcSij3Q
3 changed files with 16 additions and 0 deletions

View file

@ -62,6 +62,7 @@ mkShell {
- `defaultLicense`: the default license SPDX identifier used accross the project. - `defaultLicense`: the default license SPDX identifier used accross the project.
- `defaultCopyright`: the default copyright text used accross the project. - `defaultCopyright`: the default copyright text used accross the project.
- `downloadLicenses`: whether to download automatically the missing licenses detectd in the project.
- `annotations`: The list of [annotations](https://reuse.software/spec-3.3/#reusetoml) for this project - `annotations`: The list of [annotations](https://reuse.software/spec-3.3/#reusetoml) for this project
### reuse git-hook ### reuse git-hook

View file

@ -65,6 +65,8 @@ let
defaultLicense = "EUPL-1.2"; defaultLicense = "EUPL-1.2";
defaultCopyright = "2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>"; defaultCopyright = "2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>";
downloadLicenses = true;
annotations = [ annotations = [
# Basic paths # Basic paths
{ {

View file

@ -12,15 +12,18 @@
let let
inherit (lib) inherit (lib)
filterAttrs filterAttrs
getExe
getExe' getExe'
mapAttrs' mapAttrs'
mkDefault mkDefault
mkOption mkOption
nameValuePair nameValuePair
optionalString
; ;
inherit (lib.types) inherit (lib.types)
attrsOf attrsOf
bool
either either
enum enum
listOf listOf
@ -76,6 +79,14 @@ in
''; '';
}; };
downloadLicenses = mkOption {
type = bool;
default = false;
description = ''
Try to download all licenses present in the configuration.
'';
};
annotations = mkOption { annotations = mkOption {
type = listOf ( type = listOf (
submodule ( submodule (
@ -175,6 +186,8 @@ in
cp --no-preserve=mode,ownership ${result} "$GIT_WC/REUSE.toml" && echo "nix-reuse: Updated REUSE.toml" cp --no-preserve=mode,ownership ${result} "$GIT_WC/REUSE.toml" && echo "nix-reuse: Updated REUSE.toml"
fi fi
fi fi
${optionalString config.downloadLicenses "${getExe pkgs.reuse} download --all"}
''; '';
}; };
} }