k3s: format with nixfmt-rfc-style
[NixPkgs.git] / pkgs / kde / lib / mk-kde-derivation.nix
blob975d2e4af93ab13b98bde5ee541bf5547aa4121a
1 self: {
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;
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;
25       # https://sjfonts.sourceforge.net/
26       "LicenseRef-SJFonts" = lib.licenses.gpl2Plus;
28       # https://invent.kde.org/education/kiten/-/blob/master/LICENSES/LicenseRef-EDRDG.txt
29       "LicenseRef-EDRDG" = lib.licenses.cc-by-sa-30;
31       # https://invent.kde.org/kdevelop/kdevelop/-/blob/master/LICENSES/LicenseRef-MIT-KDevelop-Ideal.txt
32       "LicenseRef-MIT-KDevelop-Ideal" = lib.licenses.mit;
34       "FSFAP" = {
35         spdxId = "FSFAP";
36         fullName = "FSF All Permissive License";
37       };
39       "FSFULLR" = {
40         spdxId = "FSFULLR";
41         fullName = "FSF Unlimited License (with License Retention)";
42       };
44       "W3C-20150513" = {
45         spdxId = "W3C-20150513";
46         fullName = "W3C Software Notice and Document License (2015-05-13)";
47       };
49       # Technically not exact
50       "bzip2-1.0.6" = lib.licenses.bsdOriginal;
52       # FIXME: typo lol
53       "ICS" = lib.licenses.isc;
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;
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     };
71   moveDevHook = makeSetupHook {name = "kf6-move-dev-hook";} ./move-dev-hook.sh;
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;
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;
91     defaultArgs = {
92       inherit version src;
94       outputs = ["out" "dev" "devtools"];
96       nativeBuildInputs = [cmake qt6.wrapQtAppsHook moveDevHook] ++ extraNativeBuildInputs;
97       buildInputs = [qt6.qtbase] ++ extraBuildInputs;
99       # FIXME: figure out what to propagate here
100       propagatedBuildInputs = deps ++ extraPropagatedBuildInputs;
101       strictDeps = true;
103       dontFixCmake = true;
104       cmakeFlags = ["-DQT_MAJOR_VERSION=6"] ++ extraCmakeFlags;
106       separateDebugInfo = true;
108       env.LANG = "C.UTF-8";
109     };
111     cleanArgs = builtins.removeAttrs args [
112       "extraBuildInputs"
113       "extraNativeBuildInputs"
114       "extraPropagatedBuildInputs"
115       "extraCmakeFlags"
116       "excludeDependencies"
117       "meta"
118     ];
120     meta = {
121       description = projectInfo.${pname}.description;
122       homepage = "https://invent.kde.org/${projectInfo.${pname}.repo_path}";
123       license = lib.filter (l: l != null) (map (l: licensesBySpdxId.${l}) licenseInfo.${pname});
124       maintainers = lib.teams.qt-kde.members;
125       # Platforms are currently limited to what upstream tests in CI, but can be extended if there's interest.
126       platforms = lib.platforms.linux ++ lib.platforms.freebsd;
127     } // (args.meta or { });
129     pos = builtins.unsafeGetAttrPos "pname" args;
130   in
131     stdenv.mkDerivation (defaultArgs // cleanArgs // { inherit meta pos; })