about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/office/trilium/server.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/applications/office/trilium/server.nix')
-rw-r--r--nixpkgs/pkgs/applications/office/trilium/server.nix51
1 files changed, 51 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/office/trilium/server.nix b/nixpkgs/pkgs/applications/office/trilium/server.nix
new file mode 100644
index 000000000000..4beaba6688c9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/office/trilium/server.nix
@@ -0,0 +1,51 @@
+{ stdenv, autoPatchelfHook, fetchurl, nixosTests
+, metaCommon }:
+
+let
+  serverSource.url = "https://github.com/zadam/trilium/releases/download/v${version}/trilium-linux-x64-server-${version}.tar.xz";
+  serverSource.sha256 = "1s0pfb3virhxsh5kkgq4yfhdnv1lq2z0zdcikilnayzp0lpjskhb";
+  version = "0.62.5";
+in stdenv.mkDerivation {
+  pname = "trilium-server";
+  inherit version;
+  meta = metaCommon // {
+    platforms = [ "x86_64-linux" ];
+  };
+
+  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 <<EOF
+    #!${stdenv.cc.shell}
+    cd $out/share/trilium-server
+    exec ./node/bin/node src/www
+    EOF
+    chmod a+x $out/bin/trilium-server
+  '';
+
+  passthru.tests = {
+    trilium-server = nixosTests.trilium-server;
+  };
+}