]> Git — Sourcephile - julm/julm-nix.git/blob - hosts/oignon.nix
radicle: update
[julm/julm-nix.git] / hosts / oignon.nix
1 { config, pkgs, lib, inputs, hostName, ... }:
2 {
3 imports = [
4 ../nixos/profiles/debug.nix
5 ../nixos/profiles/graphical.nix
6 ../nixos/profiles/irssi.nix
7 ../nixos/profiles/lang-fr.nix
8 ../nixos/profiles/laptop.nix
9 ../nixos/profiles/printing.nix
10 ../nixos/profiles/radio.nix
11 ../nixos/profiles/tor.nix
12 ../nixos/profiles/bluetooth.nix
13 oignon/backup.nix
14 oignon/hardware.nix
15 oignon/nebula.nix
16 oignon/networking.nix
17 ];
18
19 # Lower kernel's security for better performances
20 security.kernel.mitigations = "off";
21
22 home-manager.users.julm = {
23 imports = [ ../homes/julm.nix ];
24 };
25 users.users.root = {
26 openssh.authorizedKeys.keys = map lib.readFile [
27 # For nix -L run .#oignon.switch
28 ../users/julm/ssh/oignon.pub
29 ];
30 };
31 users.users.julm = {
32 isNormalUser = true;
33 uid = 1000;
34 # Put the hashedPassword in /nix/store,
35 # though /etc/shadow is not world readable...
36 # printf %s $(mkpasswd -m md5crypt)
37 hashedPassword = lib.readFile oignon/users/julm/login/hashedPassword.clear;
38 extraGroups = [
39 "adbusers"
40 "dialout"
41 "lp"
42 "networkmanager"
43 "plugdev" # For rtl-sdr
44 "scanner"
45 "tor"
46 "video"
47 "wheel"
48 #"ipfs"
49 config.services.davfs2.davGroup
50 #"vboxusers"
51 ];
52 # If created, zfs-mount.service would require:
53 # zfs set overlay=yes ${hostName}/home
54 createHome = false;
55 openssh.authorizedKeys.keys = map lib.readFile [
56 ../users/julm/ssh/losurdo.pub
57 ];
58 };
59
60 systemd.services.nix-daemon.serviceConfig.LoadCredentialEncrypted = [
61 "${hostName}.key:${builtins.path { path = ./. + "/${hostName}/nix/secret-key-files.priv.pem.cred"; }}"
62 ];
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.sp"
70 "ssh://nix-ssh@losurdo.sp?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.sp:/";
141 fsType = "fuse";
142 inherit options;
143 };
144 "/mnt/losurdo" = {
145 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@losurdo.sp:/";
146 fsType = "fuse";
147 inherit options;
148 };
149 "/mnt/mermet" = {
150 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@mermet.sp:/";
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 xkb = {
209 layout = "fr,us(altgr-intl)";
210 };
211 desktopManager = {
212 session = [
213 # Let the session be generated by home-manager
214 {
215 name = "home-manager";
216 start = ''
217 ${pkgs.runtimeShell} $HOME/.hm-xsession &
218 waitPID=$!
219 '';
220 }
221 ];
222 };
223 };
224
225 services.displayManager = {
226 defaultSession = "home-manager";
227 #defaultSession = "none+xmonad";
228 #defaultSession = "mate";
229 #defaultSession = "cinnamon";
230 autoLogin = {
231 user = config.users.users.julm.name;
232 };
233 };
234
235 # This value determines the NixOS release with which your system is to be
236 # compatible, in order to avoid breaking some software such as database
237 # servers. You should change this only after NixOS release notes say you should.
238 system.stateVersion = "20.09"; # Did you read the comment?
239 }