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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
{ lib
, stdenv
, fetchurl
, bundlerEnv
, alsa-utils
, atk
, copyDesktopItems
, gobject-introspection
, gtk2
, ruby
, libicns
, libnotify
, makeDesktopItem
, which
, wrapGAppsHook
, writeText
}:
let
# NOTE: $out may have different values depending on context
mikutterPaths = rec {
optPrefixDir = "$out/opt/mikutter";
appPrefixDir = "$out/Applications/mikutter.app/Contents";
appBinDir = "${appPrefixDir}/MacOS";
appResourceDir = "${appPrefixDir}/Resources";
iconPath = "${optPrefixDir}/core/skin/data/icon.png";
};
gems = bundlerEnv {
name = "mikutter-gems"; # leave the version out to enable package reuse
gemdir = ./deps;
groups = [ "default" "plugin" ];
inherit ruby;
# Avoid the following error:
# > `<module:Moneta>': uninitialized constant Moneta::Builder (NameError)
#
# Related:
# https://github.com/NixOS/nixpkgs/pull/76510
# https://github.com/NixOS/nixpkgs/pull/76765
# https://github.com/NixOS/nixpkgs/issues/83442
# https://github.com/NixOS/nixpkgs/issues/106545
copyGemFiles = true;
};
mkDesktopItem = { description }:
makeDesktopItem {
name = "mikutter";
desktopName = "mikutter";
exec = "mikutter";
icon = "mikutter";
categories = [ "Network" ];
comment = description;
keywords = [ "Mastodon" ];
};
mkInfoPlist = { version }:
writeText "Info.plist" (lib.generators.toPlist { } {
CFBundleName = "mikutter";
CFBundleDisplayName = "mikutter";
CFBundleExecutable = "mikutter";
CFBundleIconFile = "mikutter";
CFBundleIdentifier = "net.hachune.mikutter";
CFBundleInfoDictionaryVersion = "6.0";
CFBundlePackageType = "APPL";
CFBundleVersion = version;
CFBundleShortVersionString = version;
});
inherit (gems) wrappedRuby;
in
with mikutterPaths; stdenv.mkDerivation rec {
pname = "mikutter";
version = "4.1.4";
src = fetchurl {
url = "https://mikutter.hachune.net/bin/mikutter-${version}.tar.gz";
sha256 = "05253nz4i1lmnq6czj48qdab2ny4vx2mznj6nsn2l1m2z6zqkwk3";
};
nativeBuildInputs = [ copyDesktopItems wrapGAppsHook gobject-introspection ]
++ lib.optionals stdenv.isDarwin [ libicns ];
buildInputs = [
atk
gtk2
libnotify
which # some plugins use it at runtime
wrappedRuby
] ++ lib.optionals stdenv.isLinux [ alsa-utils ];
scriptPath = lib.makeBinPath (
[ wrappedRuby libnotify which ]
++ lib.optionals stdenv.isLinux [ alsa-utils ]
);
postUnpack = ''
rm -rf vendor
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin ${optPrefixDir}
install -Dm644 README $out/share/doc/mikutter/README
install -Dm644 LICENSE $out/share/doc/mikutter/LICENSE
rm -r README LICENSE deployment
cp -r . ${optPrefixDir}
gappsWrapperArgsHook # FIXME: currently runs at preFixup
wrapGApp ${optPrefixDir}/mikutter.rb \
--prefix PATH : "${scriptPath}" \
--set DISABLE_BUNDLER_SETUP 1
mv ${optPrefixDir}/mikutter.rb $out/bin/mikutter
install -Dm644 ${iconPath} $out/share/icons/hicolor/256x256/apps/mikutter.png
runHook postInstall
'';
postInstall =
let
infoPlist = mkInfoPlist { inherit version; };
in
lib.optionalString stdenv.isDarwin ''
mkdir -p ${appBinDir} ${appResourceDir}
install -Dm644 ${infoPlist} ${appPrefixDir}/Info.plist
ln -s $out/bin/mikutter ${appBinDir}/mikutter
png2icns ${appResourceDir}/mikutter.icns ${iconPath}
'';
installCheckPhase = ''
runHook preInstallCheck
testDir="$(mktemp -d)"
install -Dm644 ${./test_plugin.rb} "$testDir/plugin/test_plugin/test_plugin.rb"
$out/bin/mikutter --confroot="$testDir" --plugin=test_plugin --debug
runHook postInstallCheck
'';
desktopItems = [
(mkDesktopItem { inherit (meta) description; })
];
doInstallCheck = true;
dontWrapGApps = true; # the target is placed outside of bin/
passthru.updateScript = [ ./update.sh version (toString ./.) ];
meta = with lib; {
description = "An extensible Mastodon client";
homepage = "https://mikutter.hachune.net";
platforms = ruby.meta.platforms;
license = licenses.mit;
};
}
|