From 48f4befd440d272d8405d06f5ef0867300eebc64 Mon Sep 17 00:00:00 2001 From: FliegendeWurst <2012gdwu+github@posteo.de> Date: Tue, 2 Aug 2022 14:01:17 +0200 Subject: [PATCH] trilium: 0.51.2 -> 0.53.2 + update script (#177484) Co-authored-by: Sandro --- nixos/modules/services/web-apps/trilium.nix | 9 ++++ pkgs/applications/office/trilium/default.nix | 55 ++++++++++---------- pkgs/applications/office/trilium/update.sh | 18 +++++++ 3 files changed, 55 insertions(+), 27 deletions(-) create mode 100755 pkgs/applications/office/trilium/update.sh diff --git a/nixos/modules/services/web-apps/trilium.nix b/nixos/modules/services/web-apps/trilium.nix index 193c7944a64d..75464b21fd41 100644 --- a/nixos/modules/services/web-apps/trilium.nix +++ b/nixos/modules/services/web-apps/trilium.nix @@ -10,6 +10,7 @@ let # Disable automatically generating desktop icon noDesktopIcon=true noBackup=${lib.boolToString cfg.noBackup} + noAuthentication=${lib.boolToString cfg.noAuthentication} [Network] # host setting is relevant only for web deployments - set the host on which the server will listen @@ -49,6 +50,14 @@ in ''; }; + noAuthentication = mkOption { + type = types.bool; + default = false; + description = '' + If set to true, no password is required to access the web frontend. + ''; + }; + host = mkOption { type = types.str; default = "127.0.0.1"; diff --git a/pkgs/applications/office/trilium/default.nix b/pkgs/applications/office/trilium/default.nix index 1410ab320593..0f7b4e95ff84 100644 --- a/pkgs/applications/office/trilium/default.nix +++ b/pkgs/applications/office/trilium/default.nix @@ -1,18 +1,8 @@ -{ lib, stdenv, nixosTests, fetchurl, autoPatchelfHook, atomEnv, makeWrapper, makeDesktopItem, gtk3, libxshmfence, wrapGAppsHook }: +{ lib, stdenv, nixosTests, fetchurl, autoPatchelfHook, atomEnv, makeWrapper, makeDesktopItem, copyDesktopItems, libxshmfence, wrapGAppsHook }: let - description = "Trilium Notes is a hierarchical note taking application with focus on building large personal knowledge bases"; - desktopItem = makeDesktopItem { - name = "Trilium"; - exec = "trilium"; - icon = "trilium"; - comment = description; - desktopName = "Trilium Notes"; - categories = [ "Office" ]; - }; - - meta = with lib; { - inherit description; + metaCommon = with lib; { + description = "Hierarchical note taking application with focus on building large personal knowledge bases"; homepage = "https://github.com/zadam/trilium"; license = licenses.agpl3Plus; sourceProvenance = with sourceTypes; [ binaryNativeCode ]; @@ -20,24 +10,22 @@ let maintainers = with maintainers; [ fliegendewurst ]; }; - version = "0.51.2"; + version = "0.53.2"; - desktopSource = { - url = "https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-${version}.tar.xz"; - sha256 = "17bqcnpvflpi5dlz9m294diwd6as5wha5jcv9a3qvhh4pq0nyr4z"; - }; + desktopSource.url = "https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-${version}.tar.xz"; + desktopSource.sha256 = "0sjljyn7x0kv1692wccdjsll8h49r9lyqbrfnz4cn147xinclyw4"; - serverSource = { - url = "https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-server-${version}.tar.xz"; - sha256 = "0jjvg75a4va5d81x8dvpzmzax7p0bqd7psv0alkkl13m91gai6ig"; - }; + serverSource.url = "https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-server-${version}.tar.xz"; + serverSource.sha256 = "0y5xjf4r0c2hw2ch4ml55fq1nlmgnakq4zh3ch8sdgzm86nchavb"; in { trilium-desktop = stdenv.mkDerivation rec { pname = "trilium-desktop"; inherit version; - inherit meta; + meta = metaCommon // { + mainProgram = "trilium"; + }; src = fetchurl desktopSource; @@ -45,21 +33,32 @@ in { autoPatchelfHook makeWrapper wrapGAppsHook + copyDesktopItems ]; - buildInputs = atomEnv.packages ++ [ gtk3 libxshmfence ]; + buildInputs = atomEnv.packages ++ [ libxshmfence ]; + + desktopItems = [ + (makeDesktopItem { + name = "Trilium"; + exec = "trilium"; + icon = "trilium"; + comment = meta.description; + desktopName = "Trilium Notes"; + categories = [ "Office" ]; + }) + ]; installPhase = '' runHook preInstall mkdir -p $out/bin mkdir -p $out/share/trilium - mkdir -p $out/share/{applications,icons/hicolor/128x128/apps} + mkdir -p $out/share/icons/hicolor/128x128/apps cp -r ./* $out/share/trilium ln -s $out/share/trilium/trilium $out/bin/trilium ln -s $out/share/trilium/icon.png $out/share/icons/hicolor/128x128/apps/trilium.png - cp ${desktopItem}/share/applications/* $out/share/applications runHook postInstall ''; @@ -69,13 +68,15 @@ in { ''; dontStrip = true; + + passthru.updateScript = ./update.sh; }; trilium-server = stdenv.mkDerivation rec { pname = "trilium-server"; inherit version; - inherit meta; + meta = metaCommon; src = fetchurl serverSource; diff --git a/pkgs/applications/office/trilium/update.sh b/pkgs/applications/office/trilium/update.sh new file mode 100755 index 000000000000..02af29dace2f --- /dev/null +++ b/pkgs/applications/office/trilium/update.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p coreutils curl jq +set -euo pipefail + +cd $(dirname "${BASH_SOURCE[0]}") + +version=$(curl -s --show-error "https://api.github.com/repos/zadam/trilium/releases/latest" | jq -r '.tag_name' | tail -c +2) + +sha256_linux64=$(nix-prefetch-url --quiet https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-${version}.tar.xz) +sha256_linux64_server=$(nix-prefetch-url --quiet https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-server-${version}.tar.xz) + +setKV () { + sed -i "s|$1 = \".*\"|$1 = \"${2:-}\"|" ./default.nix +} + +setKV version $version +setKV desktopSource.sha256 $sha256_linux64 +setKV serverSource.sha256 $sha256_linux64_server