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
|
|
|
|
|
|
|
browser-select = pkgs.writeScriptBin "browser-select" ''
|
|
|
|
BROWSER=$(echo -e "${concatStringsSep "\\n" (attrNames config.lass.browser.paths)}" | ${pkgs.dmenu}/bin/dmenu)
|
|
|
|
case $BROWSER in
|
|
|
|
${concatMapStringsSep "\n" (n: ''
|
|
|
|
${n})
|
|
|
|
export BIN=${config.lass.browser.paths.${n}}/bin/${n}
|
|
|
|
;;
|
|
|
|
'') (attrNames config.lass.browser.paths)}
|
|
|
|
esac
|
|
|
|
$BIN "$@"
|
|
|
|
'';
|
|
|
|
|
|
|
|
createChromiumUser = name: extraGroups:
|
|
|
|
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
|
|
|
};
|
2016-10-11 15:37:12 +00:00
|
|
|
lass.browser.paths.${name} = bin;
|
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
|
|
|
|
2016-10-11 15:37:12 +00:00
|
|
|
createFirefoxUser = name: extraGroups:
|
|
|
|
let
|
|
|
|
bin = pkgs.writeScriptBin name ''
|
2017-02-18 19:39:14 +00:00
|
|
|
/var/run/wrappers/bin/sudo -u ${name} -i ${pkgs.firefox}/bin/firefox $@
|
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
|
|
|
};
|
2016-10-11 15:37:12 +00:00
|
|
|
lass.browser.paths.${name} = bin;
|
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
|
|
|
];
|
|
|
|
|
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 {
|
|
|
|
type = with types; attrsOf path;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
( createFirefoxUser "ff" [ "audio" ] )
|
|
|
|
( createChromiumUser "cr" [ "video" "audio" ] )
|
|
|
|
( createChromiumUser "wk" [ "video" "audio" ] )
|
|
|
|
( createChromiumUser "fb" [ "video" "audio" ] )
|
|
|
|
( createChromiumUser "gm" [ "video" "audio" ] )
|
|
|
|
( createChromiumUser "com" [ "video" "audio" ] )
|
2015-07-16 13:51:01 +00:00
|
|
|
];
|
|
|
|
}
|