From 6aea9045c799bf18a6d3c30d7a1830da2c8961e0 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Mon, 13 Nov 2023 04:03:14 +0100 Subject: [PATCH] Set up passff in favour of browserpass This also introduces a custom `satellite.toggles` module. --- home/features/cli/pass.nix | 11 ++- home/features/desktop/firefox/default.nix | 47 +++++++----- home/features/neovim/default.nix | 90 ++++++++++++----------- modules/common/default.nix | 1 + modules/common/toggles.nix | 10 +++ modules/home-manager/firefox/default.nix | 2 +- 6 files changed, 94 insertions(+), 67 deletions(-) create mode 100644 modules/common/toggles.nix diff --git a/home/features/cli/pass.nix b/home/features/cli/pass.nix index 2b73b94..5088592 100644 --- a/home/features/cli/pass.nix +++ b/home/features/cli/pass.nix @@ -12,10 +12,13 @@ in enable = true; }; - home.packages = lib.mkIf config.programs.wofi.enable [ - pkgs.wofi-pass - ]; + # Enable runner integration + home.packages = lib.lists.optional config.programs.wofi.enable pkgs.wofi-pass; + + # Enable the firefox extension + home.file.".mozilla/native-messaging-hosts/passff.json".source = + lib.mkIf config.programs.firefox.enable + "${pkgs.passff-host}/lib/mozilla/native-messaging-hosts/passff.json"; - programs.browserpass.enable = config.programs.firefox.enable; satellite.persistence.at.data.apps.pass.directories = [ storePath ]; } diff --git a/home/features/desktop/firefox/default.nix b/home/features/desktop/firefox/default.nix index 85de3c0..d167b61 100644 --- a/home/features/desktop/firefox/default.nix +++ b/home/features/desktop/firefox/default.nix @@ -1,7 +1,7 @@ -{ config, pkgs, inputs, ... }: +{ config, lib, pkgs, inputs, ... }: let # {{{ Global extensions - extensions = with inputs.firefox-addons.packages.${pkgs.system}; [ + extensions = with inputs.firefox-addons.packages.${pkgs.system}; ([ buster-captcha-solver # REASON: returns 404 for now # bypass-paywalls-clean @@ -21,8 +21,10 @@ let ublock-origin unpaywall user-agent-string-switcher - browserpass # Password store support - ]; + ] ++ + # Password store support + lib.lists.optional config.programs.password-store.enable passff + ); # }}} in { @@ -47,21 +49,28 @@ in userContent = builtins.readFile ./userContent.css; # }}} # {{{ Extensions - extensions = with inputs.firefox-addons.packages.${pkgs.system}; extensions ++ [ - augmented-steam # Adds more info to steam - blocktube # Lets you block youtube channels - dearrow # Crowdsourced clickbait remover 💀 - firenvim # summon a nvim instance inside the browser - lovely-forks # displays forks on github - octolinker # github import to link thingy - octotree # github file tree - refined-github # a bunch of github modifications - return-youtube-dislikes - steam-database # adds info from steamdb on storepages - sponsorblock # skip youtube sponsors - vimium-c # vim keybinds - youtube-shorts-block - ]; + extensions = + with inputs.firefox-addons.packages.${pkgs.system}; + with lib.lists; flatten [ + extensions + # List of profile-specific extensions + [ + augmented-steam # Adds more info to steam + blocktube # Lets you block youtube channels + dearrow # Crowdsourced clickbait remover 💀 + lovely-forks # displays forks on github + octolinker # github import to link thingy + octotree # github file tree + refined-github # a bunch of github modifications + return-youtube-dislikes + steam-database # adds info from steamdb on storepages + sponsorblock # skip youtube sponsors + vimium-c # vim keybinds + youtube-shorts-block + ] + # summons a nvim instance inside the browser + (optional config.satellite.toggles.neovim.enable firenvim) + ]; # }}} # {{{ Search engines search.engines = diff --git a/home/features/neovim/default.nix b/home/features/neovim/default.nix index 354c61e..e7db9ed 100644 --- a/home/features/neovim/default.nix +++ b/home/features/neovim/default.nix @@ -137,9 +137,12 @@ let in { # {{{ Basic config - # Do not manage neovim via nix + # Do not manage neovim via the default home manager module programs.neovim.enable = false; + # We still want other modules to know that we are using neovim! + satellite.toggles.neovim.enable = true; + xdg.configFile.nvim.source = config.satellite.dev.path "dotfiles/neovim"; home.sessionVariables.EDITOR = "nvim"; @@ -150,49 +153,50 @@ in ]; # }}} # {{{ Firenvim - home.file.".mozilla/native-messaging-hosts/firenvim.json".text = - let - # God knows what this does - # https://github.com/glacambre/firenvim/blob/87c9f70d3e6aa2790982aafef3c696dbe962d35b/autoload/firenvim.vim#L592 - firenvim_init = pkgs.writeText "firenvim_init.vim" '' - let g:firenvim_i=[] - let g:firenvim_o=[] - let g:Firenvim_oi={i,d,e->add(g:firenvim_i,d)} - let g:Firenvim_oo={t->[chansend(2,t)]+add(g:firenvim_o,t)} - let g:firenvim_c=stdioopen({'on_stdin':{i,d,e->g:Firenvim_oi(i,d,e)},'on_print':{t->g:Firenvim_oo(t)}}) - let g:started_by_firenvim = v:true - ''; + home.file.".mozilla/native-messaging-hosts/firenvim.json" = + lib.mkIf config.programs.firefox.enable { + text = + let + # God knows what this does + # https://github.com/glacambre/firenvim/blob/87c9f70d3e6aa2790982aafef3c696dbe962d35b/autoload/firenvim.vim#L592 + firenvim_init = pkgs.writeText "firenvim_init.vim" '' + let g:firenvim_i=[] + let g:firenvim_o=[] + let g:Firenvim_oi={i,d,e->add(g:firenvim_i,d)} + let g:Firenvim_oo={t->[chansend(2,t)]+add(g:firenvim_o,t)} + let g:firenvim_c=stdioopen({'on_stdin':{i,d,e->g:Firenvim_oi(i,d,e)},'on_print':{t->g:Firenvim_oo(t)}}) + let g:started_by_firenvim = v:true + ''; - firenvim_file_loaded = pkgs.writeText "firenvim_file_loaded.vim" - '' - try - call firenvim#run() - catch /Unknown function/ - call chansend(g:firenvim_c,["f\n\n\n"..json_encode({"messages":["Your plugin manager did not load the Firenvim plugin for neovim."],"version":"0.0.0"})]) - call chansend(2,["Firenvim not in runtime path. &rtp="..&rtp]) - qall! - catch - call chansend(g:firenvim_c,["l\n\n\n"..json_encode({"messages": ["Something went wrong when running firenvim. See troubleshooting guide."],"version":"0.0.0"})]) - call chansend(2,[v:exception]) - qall! - endtry - ''; - in - builtins.toJSON - { - name = "firenvim"; - description = "Turn your browser into a Neovim GUI."; - type = "stdio"; - allowed_extensions = [ "firenvim@lacamb.re" ]; - path = pkgs.writeShellScript "firenvim.sh" '' - mkdir -p /run/user/$UID/firenvim - chmod 700 /run/user/$UID/firenvim - cd /run/user/$UID/firenvim + firenvim_file_loaded = pkgs.writeText "firenvim_file_loaded.vim" '' + try + call firenvim#run() + catch /Unknown function/ + call chansend(g:firenvim_c,["f\n\n\n"..json_encode({"messages":["Your plugin manager did not load the Firenvim plugin for neovim."],"version":"0.0.0"})]) + call chansend(2,["Firenvim not in runtime path. &rtp="..&rtp]) + qall! + catch + call chansend(g:firenvim_c,["l\n\n\n"..json_encode({"messages": ["Something went wrong when running firenvim. See troubleshooting guide."],"version":"0.0.0"})]) + call chansend(2,[v:exception]) + qall! + endtry + ''; + in + builtins.toJSON { + name = "firenvim"; + description = "Turn your browser into a Neovim GUI."; + type = "stdio"; + allowed_extensions = [ "firenvim@lacamb.re" ]; + path = pkgs.writeShellScript "firenvim.sh" '' + mkdir -p /run/user/$UID/firenvim + chmod 700 /run/user/$UID/firenvim + cd /run/user/$UID/firenvim - exec '${firenvim}/bin/nvim' --headless \ - --cmd 'source "${firenvim_init}"' \ - -S '${firenvim_file_loaded}' - ''; - }; + exec '${firenvim}/bin/nvim' --headless \ + --cmd 'source "${firenvim_init}"' \ + -S '${firenvim_file_loaded}' + ''; + }; + }; # }}} } diff --git a/modules/common/default.nix b/modules/common/default.nix index 1634475..1f799d1 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -4,4 +4,5 @@ # example = import ./example.nix; lua-colorscheme = import ./lua-colorscheme.nix; theming = import ./theming.nix; + toggles = import ./toggles.nix; } diff --git a/modules/common/toggles.nix b/modules/common/toggles.nix new file mode 100644 index 0000000..7f6e005 --- /dev/null +++ b/modules/common/toggles.nix @@ -0,0 +1,10 @@ +{ lib, ... }: +{ + options.satellite.toggles = lib.mkOption { + default = { }; + description = "Record of custom toggles to use throughput the config"; + type = lib.types.attrsOf (lib.types.submodule (name: { + options.enable = lib.mkEnableOption "Toggle for ${name}"; + })); + }; +} diff --git a/modules/home-manager/firefox/default.nix b/modules/home-manager/firefox/default.nix index 3476217..99a91c8 100644 --- a/modules/home-manager/firefox/default.nix +++ b/modules/home-manager/firefox/default.nix @@ -76,7 +76,7 @@ in terminal = false; name = app.displayName; type = "Application"; - exec = "firefox --name=${app.displayName} --no-remote -P \"${app.name}\" \"${app.url}\""; + exec = "firefox --name=${app.displayName} --no-remote --kiosk -P \"${app.name}\" \"${app.url}\""; icon = app.icon; }; in