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