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