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