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 "$@"
|
|
|
|
'';
|
|
|
|
|
2017-12-05 19:03:55 +00:00
|
|
|
createChromiumUser = name: extraGroups: precedence:
|
2016-10-11 15:37:12 +00:00
|
|
|
let
|
|
|
|
bin = pkgs.writeScriptBin name ''
|
2017-02-18 19:39:14 +00:00
|
|
|
/var/run/wrappers/bin/sudo -u ${name} -i ${pkgs.chromium}/bin/chromium $@
|
2016-10-11 15:37:12 +00:00
|
|
|
'';
|
|
|
|
in {
|
2015-10-03 12:37:56 +00:00
|
|
|
users.extraUsers.${name} = {
|
|
|
|
inherit name;
|
|
|
|
inherit extraGroups;
|
|
|
|
home = "/home/${name}";
|
2016-02-21 23:50:01 +00:00
|
|
|
uid = genid name;
|
2015-10-03 12:37:56 +00:00
|
|
|
useDefaultShell = true;
|
|
|
|
createHome = true;
|
2015-08-28 14:31:05 +00:00
|
|
|
};
|
2018-01-15 23:06:52 +00:00
|
|
|
lass.browser.paths.${name} = {
|
|
|
|
path = bin;
|
|
|
|
inherit precedence;
|
|
|
|
};
|
2015-08-28 14:31:05 +00:00
|
|
|
security.sudo.extraConfig = ''
|
|
|
|
${mainUser.name} ALL=(${name}) NOPASSWD: ALL
|
|
|
|
'';
|
|
|
|
environment.systemPackages = [
|
2016-10-11 15:37:12 +00:00
|
|
|
bin
|
2015-08-28 14:31:05 +00:00
|
|
|
];
|
|
|
|
};
|
2015-07-16 13:51:01 +00:00
|
|
|
|
2017-12-05 19:03:55 +00:00
|
|
|
createFirefoxUser = name: extraGroups: precedence:
|
2016-10-11 15:37:12 +00:00
|
|
|
let
|
|
|
|
bin = pkgs.writeScriptBin name ''
|
2017-12-13 17:26:49 +00:00
|
|
|
/var/run/wrappers/bin/sudo -u ${name} -i ${pkgs.firefox-devedition-bin}/bin/firefox-devedition $@
|
2016-10-11 15:37:12 +00:00
|
|
|
'';
|
|
|
|
in {
|
2015-10-03 12:37:56 +00:00
|
|
|
users.extraUsers.${name} = {
|
|
|
|
inherit name;
|
|
|
|
inherit extraGroups;
|
|
|
|
home = "/home/${name}";
|
2016-02-21 23:50:01 +00:00
|
|
|
uid = genid name;
|
2015-10-03 12:37:56 +00:00
|
|
|
useDefaultShell = true;
|
|
|
|
createHome = true;
|
2015-09-19 21:42:05 +00:00
|
|
|
};
|
2017-12-05 19:03:55 +00:00
|
|
|
lass.browser.paths.${name} = {
|
|
|
|
path = bin;
|
|
|
|
inherit precedence;
|
|
|
|
};
|
2015-09-19 21:42:05 +00:00
|
|
|
security.sudo.extraConfig = ''
|
|
|
|
${mainUser.name} ALL=(${name}) NOPASSWD: ALL
|
|
|
|
'';
|
|
|
|
environment.systemPackages = [
|
2016-10-11 15:37:12 +00:00
|
|
|
bin
|
2015-09-19 21:42:05 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2015-09-05 10:13:14 +00:00
|
|
|
#TODO: abstract this
|
|
|
|
|
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
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
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
|
|
|
};
|
|
|
|
}
|
2017-12-05 19:03:55 +00:00
|
|
|
( createFirefoxUser "ff" [ "audio" ] 10 )
|
|
|
|
( createChromiumUser "cr" [ "video" "audio" ] 9 )
|
|
|
|
( createChromiumUser "gm" [ "video" "audio" ] 8 )
|
2018-01-15 23:07:29 +00:00
|
|
|
( createChromiumUser "wk" [ "video" "audio" ] 0 )
|
|
|
|
( createChromiumUser "fb" [ "video" "audio" ] 0 )
|
|
|
|
( createChromiumUser "com" [ "video" "audio" ] 0 )
|
|
|
|
( createChromiumUser "fin" [] (-1) )
|
2015-07-16 13:51:01 +00:00
|
|
|
];
|
|
|
|
}
|