From 5760604c9d94cb2a290bf2d6f27c9c4ecbb29416 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 14 Jan 2023 21:28:01 +0200 Subject: [PATCH 1/4] trilium-desktop: split desktop & server into two files --- pkgs/applications/office/trilium/default.nix | 123 ------------------- pkgs/applications/office/trilium/desktop.nix | 72 +++++++++++ pkgs/applications/office/trilium/server.nix | 55 +++++++++ pkgs/applications/office/trilium/update.sh | 21 ++-- pkgs/top-level/all-packages.nix | 7 +- 5 files changed, 142 insertions(+), 136 deletions(-) delete mode 100644 pkgs/applications/office/trilium/default.nix create mode 100644 pkgs/applications/office/trilium/desktop.nix create mode 100644 pkgs/applications/office/trilium/server.nix diff --git a/pkgs/applications/office/trilium/default.nix b/pkgs/applications/office/trilium/default.nix deleted file mode 100644 index 08084bfbf7ac..000000000000 --- a/pkgs/applications/office/trilium/default.nix +++ /dev/null @@ -1,123 +0,0 @@ -{ lib, stdenv, nixosTests, fetchurl, autoPatchelfHook, atomEnv, makeWrapper, makeDesktopItem, copyDesktopItems, libxshmfence, wrapGAppsHook }: - -let - 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 ]; - platforms = [ "x86_64-linux" ]; - maintainers = with maintainers; [ fliegendewurst ]; - }; - - version = "0.58.7"; - - desktopSource.url = "https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-${version}.tar.xz"; - desktopSource.sha256 = "1xr8fx5m6p9z18al1iigf45acn7b69vhbc6z6q1v933bvkwry16c"; - - serverSource.url = "https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-server-${version}.tar.xz"; - serverSource.sha256 = "0xr474z7wz0z4rqvk5rhv6xh51mdysr8zw86fs8fk7av0fdqxyka"; - -in { - - trilium-desktop = stdenv.mkDerivation rec { - pname = "trilium-desktop"; - inherit version; - meta = metaCommon // { - mainProgram = "trilium"; - }; - - src = fetchurl desktopSource; - - nativeBuildInputs = [ - autoPatchelfHook - makeWrapper - wrapGAppsHook - copyDesktopItems - ]; - - buildInputs = atomEnv.packages ++ [ libxshmfence ]; - - desktopItems = [ - (makeDesktopItem { - name = "Trilium"; - exec = "trilium"; - icon = "trilium"; - comment = meta.description; - desktopName = "Trilium Notes"; - categories = [ "Office" ]; - }) - ]; - - # Remove trilium-portable.sh, so trilium knows it is packaged making it stop auto generating a desktop item on launch - postPatch = '' - rm ./trilium-portable.sh - ''; - - installPhase = '' - runHook preInstall - mkdir -p $out/bin - mkdir -p $out/share/trilium - 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 - runHook postInstall - ''; - - # LD_LIBRARY_PATH "shouldn't" be needed, remove when possible :) - preFixup = '' - gappsWrapperArgs+=(--prefix LD_LIBRARY_PATH : ${atomEnv.libPath}) - ''; - - dontStrip = true; - - passthru.updateScript = ./update.sh; - }; - - - trilium-server = stdenv.mkDerivation rec { - pname = "trilium-server"; - inherit version; - meta = metaCommon; - - src = fetchurl serverSource; - - nativeBuildInputs = [ - autoPatchelfHook - ]; - - buildInputs = [ - stdenv.cc.cc.lib - ]; - - patches = [ - # patch logger to use console instead of rolling files - ./0001-Use-console-logger-instead-of-rolling-files.patch - ]; - - installPhase = '' - runHook preInstall - mkdir -p $out/bin - mkdir -p $out/share/trilium-server - - cp -r ./* $out/share/trilium-server - runHook postInstall - ''; - - postFixup = '' - cat > $out/bin/trilium-server < $out/bin/trilium-server < Date: Sat, 14 Jan 2023 22:22:52 +0200 Subject: [PATCH 2/4] trilium-desktop: add darwin64 --- pkgs/applications/office/trilium/default.nix | 17 +++ pkgs/applications/office/trilium/desktop.nix | 127 +++++++++++-------- pkgs/applications/office/trilium/server.nix | 10 +- pkgs/applications/office/trilium/update.sh | 4 +- pkgs/top-level/all-packages.nix | 7 +- 5 files changed, 99 insertions(+), 66 deletions(-) create mode 100644 pkgs/applications/office/trilium/default.nix diff --git a/pkgs/applications/office/trilium/default.nix b/pkgs/applications/office/trilium/default.nix new file mode 100644 index 000000000000..74bcb1172d21 --- /dev/null +++ b/pkgs/applications/office/trilium/default.nix @@ -0,0 +1,17 @@ +{ lib, callPackage, ... }: + +let + 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 ]; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ fliegendewurst ]; + }; +in { + + trilium-desktop = callPackage ./desktop.nix { metaCommon = metaCommon; }; + trilium-server = callPackage ./server.nix { metaCommon = metaCommon; }; + +} diff --git a/pkgs/applications/office/trilium/desktop.nix b/pkgs/applications/office/trilium/desktop.nix index 1424c36828b7..03e88a7816d6 100644 --- a/pkgs/applications/office/trilium/desktop.nix +++ b/pkgs/applications/office/trilium/desktop.nix @@ -1,72 +1,89 @@ -{ stdenv, lib, -autoPatchelfHook, fetchurl, atomEnv, makeWrapper, -makeDesktopItem, copyDesktopItems, wrapGAppsHook, -libxshmfence +{ stdenv, lib, unzip, autoPatchelfHook +, fetchurl, atomEnv, makeWrapper +, makeDesktopItem, copyDesktopItems, wrapGAppsHook, libxshmfence +, metaCommon }: let - desktopSource.url = "https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-${version}.tar.xz"; - desktopSource.sha256 = "1xr8fx5m6p9z18al1iigf45acn7b69vhbc6z6q1v933bvkwry16c"; - version = "0.58.7"; -in stdenv.mkDerivation rec { pname = "trilium-desktop"; - inherit version; - meta = with lib; { + version = "0.58.7"; + + linuxSource.url = "https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-${version}.tar.xz"; + linuxSource.sha256 = "1xr8fx5m6p9z18al1iigf45acn7b69vhbc6z6q1v933bvkwry16c"; + + darwinSource.url = "https://github.com/zadam/trilium/releases/download/v${version}/trilium-mac-x64-${version}.zip"; + darwinSource.sha256 = "1khywd77j4f745fvxln01li8qxnhlqqsirhm75kbi24bxlcpxfpa"; + + meta = metaCommon // { mainProgram = "trilium"; - 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 ]; - platforms = [ "x86_64-linux" ]; - maintainers = with maintainers; [ fliegendewurst ]; + platforms = [ "x86_64-linux" "x86_64-darwin" ]; }; - src = fetchurl desktopSource; + linux = stdenv.mkDerivation rec { + pname = "trilium-desktop"; + inherit version; - nativeBuildInputs = [ - autoPatchelfHook - makeWrapper - wrapGAppsHook - copyDesktopItems - ]; + src = fetchurl linuxSource; - buildInputs = atomEnv.packages ++ [ libxshmfence ]; + nativeBuildInputs = [ + autoPatchelfHook + makeWrapper + wrapGAppsHook + copyDesktopItems + ]; - desktopItems = [ - (makeDesktopItem { - name = "Trilium"; - exec = "trilium"; - icon = "trilium"; - comment = meta.description; - desktopName = "Trilium Notes"; - categories = [ "Office" ]; - }) - ]; + buildInputs = atomEnv.packages ++ [ libxshmfence ]; - # Remove trilium-portable.sh, so trilium knows it is packaged making it stop auto generating a desktop item on launch - postPatch = '' - rm ./trilium-portable.sh - ''; + 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/icons/hicolor/128x128/apps + # Remove trilium-portable.sh, so trilium knows it is packaged making it stop auto generating a desktop item on launch + postPatch = '' + rm ./trilium-portable.sh + ''; - cp -r ./* $out/share/trilium - ln -s $out/share/trilium/trilium $out/bin/trilium + installPhase = '' + runHook preInstall + mkdir -p $out/bin + mkdir -p $out/share/trilium + mkdir -p $out/share/icons/hicolor/128x128/apps - ln -s $out/share/trilium/icon.png $out/share/icons/hicolor/128x128/apps/trilium.png - runHook postInstall - ''; + cp -r ./* $out/share/trilium + ln -s $out/share/trilium/trilium $out/bin/trilium - # LD_LIBRARY_PATH "shouldn't" be needed, remove when possible :) - preFixup = '' - gappsWrapperArgs+=(--prefix LD_LIBRARY_PATH : ${atomEnv.libPath}) - ''; + ln -s $out/share/trilium/icon.png $out/share/icons/hicolor/128x128/apps/trilium.png + runHook postInstall + ''; - dontStrip = true; + # LD_LIBRARY_PATH "shouldn't" be needed, remove when possible :) + preFixup = '' + gappsWrapperArgs+=(--prefix LD_LIBRARY_PATH : ${atomEnv.libPath}) + ''; - passthru.updateScript = ./update.sh; -} + dontStrip = true; + + passthru.updateScript = ./update.sh; + }; + + darwin = stdenv.mkDerivation { + inherit pname version meta; + + src = fetchurl darwinSource; + nativeBuildInputs = [ unzip ]; + + installPhase = '' + mkdir -p $out/Applications + cp -r *.app $out/Applications + ''; + }; + +in + if stdenv.isDarwin then darwin else linux diff --git a/pkgs/applications/office/trilium/server.nix b/pkgs/applications/office/trilium/server.nix index 60a4612834b5..349ae7f4c331 100644 --- a/pkgs/applications/office/trilium/server.nix +++ b/pkgs/applications/office/trilium/server.nix @@ -1,4 +1,5 @@ -{ stdenv, lib, autoPatchelfHook, fetchurl, nixosTests }: +{ stdenv, lib, autoPatchelfHook, fetchurl, nixosTests +, metaCommon }: let serverSource.url = "https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-server-${version}.tar.xz"; @@ -7,13 +8,8 @@ let in stdenv.mkDerivation rec { pname = "trilium-server"; inherit version; - meta = 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 ]; + meta = metaCommon // { platforms = [ "x86_64-linux" ]; - maintainers = with maintainers; [ fliegendewurst ]; }; src = fetchurl serverSource; diff --git a/pkgs/applications/office/trilium/update.sh b/pkgs/applications/office/trilium/update.sh index f7bc34b42384..e292609e3f75 100755 --- a/pkgs/applications/office/trilium/update.sh +++ b/pkgs/applications/office/trilium/update.sh @@ -12,8 +12,10 @@ version=$(curl -s --show-error "https://api.github.com/repos/zadam/trilium/relea # Update desktop application sha256_linux64=$(nix-prefetch-url --quiet https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-${version}.tar.xz) +sha256_darwin64=$(nix-prefetch-url --quiet https://github.com/zadam/trilium/releases/download/v${version}/trilium-mac-x64-${version}.zip) setKV ./desktop.nix version $version -setKV ./desktop.nix desktopSource.sha256 $sha256_linux64 +setKV ./desktop.nix linuxSource.sha256 $sha256_linux64 +setKV ./desktop.nix darwinSource.sha256 $sha256_darwin64 # Update server sha256_linux64_server=$(nix-prefetch-url --quiet https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-server-${version}.tar.xz) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 224c43dd7282..87fc70d7834a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12581,9 +12581,10 @@ with pkgs; triggerhappy = callPackage ../tools/inputmethods/triggerhappy {}; - trilium-desktop = callPackage ../applications/office/trilium/desktop.nix { }; - - trilium-server = callPackage ../applications/office/trilium/server.nix { }; + inherit (callPackage ../applications/office/trilium {}) + trilium-desktop + trilium-server + ; trousers = callPackage ../tools/security/trousers { }; From 96726e8fb96181d1da32a2f7e49a83f58e0f6972 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 15 Jan 2023 12:58:55 +0200 Subject: [PATCH 3/4] maintainers: add eliandoran --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 7311dadb1eef..9b0452566d70 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -4134,6 +4134,12 @@ githubId = 103082; name = "Ed Brindley"; }; + eliandoran = { + email = "contact@eliandoran.me"; + name = "Elian Doran"; + github = "eliandoran"; + githubId = 21236836; + }; elizagamedev = { email = "eliza@eliza.sh"; github = "elizagamedev"; From 93ad2ef195537e54c6310db00d07c2667bdb742d Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 16 Jan 2023 22:03:54 +0200 Subject: [PATCH 4/4] trilium-{desktop,server}: add eliandoran to maintainers --- pkgs/applications/office/trilium/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/office/trilium/default.nix b/pkgs/applications/office/trilium/default.nix index 74bcb1172d21..35b9b694c091 100644 --- a/pkgs/applications/office/trilium/default.nix +++ b/pkgs/applications/office/trilium/default.nix @@ -7,7 +7,7 @@ let license = licenses.agpl3Plus; sourceProvenance = with sourceTypes; [ binaryNativeCode ]; platforms = [ "x86_64-linux" ]; - maintainers = with maintainers; [ fliegendewurst ]; + maintainers = with maintainers; [ fliegendewurst eliandoran ]; }; in {