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