From 87292d7f589f13d77c6372dcd81feda0613bc620 Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Tue, 13 Jun 2023 10:42:46 +0100 Subject: [PATCH] Improve Qutebrowser and Wayland setup --- flake.lock | 42 ++++++++++---------- flake.nix | 11 ++++- system/ritchie.nix | 10 +++++ system/shared-configuration.nix | 11 +++++ users/tsv/home.nix | 7 +++- users/tsv/hyprland/hyprland.conf | 10 ++--- users/tsv/qutebrowser/config.py | 3 ++ users/tsv/qutebrowser/userscripts/qute-1pass | 10 ++--- users/tsv/work-packages.nix | 1 - 9 files changed, 70 insertions(+), 35 deletions(-) diff --git a/flake.lock b/flake.lock index 26c466e..30f5201 100644 --- a/flake.lock +++ b/flake.lock @@ -8,11 +8,11 @@ ] }, "locked": { - "lastModified": 1686363992, - "narHash": "sha256-OmWKx1axmCrdTWvjidtfrMCAs63G6yU0kzP4cdslYqU=", + "lastModified": 1686623080, + "narHash": "sha256-Be9a89KBd5t4sh9eIcU9FMzZuNWxwtSutkGQLQ4MhHU=", "owner": "jcdickinson", "repo": "codeium.nvim", - "rev": "b1ff0d6c993e3d87a4362d2ccd6c660f7444599f", + "rev": "cfa9100f81133b64c32ab6a19396492515eac0e5", "type": "github" }, "original": { @@ -136,11 +136,11 @@ ] }, "locked": { - "lastModified": 1686391840, - "narHash": "sha256-5S0APl6Mfm6a37taHwvuf11UHnAX0+PnoWQbsYbMUnc=", + "lastModified": 1686639065, + "narHash": "sha256-ZBDPI1GCsZaQBzPd6zjowqfNj58sRE+PTpZiThQCj68=", "owner": "nix-community", "repo": "home-manager", - "rev": "0144ac418ef633bfc9dbd89b8c199ad3a617c59f", + "rev": "d437f0d4e0f72fe76688142e954a4a9b61ac9833", "type": "github" }, "original": { @@ -154,11 +154,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1686236640, - "narHash": "sha256-HUqtNdiwMbNvgSWFYAy/b8vcnZbqoHGzZj5D7NrzjxA=", + "lastModified": 1686564083, + "narHash": "sha256-fBstj/fGsIuy05aBT2djyRsreIkGdjqslVBDtLlzpGs=", "owner": "hyprwm", "repo": "contrib", - "rev": "eece565c149e13cedf02d07d248f1697db5be400", + "rev": "f698ac5c135498224198687b32a524248b9f4e61", "type": "github" }, "original": { @@ -175,11 +175,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1686392880, - "narHash": "sha256-CI0n8XDenLWjgv3LeWyv4CezttxojkV9jMb6OLmSOzA=", + "lastModified": 1686588433, + "narHash": "sha256-qWuFScv2cokEaH1As3iH5J7fQeYoww6GghrtB96sS0g=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "003993337a96494881b9d43bdf8955fd0813ada8", + "rev": "528cfc28891431be116bcaed7e72d4f8497ed009", "type": "github" }, "original": { @@ -315,11 +315,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1685655444, - "narHash": "sha256-6EujQNAeaUkWvpEZZcVF8qSfQrNVWFNNGbUJxv/A5a8=", + "lastModified": 1686501370, + "narHash": "sha256-G0WuM9fqTPRc2URKP9Lgi5nhZMqsfHGrdEbrLvAPJcg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e635192892f5abbc2289eaac3a73cdb249abaefd", + "rev": "75a5ebf473cd60148ba9aec0d219f72e5cf52519", "type": "github" }, "original": { @@ -331,11 +331,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1686319658, - "narHash": "sha256-tGWdoUAqKnE866mYFlEfc2a99kxFy31hOQJH5YQKrTQ=", + "lastModified": 1686501370, + "narHash": "sha256-G0WuM9fqTPRc2URKP9Lgi5nhZMqsfHGrdEbrLvAPJcg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "ae766d59b07c450e0f1de8a1bfd6529089f40849", + "rev": "75a5ebf473cd60148ba9aec0d219f72e5cf52519", "type": "github" }, "original": { @@ -403,11 +403,11 @@ "flake": false, "locked": { "host": "gitlab.freedesktop.org", - "lastModified": 1685803001, - "narHash": "sha256-yxq/U9zL1ssFZtgT27A96UKteCiKb3zSmbA/dokK76U=", + "lastModified": 1686573751, + "narHash": "sha256-5vnFxEMvn4wzT+XKR5Jo8VSn1hXrdf/mWuTmdHhRFBs=", "owner": "wlroots", "repo": "wlroots", - "rev": "b61d5922f1d0910a848deb100570ad8587aea38d", + "rev": "6e8fb5509f2c94d09d4efa0f9b1f40b37bf73863", "type": "gitlab" }, "original": { diff --git a/flake.nix b/flake.nix index 4c7176c..93f2f6c 100644 --- a/flake.nix +++ b/flake.nix @@ -28,7 +28,16 @@ ./system/ritchie.nix hyprland.nixosModules.default - { programs.hyprland.enable = true; } + { + programs.hyprland = { + enable = true; + nvidiaPatches = true; + xwayland = { + enable = true; + hidpi = true; + }; + }; + } home-manager.nixosModules.home-manager { home-manager = { diff --git a/system/ritchie.nix b/system/ritchie.nix index 238496c..242f96f 100644 --- a/system/ritchie.nix +++ b/system/ritchie.nix @@ -29,4 +29,14 @@ in ../users/foxsoft/authorized_keys ]; }; + + # Enable the 1Password CLI, this also enables a SGUID wrapper so the CLI can authorize against the GUI app + programs._1password = { + enable = true; + }; + + # Enable the 1Passsword GUI with myself as an authorized user for polkit + programs._1password-gui = { + enable = true; + }; } diff --git a/system/shared-configuration.nix b/system/shared-configuration.nix index 353a4e3..4eeb7b8 100644 --- a/system/shared-configuration.nix +++ b/system/shared-configuration.nix @@ -11,6 +11,8 @@ i18n.defaultLocale = "en_GB.UTF-8"; time.timeZone = "Europe/London"; + security.polkit.enable = true; + # Enable sound. security.rtkit.enable = true; services.pipewire = { @@ -91,6 +93,15 @@ settings.PasswordAuthentication = false; }; + xdg.mime.enable = true; + xdg.mime.defaultApplications = { + "text/html" = "org.qutebrowser.qutebrowser.desktop"; + "x-scheme-handler/http" = "org.qutebrowser.qutebrowser.desktop"; + "x-scheme-handler/https" = "org.qutebrowser.qutebrowser.desktop"; + "x-scheme-handler/about" = "org.qutebrowser.qutebrowser.desktop"; + "x-scheme-handler/unknown" = "org.qutebrowser.qutebrowser.desktop"; + }; + system.stateVersion = "22.11"; # Don't change this } diff --git a/users/tsv/home.nix b/users/tsv/home.nix index 570d845..e4c349a 100644 --- a/users/tsv/home.nix +++ b/users/tsv/home.nix @@ -16,7 +16,9 @@ home.sessionVariables = { EDITOR = "nvim"; - MOZ_ENABLE_WAYLAND = 1; + MOZ_ENABLE_WAYLAND = "1"; + DEFAULT_BROWSER = "${pkgs.qutebrowser}/bin/qutebrowser"; # Used by Electron apps + NIXOS_OZONE_WL = "1"; # Wayland in Slack }; programs.tmux = { @@ -78,7 +80,8 @@ xdg.configFile."rofi/config.rasi".source = ./rofi/config.rasi; xdg.configFile."qutebrowser/config.py".source = ./qutebrowser/config.py; xdg.configFile."qutebrowser/gruvbox.py".source = ./qutebrowser/gruvbox.py; - home.file.".local/share/qutebrowser/userscripts/qute-1pass".source = .qutebrowser/userscripts/qute-1pass; + home.file.".local/share/qutebrowser/userscripts/qute-1pass".source = ./qutebrowser/userscripts/qute-1pass; + home.file.".local/share/qutebrowser/userscripts/qute-1pass".executable = true; home.file.".ssh/config".source = ./ssh/config; home.file.".LESS_TERMCAP".source = ./LESS_TERMCAP; diff --git a/users/tsv/hyprland/hyprland.conf b/users/tsv/hyprland/hyprland.conf index e0981cc..a7bfddb 100644 --- a/users/tsv/hyprland/hyprland.conf +++ b/users/tsv/hyprland/hyprland.conf @@ -1,9 +1,9 @@ # NVidia stuff -#env = LIBVA_DRIVER_NAME,nvidia -#env = XDG_SESSION_TYPE,wayland -#env = GBM_BACKEND,nvidia-drm -#env = __GLX_VENDOR_LIBRARY_NAME,nvidia -#env = WLR_NO_HARDWARE_CURSORS,1 +# env = LIBVA_DRIVER_NAME,nvidia +# env = XDG_SESSION_TYPE,wayland +# env = GBM_BACKEND,nvidia-drm +# env = __GLX_VENDOR_LIBRARY_NAME,nvidia +# env = WLR_NO_HARDWARE_CURSORS,1 monitor=eDP-1, preferred, auto, 1 monitor=DP-2, preferred, auto, auto diff --git a/users/tsv/qutebrowser/config.py b/users/tsv/qutebrowser/config.py index 64666ae..9f36e6e 100644 --- a/users/tsv/qutebrowser/config.py +++ b/users/tsv/qutebrowser/config.py @@ -12,5 +12,8 @@ config.bind(',b', 'spawn --userscript qute-bitwarden') config.bind(',p', 'spawn --userscript qute-1pass') config.bind(',f', 'spawn -d firefox {url}') config.bind(',c', 'spawn -d chromium {url}') +config.bind(',e', 'spawn -d microsoft-edge {url}') config.source('gruvbox.py') + +config.set("content.headers.user-agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36") diff --git a/users/tsv/qutebrowser/userscripts/qute-1pass b/users/tsv/qutebrowser/userscripts/qute-1pass index 091f841..34bee02 100644 --- a/users/tsv/qutebrowser/userscripts/qute-1pass +++ b/users/tsv/qutebrowser/userscripts/qute-1pass @@ -70,19 +70,19 @@ echo "message-info 'Looking for password for $URL...'" >> "$QUTE_FIFO" if [ -f "$TOKEN_CACHE" ]; then TOKEN=$(cat "$TOKEN_CACHE") - if ! op signin --session="$TOKEN" --output=raw > /dev/null; then - TOKEN=$(rofi -dmenu -password -p "1password: "| op signin --output=raw) || TOKEN="" + if ! op signin --session="$TOKEN" --raw > /dev/null; then + TOKEN=$(rofi -dmenu -password -p "1password: "| op signin) || TOKEN="" echo "$TOKEN" > "$TOKEN_CACHE" fi else - TOKEN=$(rofi -dmenu -password -p "1password: "| op signin --output=raw) || TOKEN="" + TOKEN=$(rofi -dmenu -password -p "1password: "| op signin --raw) || TOKEN="" install -m 600 /dev/null "$TOKEN_CACHE" echo "$TOKEN" > "$TOKEN_CACHE" fi if [ -n "$TOKEN" ]; then - UUID=$(op list items --cache --session="$TOKEN" | jq --arg url "$URL" -r '[.[] | {uuid, url: [.overview.URLs[]?.u, .overview.url][]?} | select(.uuid != null) | select(.url != null) | select(.url|test(".*\($url).*"))][.0].uuid') || UUID="" + UUID=$(op list items --cache --session="$TOKEN" | jq --arg url "$URL" -r '[.[] | {uuid, url: [.overview.URLs[]?.u, .overview.url][]?} | select(.uuid != null) | select(.url != null) | select(.url|test(".*\($url).*"))][.0].uuid') || UUID="" if [ -z "$UUID" ] || [ "$UUID" == "null" ];then echo "message-error 'No entry found for $URL'" >> "$QUTE_FIFO" @@ -111,7 +111,7 @@ if [ -n "$TOKEN" ]; then TOTP=$(echo "$ITEM" | op get totp --cache --session="$TOKEN" "$UUID") || TOTP="" if [ -n "$TOTP" ]; then echo "$TOTP" | xclip -in -selection clipboard - echo "message-info 'Pasted one time password for $TITLE to clipboard'" >> "$QUTE_FIFO" + echo "message-info 'Pasted one time password for $TITLE to clipboard'" >> "$QUTE_FIFO" fi else echo "message-error 'No password found for $URL'" >> "$QUTE_FIFO" diff --git a/users/tsv/work-packages.nix b/users/tsv/work-packages.nix index 4db883d..68af2a7 100644 --- a/users/tsv/work-packages.nix +++ b/users/tsv/work-packages.nix @@ -2,7 +2,6 @@ { home.packages = with pkgs; [ - _1password-gui awscli2 awsebcli gitflow