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