summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/re/remnote/package.nix
blob: 2ccd9721b90fa913fc741d72c0139fadfd5e8fd9 (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
{
  lib,
  fetchurl,
  appimageTools,
  makeWrapper,
  writeScript,
}:

appimageTools.wrapType2 (finalAttrs: {
  pname = "remnote";
  version = "1.28.9";

  src = fetchurl {
    url = "https://download2.remnote.io/remnote-desktop2/RemNote-${finalAttrs.version}.AppImage";
    hash = "sha256-Nv0pH4ZTFNs1Tl0CQ5ebXXxBFWHuhT2787k4UOcYfsI=";
  };

  nativeBuildInputs = [ makeWrapper ];

  extraInstallCommands = ''
    install -Dm444 ${finalAttrs.contents}/remnote.desktop -t $out/share/applications
    substituteInPlace $out/share/applications/remnote.desktop \
      --replace-fail 'Exec=AppRun --no-sandbox %U' 'Exec=remnote %u'
    install -Dm444 ${finalAttrs.contents}/remnote.png -t $out/share/icons/hicolor/512x512/apps

    wrapProgram $out/bin/remnote \
      --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform=wayland --enable-wayland-ime=true --wayland-text-input-version=3}}"
  '';

  passthru.updateScript = writeScript "update.sh" ''
    #!/usr/bin/env nix-shell
    #!nix-shell -i bash -p curl coreutils gnused common-updater-scripts
    set -eu -o pipefail
    url="$(curl -ILs -w %{url_effective} -o /dev/null https://backend.remnote.com/desktop/linux)"
    version="$(echo $url | sed -n 's/.*RemNote-\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/p')"
    currentVersion=$(nix-instantiate --eval -E "with import ./. {}; remnote.version or (lib.getVersion remnote)" | tr -d '"')
    if [[ "$version" != "$currentVersion" ]]; then
      hash=$(nix-hash --to-sri --type sha256 "$(nix-prefetch-url "$url")")
      update-source-version remnote "$version" "$hash" --print-changes
    fi
  '';

  meta = {
    description = "Note-taking application focused on learning and productivity";
    homepage = "https://remnote.com/";
    changelog = "https://feedback.remnote.com/changelog";
    maintainers = with lib.maintainers; [ talal ];
    license = lib.licenses.unfree;
    platforms = [ "x86_64-linux" ];
    mainProgram = "remnote";
  };
})