stockholm/lass/2configs/browsers.nix

101 lines
2.8 KiB
Nix
Raw Normal View History

2015-08-28 14:31:05 +00:00
{ config, lib, pkgs, ... }:
2015-07-16 13:51:01 +00:00
2016-10-20 18:54:38 +00:00
with import <stockholm/lib>;
2015-07-16 13:51:01 +00:00
let
2016-02-21 23:50:01 +00:00
2015-07-16 13:51:01 +00:00
mainUser = config.users.extraUsers.mainUser;
2017-12-05 19:03:55 +00:00
browser-select = let
sortedPaths = sort (a: b: a.value.precedence > b.value.precedence)
(mapAttrsToList (name: value: { inherit name value; })
config.lass.browser.paths);
in pkgs.writeScriptBin "browser-select" ''
BROWSER=$(echo -e "${concatStringsSep "\\n" (map (getAttr "name") sortedPaths)}" | ${pkgs.dmenu}/bin/dmenu)
case $BROWSER in
${concatMapStringsSep "\n" (n: ''
2017-12-05 19:03:55 +00:00
${n.name})
export BIN=${n.value.path}/bin/${n.name}
;;
2017-12-05 19:03:55 +00:00
'') (sortedPaths)}
esac
$BIN "$@"
'';
2018-04-01 14:19:28 +00:00
createUser = script: name: groups: precedence: dpi:
2018-03-28 19:13:57 +00:00
{
lass.xjail.${name} = {
2018-04-01 14:19:28 +00:00
inherit script groups dpi;
2015-08-28 14:31:05 +00:00
};
environment.systemPackages = [
config.lass.xjail-bins.${name}
(pkgs.writeDashBin "cx-${name}" ''
2018-08-09 12:38:06 +00:00
DISPLAY=:${toString (genid_uint31 name)} ${pkgs.xclip}/bin/xclip -o | DISPLAY=:0 ${pkgs.xclip}/bin/xclip
'')
];
2018-01-15 23:06:52 +00:00
lass.browser.paths.${name} = {
2018-03-28 19:13:57 +00:00
path = config.lass.xjail-bins.${name};
2018-01-15 23:06:52 +00:00
inherit precedence;
};
2015-08-28 14:31:05 +00:00
};
2015-07-16 13:51:01 +00:00
2018-04-01 14:19:28 +00:00
createChromiumUser = name: groups: precedence:
createUser (pkgs.writeDash name ''
${pkgs.chromium}/bin/chromium "$@"
'') name groups precedence 80;
2018-03-28 19:13:57 +00:00
createFirefoxUser = name: groups: precedence:
2018-04-01 14:19:28 +00:00
createUser (pkgs.writeDash name ''
2018-12-16 08:36:39 +00:00
${pkgs.firefox}/bin/firefox "$@"
2018-04-01 14:19:28 +00:00
'') name groups precedence 80;
2018-03-28 19:13:57 +00:00
createQuteUser = name: groups: precedence:
2018-04-01 14:19:28 +00:00
createUser (pkgs.writeDash name ''
${pkgs.qutebrowser}/bin/qutebrowser "$@"
'') name groups precedence 60;
2015-09-05 10:13:14 +00:00
2015-07-16 13:51:01 +00:00
in {
lass.browser.select = browser-select;
2015-09-05 10:13:14 +00:00
environment.systemPackages = [
browser-select
2015-09-05 10:13:14 +00:00
];
2018-01-15 23:07:08 +00:00
programs.chromium = {
enable = true;
extensions = [
"cjpalhdlnbpafiamejdnhcphjbkeiagm" # ublock origin
"dbepggeogbaibhgnhhndojpepiihcmeb" # vimium
];
};
2015-08-28 14:31:05 +00:00
imports = [
{
options.lass.browser.select = mkOption {
type = types.path;
};
options.lass.browser.paths = mkOption {
2017-12-05 19:03:55 +00:00
type = types.attrsOf (types.submodule ({
options = {
path = mkOption {
type = types.path;
};
precedence = mkOption {
type = types.int;
default = 0;
};
};
}));
};
}
2018-12-16 13:38:05 +00:00
( createFirefoxUser "ff" [ "audio" ] 11 )
( createQuteUser "qb" [ "audio" ] 10 )
2018-07-09 16:58:49 +00:00
( createChromiumUser "cr" [ "audio" "video" ] 9 )
2017-12-05 19:03:55 +00:00
( createChromiumUser "gm" [ "video" "audio" ] 8 )
( createChromiumUser "wk" [ "audio" ] 0 )
( createChromiumUser "fb" [ "audio" ] 0 )
( createChromiumUser "com" [ "audio" ] 0 )
2018-01-15 23:07:29 +00:00
( createChromiumUser "fin" [] (-1) )
2015-07-16 13:51:01 +00:00
];
}