]> Git — Sourcephile - julm/julm-nix.git/blob - hosts/oignon.nix
aubergine: wireguard: move to port 43646
[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;
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 nix = {
62 extraOptions = ''
63 #secret-key-files = /run/credentials/nix-daemon.service/secret-key-files.pem
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 ../hosts/losurdo/nix/key.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 "noatime" "noexec" "nosuid"
114 "user" "uid=julm" "gid=users" "allow_other"
115 "_netdev" "ssh_command=${sshAsUser "julm"}" # "reconnect"
116 "noauto" "x-gvfs-hide" "x-systemd.automount"
117 #"Compression=yes" # YMMV
118 # Disconnect approximately 2*15=30 seconds after a network failure
119 "ServerAliveCountMax=1"
120 "ServerAliveInterval=15"
121 ];
122 in {
123 "/mnt/aubergine" = {
124 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@aubergine.wg:/";
125 fsType = "fuse";
126 inherit options;
127 };
128 "/mnt/losurdo" = {
129 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@losurdo.wg:/";
130 fsType = "fuse";
131 inherit options;
132 };
133 "/mnt/mermet" = {
134 device = "${pkgs.sshfs-fuse}/bin/sshfs#julm@mermet.wg:/";
135 fsType = "fuse";
136 inherit options;
137 };
138 "/mnt/ilico/severine" = {
139 device = "https://nuage.ilico.org/remote.php/dav/files/severine/";
140 fsType = "davfs";
141 options =
142 let conf = pkgs.writeText "davfs2.conf" ''
143 backup_dir /home/julm/.local/share/davfs2/ilico/severine
144 secrets /home/julm/.davfs2/secrets
145 ''; in
146 [ "conf=${conf}" "user" "noexec" "nosuid"
147 "noauto" "nofail" "_netdev" "reconnect"
148 "x-systemd.automount"
149 "x-systemd.device-timeout=1m"
150 "x-systemd.idle-timeout=1m"
151 "x-systemd.mount-timeout=10s"
152 ];
153 };
154 };
155
156 networking.firewall.extraCommands = ''
157 ip46tables -A nixos-fw -i wg-intra -p tcp -m tcp --dport 8000 -j ACCEPT
158 '';
159
160 services.ipfs = {
161 #enable = true;
162 defaultMode = "online";
163 autoMount = true;
164 enableGC = true;
165 localDiscovery = false;
166 extraConfig = {
167 Datastore.StorageMax = "10GB";
168 Discovery.MDNS.Enabled = false;
169 #Bootstrap = [
170 #];
171 #Swarm.AddrFilters = null;
172 };
173 startWhenNeeded = true;
174 };
175
176 services.udev.packages = [
177 # Allow the console user access the Yubikey USB device node,
178 # needed for challenge/response to work correctly.
179 pkgs.yubikey-personalization
180 ];
181
182 services.xserver = {
183 desktopManager = {
184 session = [
185 # Let the session be generated by home-manager
186 { name = "home-manager";
187 start = ''
188 ${pkgs.runtimeShell} $HOME/.hm-xsession &
189 waitPID=$!
190 '';
191 }
192 ];
193 };
194 displayManager = {
195 defaultSession = "home-manager";
196 #defaultSession = "none+xmonad";
197 #defaultSession = "mate";
198 #defaultSession = "cinnamon";
199 autoLogin = {
200 user = config.users.users.julm.name;
201 };
202 };
203 };
204
205 # This value determines the NixOS release with which your system is to be
206 # compatible, in order to avoid breaking some software such as database
207 # servers. You should change this only after NixOS release notes say you should.
208 system.stateVersion = "20.09"; # Did you read the comment?
209 }