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