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