about summary refs log tree commit diff
path: root/pkgs/by-name/om/omnom/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/om/omnom/package.nix')
-rw-r--r--pkgs/by-name/om/omnom/package.nix58
1 files changed, 58 insertions, 0 deletions
diff --git a/pkgs/by-name/om/omnom/package.nix b/pkgs/by-name/om/omnom/package.nix
new file mode 100644
index 000000000000..6d89e3005b4d
--- /dev/null
+++ b/pkgs/by-name/om/omnom/package.nix
@@ -0,0 +1,58 @@
+{
+  lib,
+  buildGoModule,
+  fetchFromGitHub,
+  makeWrapper,
+}:
+
+buildGoModule {
+  pname = "omnom";
+  version = "0-unstable-2024-08-29";
+
+  src = fetchFromGitHub {
+    owner = "asciimoo";
+    repo = "omnom";
+    rev = "1fcd7787886503f703bbcd31b193d4c93acc5610";
+    hash = "sha256-o/n8rgngQkYEn8J0aFpCiD4qrWVFaaa305OxiscU6+8=";
+    fetchSubmodules = true;
+  };
+
+  vendorHash = "sha256-dsS5w8JXIwkneWScOFzLSDiXq+clgK+RdYiMw0+FnvY=";
+
+  patches = [ ./0001-fix-minimal-go-version.patch ];
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  ldflags = [
+    "-s"
+    "-w"
+  ];
+
+  postPatch = ''
+    # For the default config to work, we have to put `static/data` and
+    # `db.sqlite3` in a temporary directory since they need to be writeable.
+    #
+    # NOTE: Currently, `static/data` only holds the snapshots directory.
+    substituteInPlace config.yml \
+      --replace-fail 'root: "./static/data"' 'root: "/tmp/omnom/static/data"' \
+      --replace-fail 'connection: "./db.sqlite3"' 'connection: "/tmp/omnom/db.sqlite3"' \
+      --replace-fail 'debug: true' 'debug: false'
+  '';
+
+  postInstall = ''
+    mkdir -p $out/share
+    cp -r config.yml static templates $out/share
+
+    wrapProgram $out/bin/omnom \
+      --chdir $out/share \
+      --set-default GIN_MODE release
+  '';
+
+  meta = {
+    description = "A webpage bookmarking and snapshotting service";
+    homepage = "https://github.com/asciimoo/omnom";
+    license = lib.licenses.agpl3Only;
+    maintainers = lib.teams.ngi.members;
+    mainProgram = "omnom";
+  };
+}