Skip to content

Commit

Permalink
licenses: add faircode parameter and checks to mkLicense
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandapip1 committed Jan 3, 2025
1 parent 4df8a4f commit 0c93562
Showing 1 changed file with 35 additions and 19 deletions.
54 changes: 35 additions & 19 deletions lib/licenses.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,41 @@
let
inherit (lib) optionalAttrs;

mkLicense = lname: {
shortName ? lname,
# Most of our licenses are Free, explicitly declare unfree additions as such!
free ? true,
deprecated ? false,
spdxId ? null,
url ? null,
fullName ? null,
redistributable ? free
}@attrs: {
inherit shortName free deprecated redistributable;
} // optionalAttrs (attrs ? spdxId) {
inherit spdxId;
url = "https://spdx.org/licenses/${spdxId}.html";
} // optionalAttrs (attrs ? url) {
inherit url;
} // optionalAttrs (attrs ? fullName) {
inherit fullName;
};
mkLicense =
lname:
{
shortName ? lname,
# Most of our licenses are Free, explicitly declare unfree additions as such!
free ? true,
deprecated ? false,
spdxId ? null,
url ? null,
fullName ? null,
redistributable ? free,
faircode ? false,
}@attrs:
lib.throwIf (free && !redistributable) "License ${lname} is marked as free but not redistributable" (
lib.throwIf (free && faircode) "License ${lname} is marked as free but also Faircode" (
{
inherit
shortName
free
deprecated
redistributable
;
}
// optionalAttrs (attrs ? spdxId) {
inherit spdxId;
url = "https://spdx.org/licenses/${spdxId}.html";
}
// optionalAttrs (attrs ? url) {
inherit url;
}
// optionalAttrs (attrs ? fullName) {
inherit fullName;
}
)
);

in
lib.mapAttrs mkLicense ({
Expand Down

0 comments on commit 0c93562

Please sign in to comment.