summary refs log tree commit diff
path: root/pkgs/applications/version-management/git-and-tools/radicle-upstream/default.nix
blob: 766cb417b74524784ad0347361d155458b074780 (plain) (blame)
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
{ lib, stdenv, appimageTools, gsettings-desktop-schemas, gtk3, autoPatchelfHook, zlib, fetchurl }:

let
  pname = "radicle-upstream";
  version = "0.1.11";
  name = "${pname}-${version}";

  src = fetchurl {
    url = "https://releases.radicle.xyz/radicle-upstream-${version}.AppImage";
    sha256 =  "1j0xc9ns3andycbrrzkn6ql6739b1dimzlxq17wwpmqhni9nh673";
  };

  contents = appimageTools.extractType2 { inherit name src; };

  git-remote-rad = stdenv.mkDerivation rec {
    pname = "git-remote-rad";
    inherit version;
    src = contents;

    nativeBuildInputs = [ autoPatchelfHook ];
    buildInputs = [ zlib ];

    installPhase = ''
      mkdir -p $out/bin/
      cp ${contents}/resources/git-remote-rad $out/bin/git-remote-rad
    '';
  };
in

# FIXME: a dependency of the `proxy` component of radicle-upstream (radicle-macros
# v0.1.0) uses unstable rust features, making a from source build impossible at
# this time. See this PR for discussion: https://github.com/NixOS/nixpkgs/pull/105674
appimageTools.wrapType2 {
  inherit name src;

  profile = ''
    export XDG_DATA_DIRS=${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}:${gtk3}/share/gsettings-schemas/${gtk3.name}:$XDG_DATA_DIRS
  '';

  extraInstallCommands = ''
    mv $out/bin/${name} $out/bin/${pname}

    # this automatically adds the git-remote-rad binary to the users `PATH` so
    # they don't need to mess around with shell profiles...
    ln -s ${git-remote-rad}/bin/git-remote-rad $out/bin/git-remote-rad

    # desktop item
    install -m 444 -D ${contents}/${pname}.desktop $out/share/applications/${pname}.desktop
    substituteInPlace $out/share/applications/${pname}.desktop \
      --replace 'Exec=AppRun' 'Exec=${pname}'

    # icon
    install -m 444 -D ${contents}/${pname}.png \
      $out/share/icons/hicolor/512x512/apps/${pname}.png
  '';

  meta = with lib; {
    description = "A decentralized app for code collaboration";
    homepage = "https://radicle.xyz/";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ xwvvvvwx ];
    platforms = [ "x86_64-linux" ];
  };
}