]> Git — Sourcephile - julm/julm-nix.git/blob - hosts/oignon.nix
xmonad: tabbed layout by default
[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 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.wg:/";
140 fsType = "fuse";
141 inherit options;
142 };
143 "/mnt/losurdo" = {
144 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@losurdo.wg:/";
145 fsType = "fuse";
146 inherit options;
147 };
148 "/mnt/mermet" = {
149 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@mermet.wg:/";
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 }