aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/applications/blockchains/whirlpool-gui/default.nix
blob: 9a660bb8bffb888a9f0efce1c4d4fac98eeb1fe1 (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
{ stdenv, fetchFromGitHub, callPackage, makeWrapper, makeDesktopItem
, nodejs, yarn, electron_7, jre8, tor }:

let
  system = stdenv.hostPlatform.system;
  electron = electron_7;

in stdenv.mkDerivation rec {
  pname = "whirlpool-gui";
  version = "0.10.1";

  src = fetchFromGitHub {
    owner = "Samourai-Wallet";
    repo = pname;
    rev = version;
    sha256 = "ru6WJQRulhnQCPY2E0x9M6xXtFdj/pg2fu4HpQxhImU=";
  };

  yarnCache = stdenv.mkDerivation {
    name = "${pname}-${version}-${system}-yarn-cache";
    inherit src;
    phases = [ "unpackPhase" "buildPhase" ];
    nativeBuildInputs = [ yarn ];
    buildPhase = ''
      export HOME=$NIX_BUILD_ROOT

      yarn config set yarn-offline-mirror $out
      yarn --frozen-lockfile --ignore-scripts --ignore-platform \
        --ignore-engines --no-progress --non-interactive
    '';

    outputHashMode = "recursive";
    outputHashAlgo = "sha256";
    outputHash = {
      x86_64-linux = "6fl4cSwHXWgQcYlqxCae0p1Ppcb9fI5fFrxm7y6wxTo=";
    }.${system} or (throw "Unsupported platform ${system}");
  };

  nativeBuildInputs = [ makeWrapper nodejs yarn ];

  configurePhase = ''
    # Yarn and bundler wants a real home directory to write cache, config, etc to
    export HOME=$NIX_BUILD_ROOT

    # Make yarn install packages from our offline cache, not the registry
    yarn config --offline set yarn-offline-mirror ${yarnCache}
  '';

  buildPhase = ''
    yarn install --offline --ignore-scripts --frozen-lockfile --no-progress --non-interactive

    patchShebangs node_modules/

    yarn build
  '';

  installPhase = ''
    mkdir -p $out/{bin,share,libexec/whirlpool-gui/app}

    # install production dependencies
    yarn install \
      --offline --frozen-lockfile --ignore-scripts \
      --no-progress --non-interactive \
      --production --no-bin-links \
      --modules-folder $out/libexec/whirlpool-gui/node_modules

    # copy application
    cp -r app/{dist,app.html,main.prod.js,main.prod.js.map,img} $out/libexec/whirlpool-gui/app
    cp -r package.json resources $out/libexec/whirlpool-gui

    # make desktop item
    ln -s "${desktopItem}/share/applications" "$out/share/applications"

    # wrap electron
    makeWrapper '${electron}/bin/electron' "$out/bin/whirlpool-gui" \
      --add-flags "$out/libexec/whirlpool-gui" \
      --prefix PATH : "${jre8}/bin:${tor}/bin"
  '';

  desktopItem = makeDesktopItem {
    name = "whirlpool-gui";
    exec = "whirlpool-gui";
    icon = "whirlpool-gui";
    desktopName = "Whirlpool";
    genericName = "Whirlpool";
    comment = meta.description;
    categories = "Network;";
    extraEntries = ''
      StartupWMClass=whrilpool-gui
    '';
  };

  passthru.prefetchYarnCache = stdenv.lib.overrideDerivation yarnCache (d: {
    outputHash = stdenv.lib.fakeSha256;
  });

  meta = with stdenv.lib; {
    description = "Desktop GUI for Whirlpool by Samourai-Wallet";
    homepage = https://www.samouraiwallet.com/whirlpool;
    license = licenses.unlicense;
    maintainers = [ maintainers.offline ];
    platforms = [ "x86_64-linux" ];
  };
}