lol
1self: {
2 lib,
3 stdenv,
4 makeSetupHook,
5 fetchurl,
6 cmake,
7 qt6,
8}: let
9 dependencies = (lib.importJSON ../generated/dependencies.json).dependencies;
10 projectInfo = lib.importJSON ../generated/projects.json;
11
12 licenseInfo = lib.importJSON ../generated/licenses.json;
13 licensesBySpdxId =
14 (lib.mapAttrs' (_: v: {
15 name = v.spdxId or "unknown";
16 value = v;
17 })
18 lib.licenses)
19 // {
20 # https://community.kde.org/Policies/Licensing_Policy
21 "LicenseRef-KDE-Accepted-GPL" = lib.licenses.gpl3Plus;
22 "LicenseRef-KFQF-Accepted-GPL" = lib.licenses.gpl3Plus;
23 "LicenseRef-KDE-Accepted-LGPL" = lib.licenses.lgpl3Plus;
24
25 # https://sjfonts.sourceforge.net/
26 "LicenseRef-SJFonts" = lib.licenses.gpl2Plus;
27
28 # https://invent.kde.org/education/kiten/-/blob/master/LICENSES/LicenseRef-EDRDG.txt
29 "LicenseRef-EDRDG" = lib.licenses.cc-by-sa-30;
30
31 # https://invent.kde.org/kdevelop/kdevelop/-/blob/master/LICENSES/LicenseRef-MIT-KDevelop-Ideal.txt
32 "LicenseRef-MIT-KDevelop-Ideal" = lib.licenses.mit;
33
34 "FSFAP" = {
35 spdxId = "FSFAP";
36 fullName = "FSF All Permissive License";
37 };
38
39 "FSFULLR" = {
40 spdxId = "FSFULLR";
41 fullName = "FSF Unlimited License (with License Retention)";
42 };
43
44 "W3C-20150513" = {
45 spdxId = "W3C-20150513";
46 fullName = "W3C Software Notice and Document License (2015-05-13)";
47 };
48
49 # Technically not exact
50 "bzip2-1.0.6" = lib.licenses.bsdOriginal;
51
52 # FIXME: typo lol
53 "ICS" = lib.licenses.isc;
54
55 # These are only relevant to Qt commercial users
56 "Qt-Commercial-exception-1.0" = null;
57 "LicenseRef-Qt-Commercial" = null;
58 "LicenseRef-Qt-Commercial-exception-1.0" = null;
59
60 # FIXME: ???
61 "Qt-GPL-exception-1.0" = null;
62 "LicenseRef-Qt-LGPL-exception-1.0" = null;
63 "Qt-LGPL-exception-1.1" = null;
64 "LicenseRef-Qt-exception" = null;
65 "GCC-exception-3.1" = null;
66 "Bison-exception-2.2" = null;
67 "Font-exception-2.0" = null;
68 None = null;
69 };
70
71 moveDevHook = makeSetupHook {name = "kf6-move-dev-hook";} ./move-dev-hook.sh;
72in
73 {
74 pname,
75 version ? self.sources.${pname}.version,
76 src ? self.sources.${pname},
77 extraBuildInputs ? [],
78 extraNativeBuildInputs ? [],
79 extraPropagatedBuildInputs ? [],
80 extraCmakeFlags ? [],
81 excludeDependencies ? [],
82 ...
83 } @ args: let
84 depNames = dependencies.${pname} or [];
85 filteredDepNames = builtins.filter (dep: !(builtins.elem dep excludeDependencies)) depNames;
86
87 # FIXME(later): this is wrong for cross, some of these things really need to go into nativeBuildInputs,
88 # but cross is currently very broken anyway, so we can figure this out later.
89 deps = map (dep: self.${dep}) filteredDepNames;
90
91 traceDuplicateDeps = attrName: attrValue:
92 let
93 pretty = lib.generators.toPretty {};
94 duplicates = builtins.filter (dep: (builtins.elem (lib.getName dep) filteredDepNames)) attrValue;
95 in
96 if duplicates != []
97 then lib.warn "Duplicate dependencies in ${attrName} of package ${pname}: ${pretty duplicates}"
98 else lib.id;
99
100 traceAllDuplicateDeps = lib.flip lib.pipe [
101 (traceDuplicateDeps "extraBuildInputs" extraBuildInputs)
102 (traceDuplicateDeps "extraPropagatedBuildInputs" extraPropagatedBuildInputs)
103 ];
104
105 defaultArgs = {
106 inherit version src;
107
108 outputs = ["out" "dev" "devtools"];
109
110 nativeBuildInputs = [cmake qt6.wrapQtAppsHook moveDevHook] ++ extraNativeBuildInputs;
111 buildInputs = [qt6.qtbase] ++ extraBuildInputs;
112
113 # FIXME: figure out what to propagate here
114 propagatedBuildInputs = deps ++ extraPropagatedBuildInputs;
115 strictDeps = true;
116
117 dontFixCmake = true;
118 cmakeFlags = ["-DQT_MAJOR_VERSION=6"] ++ extraCmakeFlags;
119
120 separateDebugInfo = true;
121
122 env.LANG = "C.UTF-8";
123 };
124
125 cleanArgs = builtins.removeAttrs args [
126 "extraBuildInputs"
127 "extraNativeBuildInputs"
128 "extraPropagatedBuildInputs"
129 "extraCmakeFlags"
130 "excludeDependencies"
131 "meta"
132 ];
133
134 meta = {
135 description = projectInfo.${pname}.description;
136 homepage = "https://invent.kde.org/${projectInfo.${pname}.repo_path}";
137 license = lib.filter (l: l != null) (map (l: licensesBySpdxId.${l}) licenseInfo.${pname});
138 maintainers = lib.teams.qt-kde.members;
139 # Platforms are currently limited to what upstream tests in CI, but can be extended if there's interest.
140 platforms = lib.platforms.linux ++ lib.platforms.freebsd;
141 } // (args.meta or { });
142
143 pos = builtins.unsafeGetAttrPos "pname" args;
144 in
145 traceAllDuplicateDeps (stdenv.mkDerivation (defaultArgs // cleanArgs // { inherit meta pos; }))