From 3f1147d87e5da3109bc8203a1ac411bce39258fa Mon Sep 17 00:00:00 2001 From: Kopatz <7265381+Kropatz@users.noreply.github.com> Date: Sun, 9 Mar 2025 19:15:20 +0100 Subject: [PATCH] update --- flake.lock | 268 +++++++++++++---------------------- pkgs/default.nix | 2 + pkgs/electron27/default.nix | 162 +++++++++++++++++++++ pkgs/logseq/default.nix | 99 +++++++++++++ systems/pc/configuration.nix | 1 - systems/pc/zen.nix | 28 ---- 6 files changed, 364 insertions(+), 196 deletions(-) create mode 100644 pkgs/electron27/default.nix create mode 100644 pkgs/logseq/default.nix delete mode 100644 systems/pc/zen.nix diff --git a/flake.lock b/flake.lock index a4c76d5..2761ad5 100644 --- a/flake.lock +++ b/flake.lock @@ -130,27 +130,6 @@ "type": "github" } }, - "devshell": { - "inputs": { - "nixpkgs": [ - "nixvim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1735644329, - "narHash": "sha256-tO3HrHriyLvipc4xr+Ewtdlo7wM1OjXNjlWRgmM7peY=", - "owner": "numtide", - "repo": "devshell", - "rev": "f7795ede5b02664b57035b3b757876703e2c3eac", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "devshell", - "type": "github" - } - }, "disko": { "inputs": { "nixpkgs": [ @@ -158,11 +137,11 @@ ] }, "locked": { - "lastModified": 1739841949, - "narHash": "sha256-lSOXdgW/1zi/SSu7xp71v+55D5Egz8ACv0STkj7fhbs=", + "lastModified": 1740485968, + "narHash": "sha256-WK+PZHbfDjLyveXAxpnrfagiFgZWaTJglewBWniTn2Y=", "owner": "nix-community", "repo": "disko", - "rev": "15dbf8cebd8e2655a883b74547108e089f051bf0", + "rev": "19c1140419c4f1cdf88ad4c1cfb6605597628940", "type": "github" }, "original": { @@ -220,21 +199,6 @@ } }, "flake-compat_3": { - "locked": { - "lastModified": 1733328505, - "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", - "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", - "revCount": 69, - "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.1.0/01948eb7-9cba-704f-bbf3-3fa956735b52/source.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" - } - }, - "flake-compat_4": { - "flake": false, "locked": { "lastModified": 1733328505, "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", @@ -291,6 +255,28 @@ "type": "github" } }, + "flake-parts_3": { + "inputs": { + "nixpkgs-lib": [ + "stylix", + "nur", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733312601, + "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems_2" @@ -367,12 +353,12 @@ "git-hooks": { "inputs": { "flake-compat": [ - "nixvim", + "stylix", "flake-compat" ], "gitignore": "gitignore", "nixpkgs": [ - "nixvim", + "stylix", "nixpkgs" ] }, @@ -390,55 +376,7 @@ "type": "github" } }, - "git-hooks_2": { - "inputs": { - "flake-compat": [ - "stylix", - "flake-compat" - ], - "gitignore": "gitignore_2", - "nixpkgs": [ - "stylix", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1735882644, - "narHash": "sha256-3FZAG+pGt3OElQjesCAWeMkQ7C/nB1oTHLRQ8ceP110=", - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "a5a961387e75ae44cc20f0a57ae463da5e959656", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, "gitignore": { - "inputs": { - "nixpkgs": [ - "nixvim", - "git-hooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1709087332, - "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, - "gitignore_2": { "inputs": { "nixpkgs": [ "stylix", @@ -505,11 +443,11 @@ ] }, "locked": { - "lastModified": 1739913864, - "narHash": "sha256-WhzgQjadrwnwPJQLLxZUUEIxojxa7UWDkf7raAkB1Lw=", + "lastModified": 1741540808, + "narHash": "sha256-KSOHzP9gnxaF9YdtwFOPwnFvJEikg/uAvZ6M6VA/FQc=", "owner": "nix-community", "repo": "home-manager", - "rev": "97ac0801d187b2911e8caa45316399de12f6f199", + "rev": "2967de4d1146f1b6aa820eed85b823ea2ebfd0fa", "type": "github" }, "original": { @@ -566,27 +504,6 @@ "type": "github" } }, - "nix-darwin": { - "inputs": { - "nixpkgs": [ - "nixvim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1738743987, - "narHash": "sha256-O3bnAfsObto6l2tQOmQlrO6Z2kD6yKwOWfs7pA0CpOc=", - "owner": "lnl7", - "repo": "nix-darwin", - "rev": "ae406c04577ff9a64087018c79b4fdc02468c87c", - "type": "github" - }, - "original": { - "owner": "lnl7", - "repo": "nix-darwin", - "type": "github" - } - }, "nixlib": { "locked": { "lastModified": 1736643958, @@ -611,11 +528,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1739909000, - "narHash": "sha256-DsepQ7ApA4li8td4QFTmX2qs4gvCLfoN7Mlaifmji7Y=", + "lastModified": 1741532023, + "narHash": "sha256-wPoRT99r7dMQiXWzDe9v/2OSXOmGOWad/0q9norshvs=", "owner": "lilyinstarlight", "repo": "nixos-cosmic", - "rev": "5516035bb36dbb19f2bbe7b9cea6922db395e100", + "rev": "364761eb5ba3f1514446b6a0eb8e8651c5bc4c67", "type": "github" }, "original": { @@ -632,11 +549,11 @@ ] }, "locked": { - "lastModified": 1737057290, - "narHash": "sha256-3Pe0yKlCc7EOeq1X/aJVDH0CtNL+tIBm49vpepwL1MQ=", + "lastModified": 1740947705, + "narHash": "sha256-Co2kAD2SZalOm+5zoxmzEVZNvZ17TyafuFsD46BwSdY=", "owner": "nix-community", "repo": "nixos-generators", - "rev": "d002ce9b6e7eb467cd1c6bb9aef9c35d191b5453", + "rev": "507911df8c35939050ae324caccc7cf4ffb76565", "type": "github" }, "original": { @@ -647,11 +564,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1739798439, - "narHash": "sha256-GyipmjbbQEaosel/+wq1xihCKbv0/e1LU00x/8b/fP4=", + "lastModified": 1741325094, + "narHash": "sha256-RUAdT8dZ6k/486vnu3tiNRrNW6+Q8uSD2Mq7gTX4jlo=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "3e2ea8a49d4d76276b0f4e2041df8ca5c0771371", + "rev": "b48cc4dab0f9711af296fc367b6108cf7b8ccb16", "type": "github" }, "original": { @@ -669,11 +586,11 @@ ] }, "locked": { - "lastModified": 1739782332, - "narHash": "sha256-bPZKuual2WKfyHv7Wq+Owcj9R+i/qFzOWByqSS9rlxI=", + "lastModified": 1741192150, + "narHash": "sha256-wB140alXVla1Rw/kENerUoma2qO1Jy5IYWbmiSqmJu0=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "59bdbb1e75232bf1dd6d2a9313b9b6ddc5049ba2", + "rev": "0e4ccdb8181da2c6193c047b50ffee5f1a3b6dc1", "type": "github" }, "original": { @@ -684,11 +601,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1739758141, - "narHash": "sha256-uq6A2L7o1/tR6VfmYhZWoVAwb3gTy7j4Jx30MIrH0rE=", + "lastModified": 1741332913, + "narHash": "sha256-ri1e8ZliWS3Jnp9yqpKApHaOo7KBN33W8ECAKA4teAQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c618e28f70257593de75a7044438efc1c1fc0791", + "rev": "20755fa05115c84be00b04690630cb38f0a203ad", "type": "github" }, "original": { @@ -715,11 +632,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1739624908, - "narHash": "sha256-f84lBmLl4tkDp1ZU5LBTSFzlxXP4926DVW3KnXrke10=", + "lastModified": 1741332913, + "narHash": "sha256-ri1e8ZliWS3Jnp9yqpKApHaOo7KBN33W8ECAKA4teAQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a60651b217d2e529729cbc7d989c19f3941b9250", + "rev": "20755fa05115c84be00b04690630cb38f0a203ad", "type": "github" }, "original": { @@ -731,11 +648,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1739866667, - "narHash": "sha256-EO1ygNKZlsAC9avfcwHkKGMsmipUk1Uc0TbrEZpkn64=", + "lastModified": 1741379970, + "narHash": "sha256-Wh7esNh7G24qYleLvgOSY/7HlDUzWaL/n4qzlBePpiw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "73cf49b8ad837ade2de76f87eb53fc85ed5d4680", + "rev": "36fd87baa9083f34f7f5027900b62ee6d09b1f2f", "type": "github" }, "original": { @@ -763,11 +680,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1739736696, - "narHash": "sha256-zON2GNBkzsIyALlOCFiEBcIjI4w38GYOb+P+R4S8Jsw=", + "lastModified": 1741379970, + "narHash": "sha256-Wh7esNh7G24qYleLvgOSY/7HlDUzWaL/n4qzlBePpiw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "d74a2335ac9c133d6bbec9fc98d91a77f1604c1f", + "rev": "36fd87baa9083f34f7f5027900b62ee6d09b1f2f", "type": "github" }, "original": { @@ -779,24 +696,16 @@ }, "nixvim": { "inputs": { - "devshell": "devshell", - "flake-compat": "flake-compat_3", "flake-parts": "flake-parts", - "git-hooks": "git-hooks", - "home-manager": [ - "home-manager-unstable" - ], - "nix-darwin": "nix-darwin", "nixpkgs": "nixpkgs_2", - "nuschtosSearch": "nuschtosSearch", - "treefmt-nix": "treefmt-nix" + "nuschtosSearch": "nuschtosSearch" }, "locked": { - "lastModified": 1739902813, - "narHash": "sha256-BgOQcKKz7VNvSHIbBllHisv32HvF3W3ALF9sdnC++V8=", + "lastModified": 1741098523, + "narHash": "sha256-gXDSXDr6tAb+JgxGMvcEjKC9YO8tVOd8hMMZHJLyQ6Q=", "owner": "nix-community", "repo": "nixvim", - "rev": "0ab9947137cd034ec64eb5cd9ede94e53af21f50", + "rev": "03065fd4708bfdf47dd541d655392a60daa25ded", "type": "github" }, "original": { @@ -809,14 +718,37 @@ "inputs": { "flake-parts": "flake-parts_2", "nixpkgs": "nixpkgs_3", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1741541688, + "narHash": "sha256-So/foAIONGA7amt6gQez1RZOqYpFcvjeO+8g02LqfTU=", + "owner": "nix-community", + "repo": "NUR", + "rev": "55fd8b947ee109c7bc8ed6713a1e2e09d3e83c56", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "NUR", + "type": "github" + } + }, + "nur_2": { + "inputs": { + "flake-parts": "flake-parts_3", + "nixpkgs": [ + "stylix", + "nixpkgs" + ], "treefmt-nix": "treefmt-nix_2" }, "locked": { - "lastModified": 1739903703, - "narHash": "sha256-w2tTcjx39lJoPDaFbIxi+INIjAKE0jbIx9TNjj9ghmg=", + "lastModified": 1740408283, + "narHash": "sha256-2xECnhgF3MU9YjmvOkrRp8wRFo2OjjewgCtlfckhL5s=", "owner": "nix-community", "repo": "NUR", - "rev": "2215ad5c4347f522523715e809f5f2022509f504", + "rev": "496a4a11162bdffb9a7b258942de138873f019f7", "type": "github" }, "original": { @@ -874,9 +806,9 @@ "base16-helix": "base16-helix", "base16-vim": "base16-vim", "firefox-gnome-theme": "firefox-gnome-theme", - "flake-compat": "flake-compat_4", + "flake-compat": "flake-compat_3", "flake-utils": "flake-utils_3", - "git-hooks": "git-hooks_2", + "git-hooks": "git-hooks", "gnome-shell": "gnome-shell", "home-manager": [ "home-manager-unstable" @@ -884,6 +816,7 @@ "nixpkgs": [ "nixpkgs-unstable" ], + "nur": "nur_2", "systems": "systems_4", "tinted-foot": "tinted-foot", "tinted-kitty": "tinted-kitty", @@ -892,11 +825,11 @@ "tinted-zed": "tinted-zed" }, "locked": { - "lastModified": 1739909171, - "narHash": "sha256-GmuW8XkOF6lSEQBeXzUCyr6tetbbxX8wpNJlwFqT/9E=", + "lastModified": 1741533345, + "narHash": "sha256-wStpjHkVAuwYvs3oNSLWz8A2QkicfrGlP4rw2+OiyAU=", "owner": "danth", "repo": "stylix", - "rev": "aeb550add3bfa1ce3ce249c3b3dad71ebb018318", + "rev": "a76068262cfc16c04f9c07a6458715548b067450", "type": "github" }, "original": { @@ -1002,11 +935,11 @@ "tinted-schemes": { "flake": false, "locked": { - "lastModified": 1737565458, - "narHash": "sha256-y+9cvOA6BLKT0WfebDsyUpUa/YxKow9hTjBp6HpQv68=", + "lastModified": 1740351358, + "narHash": "sha256-Hdk850xgAd3DL8KX0AbyU7tC834d3Lej1jOo3duWiOA=", "owner": "tinted-theming", "repo": "schemes", - "rev": "ae31625ba47aeaa4bf6a98cf11a8d4886f9463d9", + "rev": "a1bc2bd89e693e7e3f5764cfe8114e2ae150e184", "type": "github" }, "original": { @@ -1018,11 +951,11 @@ "tinted-tmux": { "flake": false, "locked": { - "lastModified": 1735737224, - "narHash": "sha256-FO2hRBkZsjlIRqzNHCPc/52yxg11kHGA8MEtSun9RwE=", + "lastModified": 1740272597, + "narHash": "sha256-/etfUV3HzAaLW3RSJVwUaW8ULbMn3v6wbTlXSKbcoWQ=", "owner": "tinted-theming", "repo": "tinted-tmux", - "rev": "aead506a9930c717ebf81cc83a2126e9ca08fa64", + "rev": "b6c7f46c8718cc484f2db8b485b06e2a98304cd0", "type": "github" }, "original": { @@ -1050,16 +983,16 @@ "treefmt-nix": { "inputs": { "nixpkgs": [ - "nixvim", + "nur", "nixpkgs" ] }, "locked": { - "lastModified": 1738680491, - "narHash": "sha256-8X7tR3kFGkE7WEF5EXVkt4apgaN85oHZdoTGutCFs6I=", + "lastModified": 1733222881, + "narHash": "sha256-JIPcz1PrpXUCbaccEnrcUS8jjEb/1vJbZz5KkobyFdM=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "64dbb922d51a42c0ced6a7668ca008dded61c483", + "rev": "49717b5af6f80172275d47a418c9719a31a78b53", "type": "github" }, "original": { @@ -1071,6 +1004,7 @@ "treefmt-nix_2": { "inputs": { "nixpkgs": [ + "stylix", "nur", "nixpkgs" ] diff --git a/pkgs/default.nix b/pkgs/default.nix index 7312b58..6db687e 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -10,4 +10,6 @@ pkgs.callPackage ./website/default.nix { inherit kop-hub ente-frontend; }; sddm-astronaut = pkgs.callPackage ./sddm-astronaut/default.nix { }; mangal-patched = pkgs.callPackage ./mangal/default.nix { }; + electron_27 = pkgs.callPackage ./electron27/default.nix { }; + logseq = pkgs.callPackage ./logseq/default.nix { inherit electron_27; }; } diff --git a/pkgs/electron27/default.nix b/pkgs/electron27/default.nix new file mode 100644 index 0000000..0123155 --- /dev/null +++ b/pkgs/electron27/default.nix @@ -0,0 +1,162 @@ +{ lib, stdenv, libXScrnSaver, makeWrapper, fetchurl, wrapGAppsHook3, glib, gtk3 +, unzip, at-spi2-atk, libdrm, libgbm, libxkbcommon, libxshmfence, libGL +, vulkan-loader, alsa-lib, cairo, cups, dbus, expat, gdk-pixbuf, nss, nspr, xorg +, pango, systemd, pciutils, }: + +let + version = "27.3.11"; + hashes = { + "aarch64-darwin" = + "a687b199fcb9890f43af90ac8a4d19dc7b15522394de89e42abd5f5c6b735804"; + "aarch64-linux" = + "ddbfcd5e04450178ca4e3113f776893454822af6757761adc792692f7978e0df"; + "armv7l-linux" = + "012127a3edf79e0e4623a08e853286e1cba512438a0414b1ab19b75d929c1cf2"; + "headers" = "0vrjdvqllfyz09sw2y078mds1di219hnmska8bw8ni7j35wxr2br"; + "x86_64-darwin" = + "357e70a1c8848d4ac7655346bec98dd18a7c0cee82452a7edf76142017779049"; + "x86_64-linux" = + "e3a6f55e54e7a623bba1a15016541248408eef5a19ab82a59d19c807aab14563"; + + }; + pname = "electron"; + + meta = with lib; { + description = "Cross platform desktop application shell"; + homepage = "https://github.com/electron/electron"; + license = licenses.mit; + mainProgram = "electron"; + maintainers = with maintainers; [ yayayayaka teutat3s ]; + platforms = + [ "x86_64-darwin" "x86_64-linux" "armv7l-linux" "aarch64-linux" ] + ++ optionals (versionAtLeast version "11.0.0") [ "aarch64-darwin" ] + ++ optionals (versionOlder version "19.0.0") [ "i686-linux" ]; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + # https://www.electronjs.org/docs/latest/tutorial/electron-timelines + knownVulnerabilities = optional (versionOlder version "32.0.0") + "Electron version ${version} is EOL"; + }; + + fetcher = vers: tag: hash: + fetchurl { + url = + "https://github.com/electron/electron/releases/download/v${vers}/electron-v${vers}-${tag}.zip"; + sha256 = hash; + }; + + headersFetcher = vers: hash: + fetchurl { + url = + "https://artifacts.electronjs.org/headers/dist/v${vers}/node-v${vers}-headers.tar.gz"; + sha256 = hash; + }; + + tags = { + x86_64-linux = "linux-x64"; + armv7l-linux = "linux-armv7l"; + aarch64-linux = "linux-arm64"; + x86_64-darwin = "darwin-x64"; + } // lib.optionalAttrs (lib.versionAtLeast version "11.0.0") { + aarch64-darwin = "darwin-arm64"; + } // lib.optionalAttrs (lib.versionOlder version "19.0.0") { + i686-linux = "linux-ia32"; + }; + + get = as: platform: + as.${platform.system} or (throw "Unsupported system: ${platform.system}"); + + common = platform: { + inherit pname version meta; + src = fetcher version (get tags platform) (get hashes platform); + passthru.headers = headersFetcher version hashes.headers; + }; + + electronLibPath = lib.makeLibraryPath ([ + alsa-lib + at-spi2-atk + cairo + cups + dbus + expat + gdk-pixbuf + glib + gtk3 + nss + nspr + xorg.libX11 + xorg.libxcb + xorg.libXcomposite + xorg.libXdamage + xorg.libXext + xorg.libXfixes + xorg.libXrandr + xorg.libxkbfile + pango + pciutils + stdenv.cc.cc + systemd + ] ++ lib.optionals (lib.versionAtLeast version "9.0.0") [ libdrm libgbm ] + ++ lib.optionals (lib.versionOlder version "10.0.0") [ libXScrnSaver ] + ++ lib.optionals (lib.versionAtLeast version "11.0.0") [ libxkbcommon ] + ++ lib.optionals (lib.versionAtLeast version "12.0.0") [ libxshmfence ] + ++ lib.optionals (lib.versionAtLeast version "17.0.0") [ + libGL + vulkan-loader + ]); + + linux = finalAttrs: { + buildInputs = [ glib gtk3 ]; + + nativeBuildInputs = [ unzip makeWrapper wrapGAppsHook3 ]; + + dontUnpack = true; + dontBuild = true; + + installPhase = '' + mkdir -p $out/libexec/electron $out/bin + unzip -d $out/libexec/electron $src + ln -s $out/libexec/electron/electron $out/bin + chmod u-x $out/libexec/electron/*.so* + ''; + + postFixup = '' + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${electronLibPath}:$out/libexec/electron" \ + $out/libexec/electron/.electron-wrapped \ + ${ + lib.optionalString (lib.versionAtLeast version "15.0.0") + "$out/libexec/electron/.chrome_crashpad_handler-wrapped" + } + + # patch libANGLE + patchelf \ + --set-rpath "${lib.makeLibraryPath [ libGL pciutils vulkan-loader ]}" \ + $out/libexec/electron/lib*GL* + + # replace bundled vulkan-loader + rm "$out/libexec/electron/libvulkan.so.1" + ln -s -t "$out/libexec/electron" "${ + lib.getLib vulkan-loader + }/lib/libvulkan.so.1" + ''; + + passthru.dist = finalAttrs.finalPackage + "/libexec/electron"; + }; + + darwin = finalAttrs: { + nativeBuildInputs = [ makeWrapper unzip ]; + + buildCommand = '' + mkdir -p $out/Applications + unzip $src + mv Electron.app $out/Applications + mkdir -p $out/bin + makeWrapper $out/Applications/Electron.app/Contents/MacOS/Electron $out/bin/electron + ''; + + passthru.dist = finalAttrs.finalPackage + "/Applications"; + }; +in stdenv.mkDerivation (finalAttrs: + lib.recursiveUpdate (common stdenv.hostPlatform) + ((if stdenv.hostPlatform.isDarwin then darwin else linux) finalAttrs)) diff --git a/pkgs/logseq/default.nix b/pkgs/logseq/default.nix new file mode 100644 index 0000000..e815a18 --- /dev/null +++ b/pkgs/logseq/default.nix @@ -0,0 +1,99 @@ +{ lib +, stdenv +, fetchurl +, appimageTools +, unzip +, makeWrapper + # Notice: graphs will not sync without matching upstream's major electron version + # the specific electron version is set at top-level file to preserve override interface. + # whenever updating this package also sync electron version at top-level file. +, electron_27 +, autoPatchelfHook +, git +, nix-update-script +}: + +stdenv.mkDerivation (finalAttrs: +let + inherit (finalAttrs) pname version src; + inherit (stdenv.hostPlatform) system; + selectSystem = attrs: attrs.${system} or (throw "Unsupported system: ${system}"); + suffix = selectSystem { + x86_64-linux = "linux-x64-${version}.AppImage"; + x86_64-darwin = "darwin-x64-${version}.zip"; + aarch64-darwin = "darwin-arm64-${version}.zip"; + }; + hash = selectSystem { + x86_64-linux = "sha256-XROuY2RlKnGvK1VNvzauHuLJiveXVKrIYPppoz8fCmc="; + x86_64-darwin = "sha256-0i9ozqBSeV/y8v+YEmQkbY0V6JHOv6tKub4O5Fdx2fQ="; + aarch64-darwin = "sha256-Uvv96XWxpFj14wPH0DwPT+mlf3Z2dy1g/z8iBt5Te7Q="; + }; +in +{ + pname = "logseq"; + version = "0.10.9"; + src = fetchurl { + inherit hash; + url = "https://github.com/logseq/logseq/releases/download/${version}/logseq-${suffix}"; + name = lib.optionalString stdenv.hostPlatform.isLinux "logseq-${version}.AppImage"; + }; + + nativeBuildInputs = [ makeWrapper ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ unzip ]; + buildInputs = [ (lib.getLib stdenv.cc.cc) ]; + + dontUnpack = stdenv.hostPlatform.isLinux; + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + '' + lib.optionalString stdenv.hostPlatform.isLinux ( + let + appimageContents = appimageTools.extract { inherit pname src version; }; + in + '' + mkdir -p $out/bin $out/share/logseq $out/share/applications + cp -a ${appimageContents}/{locales,resources} $out/share/logseq + cp -a ${appimageContents}/Logseq.desktop $out/share/applications/logseq.desktop + # remove the `git` in `dugite` because we want the `git` in `nixpkgs` + chmod +w -R $out/share/logseq/resources/app/node_modules/dugite/git + chmod +w $out/share/logseq/resources/app/node_modules/dugite + rm -rf $out/share/logseq/resources/app/node_modules/dugite/git + chmod -w $out/share/logseq/resources/app/node_modules/dugite + mkdir -p $out/share/pixmaps + ln -s $out/share/logseq/resources/app/icons/logseq.png $out/share/pixmaps/logseq.png + substituteInPlace $out/share/applications/logseq.desktop \ + --replace Exec=Logseq Exec=logseq \ + --replace Icon=Logseq Icon=logseq + '' + ) + lib.optionalString stdenv.hostPlatform.isDarwin '' + mkdir -p $out/{Applications/Logseq.app,bin} + cp -R . $out/Applications/Logseq.app + makeWrapper $out/Applications/Logseq.app/Contents/MacOS/Logseq $out/bin/logseq + '' + '' + runHook postInstall + ''; + + postFixup = lib.optionalString stdenv.hostPlatform.isLinux '' + # set the env "LOCAL_GIT_DIRECTORY" for dugite so that we can use the git in nixpkgs + makeWrapper ${electron_27}/bin/electron $out/bin/logseq \ + --set "LOCAL_GIT_DIRECTORY" ${git} \ + --add-flags $out/share/logseq/resources/app \ + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" + ''; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "Local-first, non-linear, outliner notebook for organizing and sharing your personal knowledge base"; + homepage = "https://github.com/logseq/logseq"; + changelog = "https://github.com/logseq/logseq/releases/tag/${version}"; + license = lib.licenses.agpl3Plus; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + maintainers = with lib.maintainers; [ cheeseecake ]; + platforms = [ "x86_64-linux" ] ++ lib.platforms.darwin; + mainProgram = "logseq"; + }; +}) diff --git a/systems/pc/configuration.nix b/systems/pc/configuration.nix index 38b4b75..8f1c189 100644 --- a/systems/pc/configuration.nix +++ b/systems/pc/configuration.nix @@ -101,7 +101,6 @@ environment.systemPackages = with pkgs; [ libimobiledevice ifuse # optional, to mount using 'ifuse' - (callPackage ./zen.nix {}) ]; nixpkgs.config.permittedInsecurePackages = [ diff --git a/systems/pc/zen.nix b/systems/pc/zen.nix deleted file mode 100644 index d9ccea4..0000000 --- a/systems/pc/zen.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ appimageTools, fetchurl, ... }: -let - pname = "zen"; - version = "latest"; - - src = fetchurl { - url = "https://github.com/zen-browser/desktop/releases/latest/download/zen-x86_64.AppImage"; - sha256 = "sha256-hZiJ8JLzLhtD1W8DAso3yBAJYhFE+nJEbQJa59AWjnU="; - }; - - appimageContents = appimageTools.extract { - inherit pname version src; - }; -in -appimageTools.wrapType2 { - inherit pname version src; - - extraInstallCommands = '' - # Install .desktop file - install -m 444 -D ${appimageContents}/zen.desktop $out/share/applications/${pname}.desktop - # Install icon - install -m 444 -D ${appimageContents}/zen.png $out/share/icons/hicolor/128x128/apps/${pname}.png - ''; - - meta = { - platforms = [ "x86_64-linux" ]; - }; -}