summaryrefslogtreecommitdiff
path: root/pkgs/by-name/xp/xpipe/package.nix
blob: d662717bc103dd7da3e1b03dbbb9f5ac995e5da3 (about) (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
{
  stdenvNoCC,
  lib,
  fetchzip,
  makeDesktopItem,
  autoPatchelfHook,
  zlib,
  fontconfig,
  udev,
  gtk3,
  freetype,
  alsa-lib,
  makeShellWrapper,
  libX11,
  libXext,
  libXdamage,
  libXfixes,
  libxcb,
  libXcomposite,
  libXcursor,
  libXi,
  libXrender,
  libXtst,
  libXxf86vm,
  util-linux,
  socat,
}:

let
  inherit (stdenvNoCC.hostPlatform) system;
  throwSystem = throw "Unsupported system: ${system}";

  # Keep this setup to easily add more arch support in the future
  arch =
    {
      x86_64-linux = "x86_64";
    }
    .${system} or throwSystem;

  hash =
    {
      x86_64-linux = "sha256-LMScG1cbcvMuMcb+R5lFU3eXsVWJ5ApMBtFi69OjyRs=";
    }
    .${system} or throwSystem;

  displayname = "XPipe";

in
stdenvNoCC.mkDerivation rec {
  pname = "xpipe";
  version = "17.3";

  src = fetchzip {
    url = "https://github.com/xpipe-io/xpipe/releases/download/${version}/xpipe-portable-linux-${arch}.tar.gz";
    inherit hash;
  };

  nativeBuildInputs = [
    autoPatchelfHook
    makeShellWrapper
  ];

  # Ignore libavformat dependencies as we don't need them
  autoPatchelfIgnoreMissingDeps = true;

  buildInputs = [
    fontconfig
    zlib
    udev
    freetype
    gtk3
    alsa-lib
    libX11
    libX11
    libXext
    libXdamage
    libXfixes
    libxcb
    libXcomposite
    libXcursor
    libXi
    libXrender
    libXtst
    libXxf86vm
    util-linux
    socat
  ];

  desktopItem = makeDesktopItem {
    categories = [ "Network" ];
    comment = "Your entire server infrastructure at your fingertips";
    desktopName = displayname;
    exec = "/opt/${pname}/bin/xpipe open %U";
    genericName = "Shell connection hub";
    icon = "/opt/${pname}/logo.png";
    name = displayname;
  };

  installPhase = ''
    runHook preInstall

    pkg="${pname}"
    mkdir -p $out/opt/$pkg
    cp -r ./ $out/opt/$pkg

    mkdir -p "$out/bin"
    ln -s "$out/opt/$pkg/bin/xpipe" "$out/bin/$pkg"

    mkdir -p "$out/share/applications"
    cp -r "${desktopItem}/share/applications/" "$out/share/"

    substituteInPlace "$out/share/applications/${displayname}.desktop" --replace "Exec=" "Exec=$out"
    substituteInPlace "$out/share/applications/${displayname}.desktop" --replace "Icon=" "Icon=$out"

    mv "$out/opt/$pkg/bin/xpiped" "$out/opt/$pkg/bin/xpiped_raw"
    mv "$out/opt/$pkg/lib/app/xpiped.cfg" "$out/opt/$pkg/lib/app/xpiped_raw.cfg"
    mv "$out/opt/$pkg/scripts/xpiped_debug.sh" "$out/opt/$pkg/scripts/xpiped_debug_raw.sh"

    makeShellWrapper "$out/opt/$pkg/bin/xpiped_raw" "$out/opt/$pkg/bin/xpiped" \
      --prefix LD_LIBRARY_PATH : "${
        lib.makeLibraryPath [
          fontconfig
          gtk3
          udev
          util-linux
          socat
        ]
      }"

    makeShellWrapper "$out/opt/$pkg/scripts/xpiped_debug_raw.sh" "$out/opt/$pkg/scripts/xpiped_debug.sh" \
      --prefix LD_LIBRARY_PATH : "${
        lib.makeLibraryPath [
          fontconfig
          gtk3
          udev
          util-linux
          socat
        ]
      }"

    runHook postInstall
  '';

  meta = {
    description = "Cross-platform shell connection hub and remote file manager";
    homepage = "https://github.com/xpipe-io/${pname}";
    downloadPage = "https://github.com/xpipe-io/${pname}/releases/latest";
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    changelog = "https://github.com/xpipe-io/${pname}/releases/tag/${version}";
    license = [
      lib.licenses.asl20
      lib.licenses.unfree
    ];
    maintainers = with lib.maintainers; [ crschnick ];
    platforms = [ "x86_64-linux" ];
    mainProgram = "xpipe";
  };
}