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;
|
2016-10-11 15:37:12 +00:00
|
|
|
|
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)
|
2016-10-11 15:37:12 +00:00
|
|
|
case $BROWSER in
|
|
|
|
${concatMapStringsSep "\n" (n: ''
|
2017-12-05 19:03:55 +00:00
|
|
|
${n.name})
|
|
|
|
export BIN=${n.value.path}/bin/${n.name}
|
2016-10-11 15:37:12 +00:00
|
|
|
;;
|
2017-12-05 19:03:55 +00:00
|
|
|
'') (sortedPaths)}
|
2016-10-11 15:37:12 +00:00
|
|
|
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
|
|
|
};
|
2018-04-05 15:35:25 +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-04-05 15:35:25 +00:00
|
|
|
'')
|
|
|
|
];
|
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 ''
|
|
|
|
${pkgs.firefox-devedition-bin}/bin/firefox-devedition "$@"
|
|
|
|
'') name groups precedence 80;
|
2015-09-19 21:42:05 +00:00
|
|
|
|
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 {
|
|
|
|
|
2016-10-11 15:37:12 +00:00
|
|
|
lass.browser.select = browser-select;
|
|
|
|
|
2015-09-05 10:13:14 +00:00
|
|
|
environment.systemPackages = [
|
2016-10-11 15:37:12 +00:00
|
|
|
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
|
2018-07-30 14:02:31 +00:00
|
|
|
"liloimnbhkghhdhlamdjipkmadhpcjmn" # krebsgold
|
2018-01-15 23:07:08 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2015-08-28 14:31:05 +00:00
|
|
|
imports = [
|
2016-10-11 15:37:12 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}));
|
2016-10-11 15:37:12 +00:00
|
|
|
};
|
|
|
|
}
|
2018-03-28 19:15:42 +00:00
|
|
|
( createQuteUser "qb" [ "audio" ] 20 )
|
2017-12-05 19:03:55 +00:00
|
|
|
( createFirefoxUser "ff" [ "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 )
|
2018-03-28 19:15:20 +00:00
|
|
|
( 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
|
|
|
];
|
|
|
|
}
|