forked from
lass.pds.lassul.us/superconfig
This repository has no description
1.1 kB
41 lines
1{ lib }:
2/**
3 Override unfree licenses to free ones in a derivation.
4
5 This function takes a derivation and replaces any unfree license with lib.licenses.free.
6 Note: This only works for simple packages. Complex packages with unfree dependencies
7 in their build process (like firefox-bin -> firefox-bin-unwrapped) cannot be handled
8 this way and need other approaches.
9
10 # Example
11
12 ```nix
13 halalify pkgs.someUnfreePackage
14 ```
15*/
16drv:
17if !lib.isDerivation drv then
18 drv
19else
20 let
21 # Helper to check if a license is unfree
22 isUnfreeLicense = license: lib.isAttrs license && license ? free && !license.free;
23
24 # Helper to make a license free
25 makeFreeLicense =
26 license:
27 if isUnfreeLicense license then
28 lib.licenses.free
29 else if lib.isList license then
30 map makeFreeLicense license
31 else
32 license;
33 in
34 drv.overrideAttrs (old: {
35 # Override the license
36 meta =
37 (old.meta or { })
38 // lib.optionalAttrs (old.meta ? license) {
39 license = makeFreeLicense old.meta.license;
40 };
41 })