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