-
Notifications
You must be signed in to change notification settings - Fork 121
/
tiddlydesktop.nix
80 lines (68 loc) · 2.2 KB
/
tiddlydesktop.nix
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
{ stdenv
, lib
, nodePackages
, nwjs
, jq
, writeScript
, bash
, makeDesktopItem
, copyDesktopItems
, gsettings-desktop-schemas
, wrapGAppsHook
, gtk3
}:
let
launcher = writeScript "tiddlydesktop" ''
#! ${bash}/bin/bash
${nwjs}/bin/nw @out@/lib/tiddlydesktop $@
'';
packageJson = builtins.fromJSON (builtins.readFile ./package.json);
in stdenv.mkDerivation rec {
pname = "tiddlydesktop";
version = "${packageJson.version}";
src = ./.;
nativeBuildInputs = [ copyDesktopItems wrapGAppsHook gtk3 ];
buildInputs = [ nodePackages.tiddlywiki jq ];
# These instructions are based on those from the bld.sh upstream script.
buildPhase = ''
cp -RH ${nodePackages.tiddlywiki}/lib/node_modules/tiddlywiki source/tiddlywiki
chmod -R u+w source
cp -RH plugins/tiddlydesktop source/tiddlywiki/plugins/tiddlywiki
version=$(jq < package.json '.version')
plugin_info=$(mktemp)
cat source/tiddlywiki/plugins/tiddlywiki/tiddlydesktop/plugin.info > $plugin_info
jq < $plugin_info --arg version $version '. + {version: $version}' > source/tiddlywiki/plugins/tiddlywiki/tiddlydesktop/plugin.info
echo $version > source/tiddlywiki/plugins/tiddlywiki/tiddlydesktop/system/version.txt
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
mkdir -p $out/lib/tiddlydesktop
mkdir -p $out/share/icons/hicolor
cp -R source/* $out/lib/tiddlydesktop/
cp ${launcher} $out/bin/tiddlydesktop
substituteAllInPlace $out/bin/tiddlydesktop
for n in 16 32 48 64 128 256 1024; do
size=$n"x"$n
mkdir -p $out/share/icons/hicolor/$size/apps
cp icons/app-icon$n.png $out/share/icons/hicolor/$size/apps/${pname}.png
done
runHook postInstall
'';
desktopItems = [
(makeDesktopItem {
name = pname;
exec = pname;
icon = pname;
desktopName = "Tiddly Desktop";
categories = ["Utility" "TextEditor"];
})
];
meta = with lib; {
homepage = "https://github.com/TiddlyWiki/TiddlyDesktop";
description = "A custom desktop browser for TiddlyWiki 5 and TiddlyWiki Classic, based on nw.js";
license = licenses.bsd0;
maintainers = with maintainers; [ emmanuelrosa ];
platforms = [ "x86_64-linux" ];
};
}