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.
- `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
### reuse git-hook

View file

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

View file

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