blob: 0a51b68ef9b2555dad84feada755451ab81772d2 (
plain) (
blame)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
{ config, pkgs, ... }:
let
envsubstConfiguration =
pkgs.callPackage /etc/nixos/envsubst-configuration.nix { };
config = rec {
TLD = envsubstConfiguration.TLD;
openSSHPort = 23841;
};
in {
imports = [ ./hardware-configuration.nix ];
boot.loader.grub = {
enable = true;
version = 2;
device = "/dev/vda";
};
networking = {
interfaces.ens3.useDHCP = true;
};
nix = {
gc = {
automatic = true;
options = "--delete-older-than 7d";
};
# min-free 1G
extraOptions = ''
min-free = ${toString (1024 * 1024 * 1024)}
'';
};
environment = {
systemPackages = let
c99 = pkgs.tinycc.overrideAttrs (oldAttrs: {
postInstall = ''
ln -s $out/bin/tcc $out/bin/c99
'';
});
in with pkgs; [ vim git gitAndTools.git-annex gnumake gnum4 c99 bpytop ];
shellAliases = { l = "ls -lahF"; };
};
networking.firewall.allowedTCPPorts = [
# SSH: OpenSSH
config.openSSHPort
# HTTP and HTPPS: NGINX
80
443
];
security = {
acme = {
acceptTerms = true;
email = "eu@euandre.org";
};
sudo.enable = false;
doas = {
enable = true;
extraConfig = ''
permit nopass setenv { NIX_PATH } :wheel
'';
};
};
services = {
openssh = {
enable = true;
permitRootLogin = "no";
passwordAuthentication = false;
ports = [ config.openSSHPort ];
};
nginx = {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts = {
"${config.TLD}" = {
forceSSL = true;
enableACME = true;
root = "/srv/http/";
extraConfig = ''
# Allow <script type="module" src=""> 3rd-party HTML pages
add_header 'Access-Control-Allow-Origin' '*';
autoindex on;
'';
};
};
};
cron = {
enable = true;
systemCronJobs = [
"30 1 * * 1 root /opt/bin/gc.sh"
"30 0 * * * root /opt/bin/backup.sh"
];
};
};
users = {
# Improve: make mutable
mutableUsers = false;
extraUsers = let
andrehUser = {
andreh = {
uid = 1000;
isNormalUser = true;
extraGroups = [ "wheel" ];
hashedPassword = envsubstConfiguration.hashedPassword;
openssh.authorizedKeys.keys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDF+uy407LKZAFnfFkJPRiOBzwV98qIEcKhITnLYhqfITfrJvcFVOY0/YDCrs6WHXyLdM29AoywVWsQ1qXiB7xQCwknPV8YZoCnJQcn0gvH8jbCk+C8Po0Rx846wbhL49qYolnmlhe+Uoy30j7XIJSDtPVO9d/hZqt2GPwGVJ98HLyY2ak+j4i1YkHr+mPFgnCaqCAzA374d1Bop18+YENYtMMU0k8hCsomwZny/7qNo4V8mjLxQAS8FvTuljxlthEpOM4Jsjl07yDLgE69kLvU7mmFi8EeC26e50N18Ouse82dZigtVhAMeLBhbJnQbDff4WfUBzSjpKjZPGcxoRaej3qSRbIkcMMqCOSlww6GcjRi+COvlpA4c1i4hKI15wHceoiKghDLA6jbaHfOqEMldflYl5gCVUIYzJ5XehZppH6L7PzO+L4suNs+aFjWPDZ0jqEtcyTmgTMea40p7wwz086ExnBDorbG79oDiJrWc+swJjXuVakS+fQjb3mPsCC/FgUhsxEtqiVfvLo2mphp47pOYvs64aUp3RV9muqQNuS4tEuP9V1urGTLtgPL26LEjF0oLu1ag0H+VZY5O/T9KRYvWre8IWbj/KkZYo1tJaGJyEVr0plmyzLBEy8b3Hu/6Wtq7yB0Eii60fxqFWC24nEkvs1V0cxDa+o6I2iA9w== eu@euandre.org"
];
};
};
buildUser = (i: {
"guixbuilder${i}" = {
group = "guixbuild";
extraGroups = [ "guixbuild" ];
home = "/var/empty";
shell = pkgs.nologin;
description = "Guix build user ${i}";
isSystemUser = true;
};
});
in pkgs.lib.fold (str: acc: acc // buildUser str) andrehUser
(map (pkgs.lib.fixedWidthNumber 2) (builtins.genList (n: n + 1) 10));
extraGroups.guixbuild = { name = "guixbuild"; };
};
systemd = {
services = {
guix-daemon = {
enable = true;
description = "Build daemon for GNU Guix";
serviceConfig = {
ExecStart =
"/var/guix/profiles/per-user/root/current-guix/bin/guix-daemon --build-users-group=guixbuild";
};
wantedBy = [ "multi-user.target" ];
};
};
};
system = {
stateVersion = "20.09";
autoUpgrade = {
enable = true;
allowReboot = true;
};
};
}
|