]> Git — Sourcephile - julm/julm-nix.git/blob - hosts/oignon.nix
clipster: try to avoid 100% CPU
[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/tor.nix
10 ../nixos/profiles/irssi.nix
11 oignon/backup.nix
12 oignon/hardware.nix
13 oignon/networking.nix
14 ];
15
16 # Lower kernel's security for better performances
17 boot.kernelParams = [ "mitigations=off" ];
18
19 home-manager.users.julm = {
20 imports = [ ../homes/julm.nix ];
21 };
22 systemd.services.home-manager-julm.postStart = ''
23 ${pkgs.nix}/bin/nix-env --delete-generations +1 --profile /nix/var/nix/profiles/per-user/julm/home-manager
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 "scanner"
44 "tor"
45 "video"
46 "wheel"
47 #"ipfs"
48 config.services.davfs2.davGroup
49 #"vboxusers"
50 ];
51 # If created, zfs-mount.service would require:
52 # zfs set overlay=yes ${hostName}/home
53 createHome = false;
54 openssh.authorizedKeys.keys = map lib.readFile [
55 ../users/julm/ssh/losurdo.pub
56 ];
57 };
58
59 systemd.services.nix-daemon.serviceConfig.LoadCredentialEncrypted =
60 [ ("${hostName}.key:${inputs.self}/hosts/${hostName}/nix/secret-key-files.priv.pem.cred") ];
61 nix = {
62 extraOptions = ''
63 secret-key-files = /run/credentials/nix-daemon.service/${hostName}.key
64 '';
65 settings = {
66 trusted-users = [ config.users.users."julm".name ];
67 substituters = [
68 #"http://nix-localcache.losurdo.wg"
69 "ssh://nix-ssh@losurdo.wg?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 fileSystems =
103 # Use the user's gpg-agent session to query
104 # for the password of the SSH key when auto-mounting.
105 let
106 sshAsUser = user:
107 pkgs.writeScript "sshAsUser-${user}" ''
108 exec ${pkgs.sudo}/bin/sudo -i -u ${user} \
109 ${pkgs.openssh}/bin/ssh "$@"
110 '';
111 options =
112 [
113 "user"
114 "uid=julm"
115 "gid=users"
116 "allow_other"
117 "exec" # Override "user"'s noexec
118 "noatime"
119 "nosuid"
120 "_netdev"
121 "ssh_command=${sshAsUser "julm"}" # "reconnect"
122 "noauto"
123 "x-gvfs-hide"
124 "x-systemd.automount"
125 #"Compression=yes" # YMMV
126 # Disconnect approximately 2*15=30 seconds after a network failure
127 "ServerAliveCountMax=1"
128 "ServerAliveInterval=15"
129 ];
130 in
131 {
132 "/mnt/aubergine" = {
133 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@aubergine.wg:/";
134 fsType = "fuse";
135 inherit options;
136 };
137 "/mnt/losurdo" = {
138 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@losurdo.wg:/";
139 fsType = "fuse";
140 inherit options;
141 };
142 "/mnt/mermet" = {
143 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@mermet.wg:/";
144 fsType = "fuse";
145 inherit options;
146 };
147 "/mnt/ilico/severine" = {
148 device = "https://nuage.ilico.org/remote.php/dav/files/severine/";
149 fsType = "davfs";
150 options =
151 let
152 conf = pkgs.writeText "davfs2.conf" ''
153 backup_dir /home/julm/.local/share/davfs2/ilico/severine
154 secrets /home/julm/.davfs2/secrets
155 '';
156 in
157 [
158 "conf=${conf}"
159 "user"
160 "noexec"
161 "nosuid"
162 "noauto"
163 "nofail"
164 "_netdev"
165 "reconnect"
166 "x-systemd.automount"
167 "x-systemd.device-timeout=1m"
168 "x-systemd.idle-timeout=1m"
169 "x-systemd.mount-timeout=10s"
170 ];
171 };
172 };
173
174 networking.firewall.extraCommands = ''
175 ip46tables -A nixos-fw -i wg-intra -p tcp -m tcp --dport 8000 -j ACCEPT
176 '';
177
178 services.kubo = {
179 #enable = true;
180 defaultMode = "online";
181 autoMount = true;
182 enableGC = true;
183 localDiscovery = false;
184 settings = {
185 Datastore.StorageMax = "10GB";
186 Discovery.MDNS.Enabled = false;
187 #Bootstrap = [
188 #];
189 #Swarm.AddrFilters = null;
190 };
191 startWhenNeeded = true;
192 };
193
194 services.udev.packages = [
195 # Allow the console user access the Yubikey USB device node,
196 # needed for challenge/response to work correctly.
197 pkgs.yubikey-personalization
198 ];
199
200 services.xserver = {
201 layout = "fr,us(altgr-intl)";
202 desktopManager = {
203 session = [
204 # Let the session be generated by home-manager
205 {
206 name = "home-manager";
207 start = ''
208 ${pkgs.runtimeShell} $HOME/.hm-xsession &
209 waitPID=$!
210 '';
211 }
212 ];
213 };
214 displayManager = {
215 defaultSession = "home-manager";
216 #defaultSession = "none+xmonad";
217 #defaultSession = "mate";
218 #defaultSession = "cinnamon";
219 autoLogin = {
220 user = config.users.users.julm.name;
221 };
222 };
223 };
224
225 # This value determines the NixOS release with which your system is to be
226 # compatible, in order to avoid breaking some software such as database
227 # servers. You should change this only after NixOS release notes say you should.
228 system.stateVersion = "20.09"; # Did you read the comment?
229 }