From 2036170ce31a838a7df6da635d644cc1d61a585a Mon Sep 17 00:00:00 2001 From: muon Date: Wed, 24 Sep 2025 22:08:02 +0000 Subject: [PATCH] Add zmenu --- flake.lock | 48 +++---- modules/home/default.nix | 11 +- modules/home/desktop/development.nix | 44 +++++++ modules/home/desktop/i3.nix | 18 +++ modules/home/desktop/media.nix | 9 +- .../desktop/packages/stremio-linux-shell.nix | 122 ++++++++++++++++++ 6 files changed, 223 insertions(+), 29 deletions(-) create mode 100644 modules/home/desktop/packages/stremio-linux-shell.nix diff --git a/flake.lock b/flake.lock index e7b3e18..b34bc04 100644 --- a/flake.lock +++ b/flake.lock @@ -230,11 +230,11 @@ ] }, "locked": { - "lastModified": 1757075491, - "narHash": "sha256-a+NMGl5tcvm+hyfSG2DlVPa8nZLpsumuRj1FfcKb2mQ=", + "lastModified": 1758719930, + "narHash": "sha256-DgHe1026Ob49CPegPMiWj1HNtlMTGQzfSZQQVlHC950=", "owner": "nix-community", "repo": "home-manager", - "rev": "f56bf065f9abedc7bc15e1f2454aa5c8edabaacf", + "rev": "142acd7a7d9eb7f0bb647f053b4ddfd01fdfbf1d", "type": "github" }, "original": { @@ -280,11 +280,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1755253391, - "narHash": "sha256-8Muat6VcG9HsVNtyeKblnj28nnPZVPCGKh/kP3uUPeU=", + "lastModified": 1757920634, + "narHash": "sha256-MNxTc+dncIHFGKQRyAqI/Clttp3JICaSUKlMUQ6l9jc=", "owner": "thiagokokada", "repo": "nix-alien", - "rev": "e62b3ad75e8c9a5e505fc78b9b40eed1178634cb", + "rev": "f8a51ef800bc8b7420998415035f9c086eb64d5c", "type": "github" }, "original": { @@ -301,11 +301,11 @@ ] }, "locked": { - "lastModified": 1754800038, - "narHash": "sha256-UbLO8/0pVBXLJuyRizYOJigtzQAj8Z2bTnbKSec/wN0=", + "lastModified": 1757822619, + "narHash": "sha256-3HIpe3P2h1AUPYcAH9cjuX0tZOqJpX01c0iDwoUYNZ8=", "owner": "nix-community", "repo": "nix-index-database", - "rev": "b65f8d80656f9fcbd1fecc4b7f0730f468333142", + "rev": "050a5feb5d1bb5b6e5fc04a7d3d816923a87c9ea", "type": "github" }, "original": { @@ -336,11 +336,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1755027561, - "narHash": "sha256-IVft239Bc8p8Dtvf7UAACMG5P3ZV+3/aO28gXpGtMXI=", + "lastModified": 1757745802, + "narHash": "sha256-hLEO2TPj55KcUFUU1vgtHE9UEIOjRcH/4QbmfHNF820=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "005433b926e16227259a1843015b5b2b7f7d1fc3", + "rev": "c23193b943c6c689d70ee98ce3128239ed9e32d1", "type": "github" }, "original": { @@ -368,11 +368,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1756787288, - "narHash": "sha256-rw/PHa1cqiePdBxhF66V7R+WAP8WekQ0mCDG4CFqT8Y=", + "lastModified": 1758427187, + "narHash": "sha256-pHpxZ/IyCwoTQPtFIAG2QaxuSm8jWzrzBGjwQZIttJc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "d0fc30899600b9b3466ddb260fd83deb486c32f1", + "rev": "554be6495561ff07b6c724047bdd7e0716aa7b46", "type": "github" }, "original": { @@ -434,11 +434,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1757095994, - "narHash": "sha256-AXwM6/7CuQ39iwBqmc6ZNkVcCdFiK4MFRIGQgU6Mkyk=", + "lastModified": 1758271661, + "narHash": "sha256-ENqd2/33uP5vB44ClDjjAV+J78oF8q1er4QUZuT8Z7g=", "owner": "NotAShelf", "repo": "nvf", - "rev": "fb31022b366ad21951f0352f0cc282cc6a8e9e6f", + "rev": "b7571df4d6e9ac08506a738ddceeec0b141751b0", "type": "github" }, "original": { @@ -467,11 +467,11 @@ ] }, "locked": { - "lastModified": 1754988908, - "narHash": "sha256-t+voe2961vCgrzPFtZxha0/kmFSHFobzF00sT8p9h0U=", + "lastModified": 1758425756, + "narHash": "sha256-L3N8zV6wsViXiD8i3WFyrvjDdz76g3tXKEdZ4FkgQ+Y=", "owner": "Mic92", "repo": "sops-nix", - "rev": "3223c7a92724b5d804e9988c6b447a0d09017d48", + "rev": "e0fdaea3c31646e252a60b42d0ed8eafdb289762", "type": "github" }, "original": { @@ -520,11 +520,11 @@ "tinted-zed": "tinted-zed" }, "locked": { - "lastModified": 1757172691, - "narHash": "sha256-VOn/s24rb+iO6auhmGfT5kyr0ixRK6weBsNCKkGo2yY=", + "lastModified": 1758716250, + "narHash": "sha256-PvOo4vSk7WAOhSifgL+rzExihquU9DOIOQPrUVuFHpE=", "owner": "danth", "repo": "stylix", - "rev": "9991299fe9aad330fb6b96bb58def37033271177", + "rev": "526c882800837cce7676f3e11bb3e13e975c6032", "type": "github" }, "original": { diff --git a/modules/home/default.nix b/modules/home/default.nix index e587fc2..847a63b 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -1,6 +1,11 @@ -{ pkgs, lib, config, osConfig, ... }: -let cfg = osConfig.mods; - +{ + pkgs, + lib, + config, + osConfig, + ... +}: let + cfg = osConfig.mods; in { imports = [ ./terminal diff --git a/modules/home/desktop/development.nix b/modules/home/desktop/development.nix index 31a4064..cfa91fc 100644 --- a/modules/home/desktop/development.nix +++ b/modules/home/desktop/development.nix @@ -10,6 +10,50 @@ config = lib.mkIf config.mods.desktop.development.enable { # home.packages = with pkgs; [ i3-swallow ]; + programs.nyxt = { + enable = true; + config = '' + (in-package #:nyxt-user) + + (defvar *my-search-engines* + (list + (make-instance 'search-engine + :name "Searx" + :shortcut "s" + #+nyxt-4 :control-url #+nyxt-3 :search-url + ""https://search.muon.host/?q=~a";") + + (make-instance 'search-engine + :name "nixpkgs" + :shortcut "np" + #+nyxt-4 :control-url #+nyxt-3 :search-url + "https://search.nixos.org/packages?channel=unstable&query=~a"))) + + (make-instance 'search-engine + :name "nix options" + :shortcut "np" + #+nyxt-4 :control-url #+nyxt-3 :search-url + "https://search.nixos.org/options?channel=unstable&query=~a"))) + + (make-instance 'search-engine + :name "home-manager" + :shortcut "hm" + #+nyxt-4 :control-url #+nyxt-3 :search-url + "https://home-manager-options.extranix.com/?release=master&query=~a"))) + + + (define-configuration browser + ((restore-session-on-startup-p nil) + (default-new-buffer-url (quri:uri "https://online.bonjourr.fr/")) + (external-editor-program ("alacritty -e hx") + #+nyxt-4 + (search-engine-suggestions-p nil) + #+nyxt-4 + (search-engines (append %slot-default% *my-search-engines*)) + )) + ''; + }; + programs.qutebrowser = { enable = true; diff --git a/modules/home/desktop/i3.nix b/modules/home/desktop/i3.nix index f6bb38a..0c2021a 100644 --- a/modules/home/desktop/i3.nix +++ b/modules/home/desktop/i3.nix @@ -17,6 +17,23 @@ curl -H "authorization: $AUTH" https://share.muon.host/api/upload -F file=@/tmp/ss.png -H "Content-Type: multipart/form-data" -H "Format: date" -H "Image-Compression-Percent: 90" -H "No-JSON: true" | tr -d '\n' | xsel -ib; ''; }; + zmenu = with pkgs; + writeShellApplication { + name = "zmenu"; + runtimeInputs = [zellij zoxide wmctrl i3 rofi alacritty zsh]; + text = '' + ZPATH=$(zoxide query -l | sed -e "s|$HOME||g" | cut -b 2- | rofi -dmenu) + [[ -z "$ZPATH" ]] && exit + ZSESH=$(echo "$ZPATH" | tr / -) + ZWIND=$(wmctrl -l | grep "$ZSESH" || echo "") + cd "$ZPATH" + if [[ -z "$ZWIND" ]]; then + alacritty -T "$ZSESH" -e zsh -c "zellij -s $ZSESH -n compact || zellij a $ZSESH" + else + wmctrl -a "$ZSESH" + fi + ''; + }; in with lib; { options.mods.i3.enable = mkEnableOption "enables i3"; @@ -139,6 +156,7 @@ in "XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume 0 +2%"; "XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume 0 -2%"; "Print" = "exec ${getExe fsss}"; + "${modifier}+z" = "exec ${getExe zmenu}"; "${modifier}+y" = "sticky toggle"; }); diff --git a/modules/home/desktop/media.nix b/modules/home/desktop/media.nix index 4d8cfce..2f4fe79 100644 --- a/modules/home/desktop/media.nix +++ b/modules/home/desktop/media.nix @@ -1,4 +1,9 @@ -{ pkgs, lib, config, ... }: { +{ + pkgs, + lib, + config, + ... +}: { options.mods.desktop.media.enable = lib.mkEnableOption "enables entertainment programs"; @@ -9,7 +14,7 @@ pavucontrol # Video - stremio + (callPackage ./packages/stremio-linux-shell.nix {}) # Podcasts gpodder diff --git a/modules/home/desktop/packages/stremio-linux-shell.nix b/modules/home/desktop/packages/stremio-linux-shell.nix new file mode 100644 index 0000000..79ca2fc --- /dev/null +++ b/modules/home/desktop/packages/stremio-linux-shell.nix @@ -0,0 +1,122 @@ +{ + lib, + stdenv, + rustPlatform, + fetchFromGitHub, + openssl, + pkg-config, + gtk3, + mpv, + libappindicator, + libxkbcommon, + libcef, + makeWrapper, + nodejs, + # fetchurl, + ... +}: let + # cef-rs expects a specific directory layout + # Copied from https://github.com/NixOS/nixpkgs/pull/428206 because im lazy + cef-path = stdenv.mkDerivation { + pname = "cef-path"; + version = libcef.version; + dontUnpack = true; + installPhase = '' + mkdir -p "$out" + find ${libcef}/lib -type f -name "*" -exec cp {} $out/ \; + find ${libcef}/libexec -type f -name "*" -exec cp {} $out/ \; + cp -r ${libcef}/share/cef/* $out/ + mkdir -p "$out/include" + cp -r ${libcef}/include/* "$out/include/" + ''; + postFixup = '' + strip $out/*.so* + ''; + }; + # NOTE stremio downloads server.js into XDG_DATA_DIR. Packaging it is not required. + # I'm patching this because I don't enjoy stremio downloading code at runtime. + # This and the postPatch are not needed if you're okay with stremio downloading server.js at runtime + # Latest server.js version found at https://www.strem.io/updater/server/check + # server = fetchurl rec { + # pname = "stremio-server"; + # version = "4.20.11"; + # url = "https://dl.strem.io/server/v${version}/desktop/server.js"; + # hash = "sha256-2QCwUlusNTGqbOmOGjyKOx0bHaoGmn9vy93qViXx95E="; + # meta.license = lib.licenses.unfree; + # }; +in + rustPlatform.buildRustPackage (finalAttrs: { + name = "stremio-linux-shell"; + version = "1.0.0-beta.11"; + + src = fetchFromGitHub { + owner = "Stremio"; + repo = "stremio-linux-shell"; + tag = "v${finalAttrs.version}"; + hash = "sha256-FNAeur5esDqBoYlmjUO6jdi1eC83ynbLxbjH07QZ++E="; + }; + + cargoHash = "sha256-9/28BCG51jPnKXbbzzNp7KQLMkLEugFQfwszRR9kmUw="; + + # The build scripts tries to download CEF binaries by default. + # Probably overkill since setting CEF_PATH should skip downloading binaries. + buildFeatures = [ + "offline-build" + ]; + + buildInputs = [ + openssl + gtk3 + mpv + libcef + ]; + + nativeBuildInputs = [ + makeWrapper + pkg-config + ]; + + #postPatch = '' + # substituteInPlace ./src/config.rs \ + # --replace-fail \ + # 'let file = data_dir.join(SERVER_FILE);' \ + # 'let file = PathBuf::from(r"${server}");' + + # substituteInPlace ./src/server.rs \ + # --replace-fail \ + # 'let should_download = self.config.version() != Some(latest_version.clone());' \ + # 'let should_download = false;' + #''; + + postInstall = '' + mkdir -p $out/share/applications + mkdir -p $out/share/icons/hicolor/scalable/apps + + mv $out/bin/stremio-linux-shell $out/bin/stremio + cp $src/data/com.stremio.Stremio.desktop $out/share/applications/com.stremio.Stremio.desktop + cp $src/data/icons/com.stremio.Stremio.svg $out/share/icons/hicolor/scalable/apps/com.stremio.Stremio.svg + + + wrapProgram $out/bin/stremio \ + --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [libappindicator libxkbcommon]} \ + --prefix PATH : ${lib.makeBinPath [nodejs]}''; + + env.CEF_PATH = cef-path; + + meta = { + mainProgram = "stremio"; + description = "Modern media center that gives you the freedom to watch everything you want"; + homepage = "https://www.stremio.com/"; + # (Server-side) 4.x versions of the web UI are closed-source + license = with lib.licenses; [ + gpl3Only + # server.js is unfree + # unfree + ]; + maintainers = with lib.maintainers; [ + griffi-gh + {name = "nuko";} + ]; + platforms = lib.platforms.linux; + }; + })