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