blob: 75a86db6abdfd05a0baf2a8197ea56c514a0e997 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
{ config, lib, pkgs, ... }:
with import <stockholm/lib>;
let
mainUser = config.users.extraUsers.mainUser;
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: ''
${n.name})
export BIN=${n.value.path}/bin/${n.name}
;;
'') (sortedPaths)}
esac
$BIN "$@"
'';
createChromiumUser = name: groups: precedence:
{
lass.xjail.${name} = {
user = name;
script = pkgs.writeDash name ''
${pkgs.chromium}/bin/chromium "$@"
'';
inherit groups;
};
environment.systemPackages = [ config.lass.xjail-bins.${name} ];
lass.browser.paths.${name} = {
path = config.lass.xjail-bins.${name};
inherit precedence;
};
};
createFirefoxUser = name: groups: precedence:
{
lass.xjail.${name} = {
user = name;
script = pkgs.writeDash name ''
${pkgs.firefox-devedition-bin}/bin/firefox-devedition "$@"
'';
inherit groups;
};
environment.systemPackages = [ config.lass.xjail-bins.${name} ];
lass.browser.paths.${name} = {
path = config.lass.xjail-bins.${name};
inherit precedence;
};
};
createQuteUser = name: groups: precedence:
{
lass.xjail.${name} = {
user = name;
script = pkgs.writeDash name ''
${pkgs.qutebrowser}/bin/qutebrowser "$@"
'';
inherit groups;
};
environment.systemPackages = [ config.lass.xjail-bins.${name} ];
lass.browser.paths.${name} = {
path = config.lass.xjail-bins.${name};
inherit precedence;
};
};
#TODO: abstract this
in {
lass.browser.select = browser-select;
environment.systemPackages = [
browser-select
];
programs.chromium = {
enable = true;
extensions = [
"cjpalhdlnbpafiamejdnhcphjbkeiagm" # ublock origin
"dbepggeogbaibhgnhhndojpepiihcmeb" # vimium
];
};
imports = [
{
options.lass.browser.select = mkOption {
type = types.path;
};
options.lass.browser.paths = mkOption {
type = types.attrsOf (types.submodule ({
options = {
path = mkOption {
type = types.path;
};
precedence = mkOption {
type = types.int;
default = 0;
};
};
}));
};
}
( createQuteUser "qb" [ "audio" ] 20 )
( createFirefoxUser "ff" [ "audio" ] 10 )
( createChromiumUser "cr" [ "audio" ] 9 )
( createChromiumUser "gm" [ "video" "audio" ] 8 )
( createChromiumUser "wk" [ "audio" ] 0 )
( createChromiumUser "fb" [ "audio" ] 0 )
( createChromiumUser "com" [ "audio" ] 0 )
( createChromiumUser "fin" [] (-1) )
];
}
|