l browsers: add precedence
This commit is contained in:
parent
8030352c45
commit
5747398b0e
|
@ -5,19 +5,23 @@ let
|
||||||
|
|
||||||
mainUser = config.users.extraUsers.mainUser;
|
mainUser = config.users.extraUsers.mainUser;
|
||||||
|
|
||||||
browser-select = pkgs.writeScriptBin "browser-select" ''
|
browser-select = let
|
||||||
BROWSER=$(echo -e "${concatStringsSep "\\n" (attrNames config.lass.browser.paths)}" | ${pkgs.dmenu}/bin/dmenu)
|
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
|
case $BROWSER in
|
||||||
${concatMapStringsSep "\n" (n: ''
|
${concatMapStringsSep "\n" (n: ''
|
||||||
${n})
|
${n.name})
|
||||||
export BIN=${config.lass.browser.paths.${n}}/bin/${n}
|
export BIN=${n.value.path}/bin/${n.name}
|
||||||
;;
|
;;
|
||||||
'') (attrNames config.lass.browser.paths)}
|
'') (sortedPaths)}
|
||||||
esac
|
esac
|
||||||
$BIN "$@"
|
$BIN "$@"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
createChromiumUser = name: extraGroups:
|
createChromiumUser = name: extraGroups: precedence:
|
||||||
let
|
let
|
||||||
bin = pkgs.writeScriptBin name ''
|
bin = pkgs.writeScriptBin name ''
|
||||||
/var/run/wrappers/bin/sudo -u ${name} -i ${pkgs.chromium}/bin/chromium $@
|
/var/run/wrappers/bin/sudo -u ${name} -i ${pkgs.chromium}/bin/chromium $@
|
||||||
|
@ -31,7 +35,7 @@ let
|
||||||
useDefaultShell = true;
|
useDefaultShell = true;
|
||||||
createHome = true;
|
createHome = true;
|
||||||
};
|
};
|
||||||
lass.browser.paths.${name} = bin;
|
lass.browser.paths.${name}.path = bin;
|
||||||
security.sudo.extraConfig = ''
|
security.sudo.extraConfig = ''
|
||||||
${mainUser.name} ALL=(${name}) NOPASSWD: ALL
|
${mainUser.name} ALL=(${name}) NOPASSWD: ALL
|
||||||
'';
|
'';
|
||||||
|
@ -40,7 +44,7 @@ let
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
createFirefoxUser = name: extraGroups:
|
createFirefoxUser = name: extraGroups: precedence:
|
||||||
let
|
let
|
||||||
bin = pkgs.writeScriptBin name ''
|
bin = pkgs.writeScriptBin name ''
|
||||||
/var/run/wrappers/bin/sudo -u ${name} -i ${pkgs.firefox}/bin/firefox $@
|
/var/run/wrappers/bin/sudo -u ${name} -i ${pkgs.firefox}/bin/firefox $@
|
||||||
|
@ -54,7 +58,10 @@ let
|
||||||
useDefaultShell = true;
|
useDefaultShell = true;
|
||||||
createHome = true;
|
createHome = true;
|
||||||
};
|
};
|
||||||
lass.browser.paths.${name} = bin;
|
lass.browser.paths.${name} = {
|
||||||
|
path = bin;
|
||||||
|
inherit precedence;
|
||||||
|
};
|
||||||
security.sudo.extraConfig = ''
|
security.sudo.extraConfig = ''
|
||||||
${mainUser.name} ALL=(${name}) NOPASSWD: ALL
|
${mainUser.name} ALL=(${name}) NOPASSWD: ALL
|
||||||
'';
|
'';
|
||||||
|
@ -79,14 +86,24 @@ in {
|
||||||
type = types.path;
|
type = types.path;
|
||||||
};
|
};
|
||||||
options.lass.browser.paths = mkOption {
|
options.lass.browser.paths = mkOption {
|
||||||
type = with types; attrsOf path;
|
type = types.attrsOf (types.submodule ({
|
||||||
|
options = {
|
||||||
|
path = mkOption {
|
||||||
|
type = types.path;
|
||||||
|
};
|
||||||
|
precedence = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
default = 0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
( createFirefoxUser "ff" [ "audio" ] )
|
( createFirefoxUser "ff" [ "audio" ] 10 )
|
||||||
( createChromiumUser "cr" [ "video" "audio" ] )
|
( createChromiumUser "cr" [ "video" "audio" ] 9 )
|
||||||
|
( createChromiumUser "gm" [ "video" "audio" ] 8 )
|
||||||
( createChromiumUser "wk" [ "video" "audio" ] )
|
( createChromiumUser "wk" [ "video" "audio" ] )
|
||||||
( createChromiumUser "fb" [ "video" "audio" ] )
|
( createChromiumUser "fb" [ "video" "audio" ] )
|
||||||
( createChromiumUser "gm" [ "video" "audio" ] )
|
|
||||||
( createChromiumUser "com" [ "video" "audio" ] )
|
( createChromiumUser "com" [ "video" "audio" ] )
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue