]> Git — Sourcephile - julm/julm-nix.git/blob - hosts/oignon.nix
perf: add to essential profile
[julm/julm-nix.git] / hosts / oignon.nix
1 { config, pkgs, lib, inputs, hostName, ... }:
2 {
3 imports = [
4 ../nixos/profiles/builder.nix
5 ../nixos/profiles/debug.nix
6 ../nixos/profiles/graphical.nix
7 ../nixos/profiles/irssi.nix
8 ../nixos/profiles/lang-fr.nix
9 ../nixos/profiles/printing.nix
10 ../nixos/profiles/radio.nix
11 ../nixos/profiles/tor.nix
12 oignon/backup.nix
13 oignon/hardware.nix
14 oignon/networking.nix
15 ];
16
17 # Lower kernel's security for better performances
18 boot.kernelParams = [ "mitigations=off" ];
19
20 home-manager.users.julm = {
21 imports = [ ../homes/julm.nix ];
22 };
23 systemd.services.home-manager-julm.postStart = ''
24 ${pkgs.nix}/bin/nix-env --delete-generations +1 --profile /nix/var/nix/profiles/per-user/julm/home-manager
25 '';
26 users.users.root = {
27 openssh.authorizedKeys.keys = map lib.readFile [
28 # For nix -L run .#oignon.switch
29 ../users/julm/ssh/oignon.pub
30 ];
31 };
32 users.users.julm = {
33 isNormalUser = true;
34 uid = 1000;
35 # Put the hashedPassword in /nix/store,
36 # though /etc/shadow is not world readable...
37 # printf %s $(mkpasswd -m md5crypt)
38 hashedPassword = lib.readFile oignon/users/julm/login/hashedPassword.clear;
39 extraGroups = [
40 "adbusers"
41 "dialout"
42 "lp"
43 "networkmanager"
44 "plugdev" # For rtl-sdr
45 "scanner"
46 "tor"
47 "video"
48 "wheel"
49 #"ipfs"
50 config.services.davfs2.davGroup
51 #"vboxusers"
52 ];
53 # If created, zfs-mount.service would require:
54 # zfs set overlay=yes ${hostName}/home
55 createHome = false;
56 openssh.authorizedKeys.keys = map lib.readFile [
57 ../users/julm/ssh/losurdo.pub
58 ];
59 };
60
61 systemd.services.nix-daemon.serviceConfig.LoadCredentialEncrypted =
62 [ ("${hostName}.key:${inputs.self}/hosts/${hostName}/nix/secret-key-files.priv.pem.cred") ];
63 nix = {
64 extraOptions = ''
65 secret-key-files = /run/credentials/nix-daemon.service/${hostName}.key
66 '';
67 settings = {
68 substituters = [
69 #"http://nix-localcache.losurdo.wg"
70 "ssh://nix-ssh@losurdo.wg?priority=30"
71 ];
72 trusted-public-keys = map lib.readFile [
73 ../users/nix/ssh/losurdo.pub
74 ];
75 };
76 nixPath = lib.mkForce [ "nixpkgs=${inputs.nixpkgs}" ];
77 };
78 #environment.etc."nixpkgs".source = pkgs.path;
79 #environment.etc."nixpkgs-overlays".source = inputs.self + "/nixpkgs";
80
81 nix.settings.allowed-users = [ config.users.users."nix-ssh".name ];
82 nix.sshServe = {
83 enable = true;
84 keys = map lib.readFile [
85 ../users/julm/ssh/losurdo.pub
86 ../users/julm/ssh/oignon.pub
87 ../users/sevy/ssh/patate.pub
88 ];
89 };
90
91 environment.systemPackages = [
92 pkgs.riseup-vpn # Can't be installed by home-manager because it needs to install policy-kit rules
93 ];
94
95 boot.extraModulePackages = [
96 #config.boot.kernelPackages.v4l2loopback
97 ];
98
99 programs.fuse.userAllowOther = true;
100
101 services.davfs2.enable = true;
102
103 systemd.automounts = [
104 { where = "/mnt/aubergine"; automountConfig.TimeoutIdleSec = "5 min"; }
105 ];
106 fileSystems =
107 let
108 # Use the user's gpg-agent session to query
109 # for the password of the SSH key when auto-mounting.
110 sshAsUser =
111 pkgs.writeScript "sshAsUser" ''
112 user="$1"; shift
113 exec ${pkgs.sudo}/bin/sudo -i -u "$user" \
114 ${pkgs.openssh}/bin/ssh "$@"
115 '';
116 options =
117 [
118 "user"
119 "uid=julm"
120 "gid=users"
121 "allow_other"
122 "exec" # Override "user"'s noexec
123 "noatime"
124 "nosuid"
125 "_netdev"
126 "ssh_command=${sshAsUser}\\040julm"
127 "noauto"
128 "x-gvfs-hide"
129 "x-systemd.automount"
130 #"Compression=yes" # YMMV
131 # Disconnect approximately 2*15=30 seconds after a network failure
132 "ServerAliveCountMax=1"
133 "ServerAliveInterval=15"
134 "dir_cache=no"
135 #"reconnect"
136 ];
137 in
138 {
139 "/mnt/aubergine" = {
140 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@aubergine.wg:/";
141 fsType = "fuse";
142 inherit options;
143 };
144 "/mnt/losurdo" = {
145 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@losurdo.wg:/";
146 fsType = "fuse";
147 inherit options;
148 };
149 "/mnt/mermet" = {
150 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@mermet.wg:/";
151 fsType = "fuse";
152 inherit options;
153 };
154 "/mnt/ilico/severine" = {
155 device = "https://nuage.ilico.org/remote.php/dav/files/severine/";
156 fsType = "davfs";
157 options =
158 let
159 conf = pkgs.writeText "davfs2.conf" ''
160 backup_dir /home/julm/.local/share/davfs2/ilico/severine
161 secrets /home/julm/.davfs2/secrets
162 '';
163 in
164 [
165 "conf=${conf}"
166 "user"
167 "noexec"
168 "nosuid"
169 "noauto"
170 "nofail"
171 "_netdev"
172 "reconnect"
173 "x-systemd.automount"
174 "x-systemd.device-timeout=1m"
175 "x-systemd.idle-timeout=1m"
176 "x-systemd.mount-timeout=10s"
177 ];
178 };
179 };
180
181 networking.firewall.extraCommands = ''
182 ip46tables -A nixos-fw -i wg-intra -p tcp -m tcp --dport 8000 -j ACCEPT
183 '';
184
185 services.kubo = {
186 #enable = true;
187 defaultMode = "online";
188 autoMount = true;
189 enableGC = true;
190 localDiscovery = false;
191 settings = {
192 Datastore.StorageMax = "10GB";
193 Discovery.MDNS.Enabled = false;
194 #Bootstrap = [
195 #];
196 #Swarm.AddrFilters = null;
197 };
198 startWhenNeeded = true;
199 };
200
201 services.udev.packages = [
202 # Allow the console user access the Yubikey USB device node,
203 # needed for challenge/response to work correctly.
204 pkgs.yubikey-personalization
205 ];
206
207 services.xserver = {
208 layout = "fr,us(altgr-intl)";
209 desktopManager = {
210 session = [
211 # Let the session be generated by home-manager
212 {
213 name = "home-manager";
214 start = ''
215 ${pkgs.runtimeShell} $HOME/.hm-xsession &
216 waitPID=$!
217 '';
218 }
219 ];
220 };
221 displayManager = {
222 defaultSession = "home-manager";
223 #defaultSession = "none+xmonad";
224 #defaultSession = "mate";
225 #defaultSession = "cinnamon";
226 autoLogin = {
227 user = config.users.users.julm.name;
228 };
229 };
230 };
231
232 # This value determines the NixOS release with which your system is to be
233 # compatible, in order to avoid breaking some software such as database
234 # servers. You should change this only after NixOS release notes say you should.
235 system.stateVersion = "20.09"; # Did you read the comment?
236 }