1{
2 stdenvNoCC,
3 lib,
4 fetchzip,
5 makeDesktopItem,
6 autoPatchelfHook,
7 zlib,
8 fontconfig,
9 udev,
10 gtk3,
11 freetype,
12 alsa-lib,
13 makeShellWrapper,
14 libX11,
15 libXext,
16 libXdamage,
17 libXfixes,
18 libxcb,
19 libXcomposite,
20 libXcursor,
21 libXi,
22 libXrender,
23 libXtst,
24 libXxf86vm,
25 util-linux,
26 socat,
27}:
28
29let
30 inherit (stdenvNoCC.hostPlatform) system;
31 throwSystem = throw "Unsupported system: ${system}";
32
33 # Keep this setup to easily add more arch support in the future
34 arch =
35 {
36 x86_64-linux = "x86_64";
37 }
38 .${system} or throwSystem;
39
40 hash =
41 {
42 x86_64-linux = "sha256-LMScG1cbcvMuMcb+R5lFU3eXsVWJ5ApMBtFi69OjyRs=";
43 }
44 .${system} or throwSystem;
45
46 displayname = "XPipe";
47
48in
49stdenvNoCC.mkDerivation rec {
50 pname = "xpipe";
51 version = "17.3";
52
53 src = fetchzip {
54 url = "https://github.com/xpipe-io/xpipe/releases/download/${version}/xpipe-portable-linux-${arch}.tar.gz";
55 inherit hash;
56 };
57
58 nativeBuildInputs = [
59 autoPatchelfHook
60 makeShellWrapper
61 ];
62
63 # Ignore libavformat dependencies as we don't need them
64 autoPatchelfIgnoreMissingDeps = true;
65
66 buildInputs = [
67 fontconfig
68 zlib
69 udev
70 freetype
71 gtk3
72 alsa-lib
73 libX11
74 libX11
75 libXext
76 libXdamage
77 libXfixes
78 libxcb
79 libXcomposite
80 libXcursor
81 libXi
82 libXrender
83 libXtst
84 libXxf86vm
85 util-linux
86 socat
87 ];
88
89 desktopItem = makeDesktopItem {
90 categories = [ "Network" ];
91 comment = "Your entire server infrastructure at your fingertips";
92 desktopName = displayname;
93 exec = "/opt/${pname}/bin/xpipe open %U";
94 genericName = "Shell connection hub";
95 icon = "/opt/${pname}/logo.png";
96 name = displayname;
97 };
98
99 installPhase = ''
100 runHook preInstall
101
102 pkg="${pname}"
103 mkdir -p $out/opt/$pkg
104 cp -r ./ $out/opt/$pkg
105
106 mkdir -p "$out/bin"
107 ln -s "$out/opt/$pkg/bin/xpipe" "$out/bin/$pkg"
108
109 mkdir -p "$out/share/applications"
110 cp -r "${desktopItem}/share/applications/" "$out/share/"
111
112 substituteInPlace "$out/share/applications/${displayname}.desktop" --replace "Exec=" "Exec=$out"
113 substituteInPlace "$out/share/applications/${displayname}.desktop" --replace "Icon=" "Icon=$out"
114
115 mv "$out/opt/$pkg/bin/xpiped" "$out/opt/$pkg/bin/xpiped_raw"
116 mv "$out/opt/$pkg/lib/app/xpiped.cfg" "$out/opt/$pkg/lib/app/xpiped_raw.cfg"
117 mv "$out/opt/$pkg/scripts/xpiped_debug.sh" "$out/opt/$pkg/scripts/xpiped_debug_raw.sh"
118
119 makeShellWrapper "$out/opt/$pkg/bin/xpiped_raw" "$out/opt/$pkg/bin/xpiped" \
120 --prefix LD_LIBRARY_PATH : "${
121 lib.makeLibraryPath [
122 fontconfig
123 gtk3
124 udev
125 util-linux
126 socat
127 ]
128 }"
129
130 makeShellWrapper "$out/opt/$pkg/scripts/xpiped_debug_raw.sh" "$out/opt/$pkg/scripts/xpiped_debug.sh" \
131 --prefix LD_LIBRARY_PATH : "${
132 lib.makeLibraryPath [
133 fontconfig
134 gtk3
135 udev
136 util-linux
137 socat
138 ]
139 }"
140
141 runHook postInstall
142 '';
143
144 meta = {
145 description = "Cross-platform shell connection hub and remote file manager";
146 homepage = "https://github.com/xpipe-io/${pname}";
147 downloadPage = "https://github.com/xpipe-io/${pname}/releases/latest";
148 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
149 changelog = "https://github.com/xpipe-io/${pname}/releases/tag/${version}";
150 license = [
151 lib.licenses.asl20
152 lib.licenses.unfree
153 ];
154 maintainers = with lib.maintainers; [ crschnick ];
155 platforms = [ "x86_64-linux" ];
156 mainProgram = "xpipe";
157 };
158}