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