summaryrefslogtreecommitdiff
path: root/meshmc/nix/unwrapped.nix
blob: aa2baf2bebfdf0dd3325208d353ac3d19aefb493 (plain)
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
128
129
130
131
132
133
134
135
136
137
138
139
140
{
  lib,
  stdenv,
  cmake,
  cmark,
  extra-cmake-modules,
  gamemode,
  jdk17,
  kdePackages,
  libnbtplusplus,
  ninja,
  qrencode,
  self,
  stripJavaArchivesHook,
  tomlplusplus,
  zlib,
  msaClientID ? null,
  libarchive,
}:

let
  date =
    let
      # YYYYMMDD
      date' = lib.substring 0 8 self.lastModifiedDate;
      year = lib.substring 0 4 date';
      month = lib.substring 4 2 date';
      date = lib.substring 6 2 date';
    in
    if (self ? "lastModifiedDate") then
      lib.concatStringsSep "-" [
        year
        month
        date
      ]
    else
      "unknown";
in

stdenv.mkDerivation {
  pname = "meshmc-unwrapped";
  version = "7.0-unstable-${date}";

  src = lib.fileset.toSource {
    root = ../.;
    fileset = lib.fileset.unions [
      ../bootstrap.sh
      ../branding
      ../buildconfig
      ../BUILD.md
      ../changelog.md
      ../cmake
      ../CMakeLists.txt
      ../CMakePresets.json
      ../CODE_OF_CONDUCT.md
      ../Containerfile
      ../CONTRIBUTING.md
      ../COPYING.md
      ../default.nix
      ../doc
      ../.envrc
      ../flake.nix
      ../.gitattributes
      ../.gitmodules
      ../launcher
      ../lefthook.yml
      ../libraries
      ../LICENSES
      ../.markdownlintignore
      ../.markdownlint.yaml
      ../nix
      ../README.md
      ../REUSE.toml
      ../scripts
      ../shell.nix
      ../updater
    ];
  };

  postUnpack = ''
    rm -rf source/libraries/libnbtplusplus
    ln -s ${libnbtplusplus} source/libraries/libnbtplusplus
  '';

  nativeBuildInputs = [
    cmake
    ninja
    extra-cmake-modules
    jdk17
    stripJavaArchivesHook
  ];

  buildInputs = [
    cmark
    kdePackages.qtbase
    kdePackages.qtnetworkauth
    kdePackages.qt5compat
    qrencode
    libarchive
    tomlplusplus
    zlib
  ]
  ++ lib.optional stdenv.hostPlatform.isLinux gamemode;

  cmakeFlags = [
    # downstream branding
    (lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixpkgs")
  ]
  ++ lib.optionals (msaClientID != null) [
    (lib.cmakeFeature "Launcher_MSA_CLIENT_ID" (toString msaClientID))
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # we wrap our binary manually
    (lib.cmakeFeature "INSTALL_BUNDLE" "nodeps")
    # disable built-in updater
    (lib.cmakeFeature "MACOSX_SPARKLE_UPDATE_FEED_URL" "''")
    (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/Applications/")
  ];

  doCheck = true;

  dontWrapQtApps = true;

  meta = {
    description = "Free, open source launcher for Minecraft";
    longDescription = ''
      Allows you to have multiple, separate instances of Minecraft (each with
      their own mods, texture packs, saves, etc) and helps you manage them and
      their associated options with a simple interface.
    '';
    homepage = "https://projecttick.org/";
    license = lib.licenses.gpl3Plus;
    maintainers = with lib.maintainers; [
      Scrumplex
      getchoo
    ];
    mainProgram = "meshmc";
    platforms = lib.platforms.linux ++ lib.platforms.darwin;
  };
}