about summary refs log tree commit diff
path: root/nixpkgs/pkgs/kde/lib/mk-kde-derivation.nix
blob: 042c7531f07eb6a99bb650b6b055fe9448d8aace (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
self: {
  lib,
  stdenv,
  makeSetupHook,
  fetchurl,
  cmake,
  qt6,
}: let
  dependencies = (lib.importJSON ../generated/dependencies.json).dependencies;
  projectInfo = lib.importJSON ../generated/projects.json;

  licenseInfo = lib.importJSON ../generated/licenses.json;
  licensesBySpdxId =
    (lib.mapAttrs' (_: v: {
        name = v.spdxId or "unknown";
        value = v;
      })
      lib.licenses)
    // {
      # https://community.kde.org/Policies/Licensing_Policy
      "LicenseRef-KDE-Accepted-GPL" = lib.licenses.gpl3Plus;
      "LicenseRef-KFQF-Accepted-GPL" = lib.licenses.gpl3Plus;
      "LicenseRef-KDE-Accepted-LGPL" = lib.licenses.lgpl3Plus;

      # https://sjfonts.sourceforge.net/
      "LicenseRef-SJFonts" = lib.licenses.gpl2Plus;

      # https://invent.kde.org/education/kiten/-/blob/master/LICENSES/LicenseRef-EDRDG.txt
      "LicenseRef-EDRDG" = lib.licenses.cc-by-sa-30;

      # https://invent.kde.org/kdevelop/kdevelop/-/blob/master/LICENSES/LicenseRef-MIT-KDevelop-Ideal.txt
      "LicenseRef-MIT-KDevelop-Ideal" = lib.licenses.mit;

      "FSFAP" = {
        spdxId = "FSFAP";
        fullName = "FSF All Permissive License";
      };

      "FSFULLR" = {
        spdxId = "FSFULLR";
        fullName = "FSF Unlimited License (with License Retention)";
      };

      "W3C-20150513" = {
        spdxId = "W3C-20150513";
        fullName = "W3C Software Notice and Document License (2015-05-13)";
      };

      # Technically not exact
      "bzip2-1.0.6" = lib.licenses.bsdOriginal;

      # FIXME: typo lol
      "ICS" = lib.licenses.isc;

      # These are only relevant to Qt commercial users
      "Qt-Commercial-exception-1.0" = null;
      "LicenseRef-Qt-Commercial" = null;
      "LicenseRef-Qt-Commercial-exception-1.0" = null;

      # FIXME: ???
      "Qt-GPL-exception-1.0" = null;
      "LicenseRef-Qt-LGPL-exception-1.0" = null;
      "Qt-LGPL-exception-1.1" = null;
      "LicenseRef-Qt-exception" = null;
      "GCC-exception-3.1" = null;
      "Bison-exception-2.2" = null;
      "Font-exception-2.0" = null;
      None = null;
    };

  moveDevHook = makeSetupHook {name = "kf6-move-dev-hook";} ./move-dev-hook.sh;
in
  {
    pname,
    version ? self.sources.${pname}.version,
    src ? self.sources.${pname},
    extraBuildInputs ? [],
    extraNativeBuildInputs ? [],
    extraPropagatedBuildInputs ? [],
    extraCmakeFlags ? [],
    ...
  } @ args: let
    # FIXME(later): this is wrong for cross, some of these things really need to go into nativeBuildInputs,
    # but cross is currently very broken anyway, so we can figure this out later.
    deps = map (dep: self.${dep}) (dependencies.${pname} or []);

    defaultArgs = {
      inherit version src;

      outputs = ["out" "dev"];

      nativeBuildInputs = [cmake qt6.wrapQtAppsHook moveDevHook] ++ extraNativeBuildInputs;
      buildInputs = [qt6.qtbase] ++ extraBuildInputs;

      # FIXME: figure out what to propagate here
      propagatedBuildInputs = deps ++ extraPropagatedBuildInputs;
      strictDeps = true;

      dontFixCmake = true;
      cmakeFlags = ["-DQT_MAJOR_VERSION=6"] ++ extraCmakeFlags;

      separateDebugInfo = true;

      env.LANG = "C.UTF-8";
    };

    cleanArgs = builtins.removeAttrs args [
      "extraBuildInputs"
      "extraNativeBuildInputs"
      "extraPropagatedBuildInputs"
      "extraCmakeFlags"
      "meta"
    ];

    meta = let
      pos = builtins.unsafeGetAttrPos "pname" args;
    in {
      description = projectInfo.${pname}.description;
      homepage = "https://invent.kde.org/${projectInfo.${pname}.repo_path}";
      license = lib.filter (l: l != null) (map (l: licensesBySpdxId.${l}) licenseInfo.${pname});
      maintainers = lib.teams.qt-kde.members;
      # Platforms are currently limited to what upstream tests in CI, but can be extended if there's interest.
      platforms = lib.platforms.linux ++ lib.platforms.freebsd;
      position = "${pos.file}:${toString pos.line}";
    } // (args.meta or { });
  in
    stdenv.mkDerivation (defaultArgs // cleanArgs) // { inherit meta; }