summary refs log tree commit diff
path: root/pkgs/applications/misc/1password-gui/default.nix
blob: 9f062aa20fc0a683c7ef8da2b4d86685d781534f (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
65
66
67
68
69
70
71
72
73
74
75
76
77
{ lib
, stdenv
, fetchurl
, makeWrapper
, electron_11
, openssl
}:

stdenv.mkDerivation rec {
  pname = "1password";
  version = "8.0.33-53.BETA";

  src = fetchurl {
    url = "https://downloads.1password.com/linux/tar/beta/x86_64/1password-${version}.x64.tar.gz";
    hash = "sha256-YUYER+UiM1QEDgGl0P9bIT65YVacUnuGtQVkV91teEU=";
  };

  nativeBuildInputs = [ makeWrapper ];

  dontConfigure = true;
  dontBuild = true;

  installPhase = let
    runtimeLibs = [
      openssl.out
      stdenv.cc.cc
    ];
  in ''
    mkdir -p $out/bin $out/share/1password

    # Applications files.
    cp -a {locales,resources} $out/share/${pname}
    install -Dm0755 -t $out/share/${pname} {1Password-BrowserSupport,1Password-KeyringHelper}

    # Desktop file.
    install -Dt $out/share/applications resources/${pname}.desktop
    substituteInPlace $out/share/applications/${pname}.desktop \
      --replace 'Exec=/opt/1Password/${pname}' 'Exec=${pname}'

    # Icons.
    cp -a resources/icons $out/share

    # Wrap the application with Electron.
    makeWrapper "${electron_11}/bin/electron" "$out/bin/${pname}" \
      --add-flags "$out/share/${pname}/resources/app.asar" \
      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeLibs}"

    # Set the interpreter for the helper binaries and wrap them with
    # the runtime libraries.
    interp="$(cat $NIX_CC/nix-support/dynamic-linker)"
    patchelf --set-interpreter $interp \
      $out/share/$pname/{1Password-BrowserSupport,1Password-KeyringHelper}

    wrapProgram $out/share/${pname}/1Password-BrowserSupport \
      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeLibs}"

    wrapProgram $out/share/${pname}/1Password-KeyringHelper \
      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeLibs}"
  '';

  passthru.updateScript = ./update.sh;

  meta = with lib; {
    description = "Multi-platform password manager";
    longDescription = ''
      1Password is a multi-platform package manager.

      The Linux version is currently a development preview and can
      only be used to search, view, and copy items. However items
      cannot be created or edited.
    '';
    homepage = "https://1password.com/";
    license = licenses.unfree;
    maintainers = with maintainers; [ danieldk timstott ];
    platforms = [ "x86_64-linux" ];
  };
}