]> Git — Sourcephile - julm/julm-nix.git/blob - hosts/oignon.nix
git: ignore formatting with nixfmt-rfc-style
[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 nixPath = lib.mkForce [ "nixpkgs=${inputs.nixpkgs}" ];
86 };
87 #environment.etc."nixpkgs".source = pkgs.path;
88 #environment.etc."nixpkgs-overlays".source = inputs.self + "/nixpkgs";
89
90 nix.settings.allowed-users = [ config.users.users."nix-ssh".name ];
91 nix.sshServe = {
92 enable = true;
93 keys = map lib.readFile [
94 ../users/julm/ssh/losurdo.pub
95 ../users/julm/ssh/oignon.pub
96 ../users/sevy/ssh/patate.pub
97 ];
98 };
99
100 environment.systemPackages = [
101 pkgs.riseup-vpn # Can't be installed by home-manager because it needs to install policy-kit rules
102 ];
103
104 boot.extraModulePackages = [
105 #config.boot.kernelPackages.v4l2loopback
106 ];
107
108 programs.fuse.userAllowOther = true;
109
110 services.davfs2.enable = true;
111
112 systemd.automounts = [
113 {
114 where = "/mnt/aubergine";
115 automountConfig.TimeoutIdleSec = "5 min";
116 }
117 ];
118 fileSystems =
119 let
120 # Use the user's gpg-agent session to query
121 # for the password of the SSH key when auto-mounting.
122 sshAsUser = pkgs.writeScript "sshAsUser" ''
123 user="$1"; shift
124 exec ${pkgs.sudo}/bin/sudo -i -u "$user" \
125 ${pkgs.openssh}/bin/ssh "$@"
126 '';
127 options = [
128 "user"
129 "uid=julm"
130 "gid=users"
131 "allow_other"
132 "exec" # Override "user"'s noexec
133 "noatime"
134 "nosuid"
135 "_netdev"
136 "ssh_command=${sshAsUser}\\040julm"
137 "noauto"
138 "x-gvfs-hide"
139 "x-systemd.automount"
140 #"Compression=yes" # YMMV
141 # Disconnect approximately 2*15=30 seconds after a network failure
142 "ServerAliveCountMax=1"
143 "ServerAliveInterval=15"
144 "dir_cache=no"
145 #"reconnect"
146 ];
147 in
148 {
149 "/mnt/aubergine" = {
150 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@aubergine.sp:/";
151 fsType = "fuse";
152 inherit options;
153 };
154 "/mnt/losurdo" = {
155 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@losurdo.sp:/";
156 fsType = "fuse";
157 inherit options;
158 };
159 "/mnt/mermet" = {
160 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@mermet.sp:/";
161 fsType = "fuse";
162 inherit options;
163 };
164 "/mnt/ilico/severine" = {
165 device = "https://nuage.ilico.org/remote.php/dav/files/severine/";
166 fsType = "davfs";
167 options =
168 let
169 conf = pkgs.writeText "davfs2.conf" ''
170 backup_dir /home/julm/.local/share/davfs2/ilico/severine
171 secrets /home/julm/.davfs2/secrets
172 '';
173 in
174 [
175 "conf=${conf}"
176 "user"
177 "noexec"
178 "nosuid"
179 "noauto"
180 "nofail"
181 "_netdev"
182 "reconnect"
183 "x-systemd.automount"
184 "x-systemd.device-timeout=1m"
185 "x-systemd.idle-timeout=1m"
186 "x-systemd.mount-timeout=10s"
187 ];
188 };
189 };
190
191 networking.firewall.extraCommands = ''
192 ip46tables -A nixos-fw -i wg-intra -p tcp -m tcp --dport 8000 -j ACCEPT
193 '';
194
195 services.kubo = {
196 #enable = true;
197 defaultMode = "online";
198 autoMount = true;
199 enableGC = true;
200 localDiscovery = false;
201 settings = {
202 Datastore.StorageMax = "10GB";
203 Discovery.MDNS.Enabled = false;
204 #Bootstrap = [
205 #];
206 #Swarm.AddrFilters = null;
207 };
208 startWhenNeeded = true;
209 };
210
211 services.udev.packages = [
212 # Allow the console user access the Yubikey USB device node,
213 # needed for challenge/response to work correctly.
214 pkgs.yubikey-personalization
215 ];
216
217 services.xserver = {
218 xkb = {
219 layout = "fr,us(altgr-intl)";
220 };
221 desktopManager = {
222 session = [
223 # Let the session be generated by home-manager
224 {
225 name = "home-manager";
226 start = ''
227 ${pkgs.runtimeShell} $HOME/.hm-xsession &
228 waitPID=$!
229 '';
230 }
231 ];
232 };
233 };
234
235 services.displayManager = {
236 defaultSession = "home-manager";
237 #defaultSession = "none+xmonad";
238 #defaultSession = "mate";
239 #defaultSession = "cinnamon";
240 autoLogin = {
241 user = config.users.users.julm.name;
242 };
243 };
244
245 # This value determines the NixOS release with which your system is to be
246 # compatible, in order to avoid breaking some software such as database
247 # servers. You should change this only after NixOS release notes say you should.
248 system.stateVersion = "20.09"; # Did you read the comment?
249 }