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