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