13 inherit (stdenv.hostPlatform) system;
18 description = "A powerful knowledge base that works on top of a local folder of plain text Markdown files";
19 homepage = "https://obsidian.md";
20 downloadPage = "https://github.com/obsidianmd/obsidian-releases/releases";
21 license = licenses.obsidian;
22 maintainers = with maintainers; [ atila conradmearns zaninime qbit kashw2 w-lfchen ];
25 filename = if stdenv.isDarwin then "Obsidian-${version}-universal.dmg" else "obsidian-${version}.tar.gz";
27 url = "https://github.com/obsidianmd/obsidian-releases/releases/download/v${version}/${filename}";
28 hash = if stdenv.isDarwin then "sha256-MSJmF5WddxbC/S7w2nWjlDxt5HPUDCoRFwJ2MZMH9Ks=" else "sha256-UQLljP7eZELTuHwX+OylXY+Wy2YK1ZEJX1IQfIvBLe8=";
32 url = "https://obsidian.md/images/obsidian-logo-gradient.svg";
33 hash = "sha256-EZsBuWyZ9zYJh0LDKfRAMTtnY70q6iLK/ggXlplDEoA=";
36 desktopItem = makeDesktopItem {
38 desktopName = "Obsidian";
39 comment = "Knowledge base";
42 categories = [ "Office" ];
43 mimeTypes = [ "x-scheme-handler/obsidian" ];
46 linux = stdenv.mkDerivation {
47 inherit pname version src desktopItem icon;
48 meta = meta // { platforms = [ "x86_64-linux" "aarch64-linux" ]; };
49 nativeBuildInputs = [ makeWrapper imagemagick ];
53 makeWrapper ${electron}/bin/electron $out/bin/obsidian \
54 --add-flags $out/share/obsidian/app.asar \
55 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform=wayland}}"
56 install -m 444 -D resources/app.asar $out/share/obsidian/app.asar
57 install -m 444 -D resources/obsidian.asar $out/share/obsidian/obsidian.asar
58 install -m 444 -D "${desktopItem}/share/applications/"* \
59 -t $out/share/applications/
60 for size in 16 24 32 48 64 128 256 512; do
61 mkdir -p $out/share/icons/hicolor/"$size"x"$size"/apps
62 convert -background none -resize "$size"x"$size" ${icon} $out/share/icons/hicolor/"$size"x"$size"/apps/obsidian.png
67 passthru.updateScript = writeScript "updater" ''
68 #!/usr/bin/env nix-shell
69 #!nix-shell -i bash -p curl jq common-updater-scripts
71 latestVersion="$(curl -sS https://raw.githubusercontent.com/obsidianmd/obsidian-releases/master/desktop-releases.json | jq -r '.latestVersion')"
72 update-source-version obsidian "$latestVersion"
76 darwin = stdenv.mkDerivation {
77 inherit pname version src appname;
78 meta = meta // { platforms = [ "x86_64-darwin" "aarch64-darwin" ]; };
79 sourceRoot = "${appname}.app";
80 nativeBuildInputs = [ makeWrapper undmg unzip ];
83 mkdir -p $out/{Applications/${appname}.app,bin}
84 cp -R . $out/Applications/${appname}.app
85 makeWrapper $out/Applications/${appname}.app/Contents/MacOS/${appname} $out/bin/${pname}
90 if stdenv.isDarwin then darwin else linux