fork/home-manager
git clone https://git.julia.blue/fork/home-manager
18791781
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6cfg = config . programs . browserpass ; 7browsers = [ "brave" "chrome" "chromium" "firefox" "librewolf" "vivaldi" ]; 8in { 9options = { 10programs . browserpass = { 11enable = mkEnableOption "the browserpass extension host application" ; 12 13browsers = mkOption { 14type = types . listOf ( types . enum browsers ); 15default = browsers ; 16example = [ "firefox" ]; 17description = "Which browsers to install browserpass for" ; 18}; 19}; 20}; 21 22config = mkIf cfg . enable { 23home . file = foldl' ( a :b :a // b ) { } ( concatMap ( x : 24with pkgs . stdenv ; 25if x == "brave" then 26let 27dir = if isDarwin then 28"Library/Application Support/BraveSoftware/Brave-Browser/NativeMessagingHosts" 29else 30".config/BraveSoftware/Brave-Browser/NativeMessagingHosts" ; 31in [{ 32# Policies are read from `/etc/brave/policies` only 33# https://github.com/brave/brave-browser/issues/19052 34" ${ dir } /com.github.browserpass.native.json" . source = 35" ${ pkgs . browserpass } /lib/browserpass/hosts/chromium/com.github.browserpass.native.json" ; 36}] 37else if x == "chrome" then 38let 39dir = if isDarwin then 40"Library/Application Support/Google/Chrome/NativeMessagingHosts" 41else 42".config/google-chrome/NativeMessagingHosts" ; 43in [{ 44" ${ dir } /com.github.browserpass.native.json" . source = 45" ${ pkgs . browserpass } /lib/browserpass/hosts/chromium/com.github.browserpass.native.json" ; 46" ${ dir } /../policies/managed/com.github.browserpass.native.json" . source = 47" ${ pkgs . browserpass } /lib/browserpass/policies/chromium/com.github.browserpass.native.json" ; 48}] 49else if x == "chromium" then 50let 51dir = if isDarwin then 52"Library/Application Support/Chromium/NativeMessagingHosts" 53else 54".config/chromium/NativeMessagingHosts" ; 55in [ 56{ 57" ${ dir } /com.github.browserpass.native.json" . source = 58" ${ pkgs . browserpass } /lib/browserpass/hosts/chromium/com.github.browserpass.native.json" ; 59} 60{ 61" ${ dir } /../policies/managed/com.github.browserpass.native.json" . source = 62" ${ pkgs . browserpass } /lib/browserpass/policies/chromium/com.github.browserpass.native.json" ; 63} 64] 65else if x == "firefox" then 66let 67dir = if isDarwin then 68"Library/Application Support/Mozilla/NativeMessagingHosts" 69else 70".mozilla/native-messaging-hosts" ; 71in [{ 72" ${ dir } /com.github.browserpass.native.json" . source = 73" ${ pkgs . browserpass } /lib/browserpass/hosts/firefox/com.github.browserpass.native.json" ; 74}] 75else if x == "librewolf" then 76let 77dir = if isDarwin then 78"Library/Application Support/LibreWolf/NativeMessagingHosts" 79else 80".librewolf/native-messaging-hosts" ; 81in [{ 82" ${ dir } /com.github.browserpass.native.json" . source = 83" ${ pkgs . browserpass } /lib/browserpass/hosts/firefox/com.github.browserpass.native.json" ; 84}] 85 86else if x == "vivaldi" then 87let 88dir = if isDarwin then 89"Library/Application Support/Vivaldi/NativeMessagingHosts" 90else 91".config/vivaldi/NativeMessagingHosts" ; 92in [{ 93" ${ dir } /com.github.browserpass.native.json" . source = 94" ${ pkgs . browserpass } /lib/browserpass/hosts/chromium/com.github.browserpass.native.json" ; 95" ${ dir } /../policies/managed/com.github.browserpass.native.json" . source = 96" ${ pkgs . browserpass } /lib/browserpass/policies/chromium/com.github.browserpass.native.json" ; 97}] 98else 99throw "unknown browser ${ x } " ) cfg . browsers ); 100}; 101}