-
Notifications
You must be signed in to change notification settings - Fork 18
/
builtin.go
59 lines (50 loc) · 1.06 KB
/
builtin.go
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
package main
import (
"io/ioutil"
)
// Builtin VMs
type app struct {
Name string
Nix []byte
}
var builtin_chromium_nix = app{
Name: "chromium",
Nix: []byte(`
{pkgs, ...}:
let
application = "${pkgs.chromium}/bin/chromium";
appRunner = pkgs.writeShellScriptBin "app" ''
ARGS_FILE=/home/user/.args
ARGS=$(cat $ARGS_FILE)
rm $ARGS_FILE
${application} $ARGS
systemctl poweroff
'';
in {
imports = [
<nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
<nix/base.nix>
];
programs.chromium = {
enable = true;
extensions = [
"cjpalhdlnbpafiamejdnhcphjbkeiagm" # uBlock Origin
"gcbommkclmclpchllfjekcdonpmejbdp" # HTTPS Everywhere
"fihnjjcciajhdojfnbdddfaoknhalnja" # I don't care about cookies
];
};
services.xserver.displayManager.sessionCommands = "${appRunner}/bin/app &";
}
`),
}
func writeBuiltinApps(path string) (err error) {
for _, f := range []app{
builtin_chromium_nix,
} {
err = ioutil.WriteFile(configDir+"/nix/"+f.Name+".nix", f.Nix, 0644)
if err != nil {
return
}
}
return
}