]> Git — Sourcephile - julm/julm-nix.git/blob - hosts/oignon.nix
tmux: enable socket activation
[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 fileSystems =
90 # Use the user's gpg-agent session to query
91 # for the password of the SSH key when auto-mounting.
92 let
93 sshAsUser = user:
94 pkgs.writeScript "sshAsUser-${user}" ''
95 exec ${pkgs.sudo}/bin/sudo -i -u ${user} \
96 ${pkgs.openssh}/bin/ssh "$@"
97 '';
98 options =
99 [
100 "noatime" "noexec" "nosuid"
101 "user" "uid=julm" "gid=users" "allow_other"
102 "_netdev" "ssh_command=${sshAsUser "julm"}" # "reconnect"
103 "noauto" "x-gvfs-hide" "x-systemd.automount"
104 #"Compression=yes" # YMMV
105 # Disconnect approximately 2*15=30 seconds after a network failure
106 "ServerAliveCountMax=1"
107 "ServerAliveInterval=15"
108 ];
109 in {
110 "/mnt/losurdo" = {
111 device = "${pkgs.sshfsFuse}/bin/sshfs#julm@losurdo.wg:/";
112 fsType = "fuse";
113 inherit options;
114 };
115 "/mnt/mermet" = {
116 device = "${pkgs.sshfsFuse}/bin/sshfs#julm@mermet.wg:/";
117 fsType = "fuse";
118 inherit options;
119 };
120 };
121
122 networking.firewall.extraCommands = ''
123 ip46tables -A nixos-fw -i wg-intra -p tcp -m tcp --dport 8000 -j ACCEPT
124 '';
125
126 services.ipfs = {
127 #enable = true;
128 defaultMode = "online";
129 autoMount = true;
130 enableGC = true;
131 localDiscovery = false;
132 extraConfig = {
133 Datastore.StorageMax = "10GB";
134 Discovery.MDNS.Enabled = false;
135 #Bootstrap = [
136 #];
137 #Swarm.AddrFilters = null;
138 };
139 startWhenNeeded = true;
140 };
141
142 services.udev.packages = [
143 # Allow the console user access the Yubikey USB device node,
144 # needed for challenge/response to work correctly.
145 pkgs.yubikey-personalization
146 ];
147
148 services.xserver = {
149 desktopManager = {
150 session = [
151 # Let the session be generated by home-manager
152 { name = "home-manager";
153 start = ''
154 ${pkgs.runtimeShell} $HOME/.hm-xsession &
155 waitPID=$!
156 '';
157 }
158 ];
159 };
160 displayManager = {
161 defaultSession = "home-manager";
162 #defaultSession = "none+xmonad";
163 #defaultSession = "mate";
164 #defaultSession = "cinnamon";
165 autoLogin = {
166 user = config.users.users.julm.name;
167 };
168 };
169 };
170
171 # This value determines the NixOS release with which your system is to be
172 # compatible, in order to avoid breaking some software such as database
173 # servers. You should change this only after NixOS release notes say you should.
174 system.stateVersion = "20.09"; # Did you read the comment?
175 }