main
1{
2 hostname,
3 config,
4 pkgs,
5 lib,
6 options,
7 ...
8}:
9{
10 imports = [
11 ./boot.nix
12 ./console.nix
13 ./hardware.nix
14 ./locale.nix
15 ./nh.nix
16 ./network.nix
17 ./tpm.nix
18
19 # All my machines have this running
20 ../services/avahi.nix
21 ../services/openssh.nix
22 ../services/prometheus-exporters-node.nix
23 ../services/wireguard.nix
24 ../programs/age.nix
25 # ../services/wireguard.nix # or netbird
26 ];
27
28 networking = {
29 hostName = hostname;
30 # useDHCP = lib.mkDefault true;
31 };
32
33 environment.systemPackages = with pkgs; [
34 acct
35 binutils
36 curl
37 detach # For detached session management
38 # f2
39 file
40 htop
41 iotop
42 killall
43 lsof
44 netcat
45 pciutils
46 psmisc
47 pv
48 ripgrep
49 rsync
50 shpool-ssh-wrapper # For smart shpool SSH session management
51 traceroute
52 tree
53 usbutils
54 vim
55 wget
56 yq-go
57 ];
58
59 programs = {
60 zsh.enable = true;
61 };
62
63 # Only keep the last 500MiB of systemd journal.
64 services = {
65 fwupd.enable = true;
66 }
67 // lib.optionalAttrs (options.services.journald ? settings) {
68 journald.settings.Journal.SystemMaxUse = "500M";
69 }
70 // lib.optionalAttrs (!(options.services.journald ? settings)) {
71 journald.extraConfig = "SystemMaxUse=500M";
72 };
73
74 security = {
75 polkit.enable = true;
76 rtkit.enable = true;
77 pam.sshAgentAuth.enable = true;
78 };
79
80 # Clear out /tmp after a fortnight and give all normal users a ~/tmp
81 # cleaned out weekly.
82 systemd.tmpfiles.rules = [
83 "d /tmp 1777 root root 14d"
84 ]
85 ++ (
86 let
87 mkTmpDir = n: u: "d ${u.home}/tmp 0700 ${n} ${u.group} 7d";
88 in
89 lib.mapAttrsToList mkTmpDir (lib.filterAttrs (_: u: u.isNormalUser) config.users.extraUsers)
90 );
91
92 # Process accounting — logs every exec for usage-metrics tracking
93 systemd.services.acct = {
94 description = "GNU Process Accounting";
95 wantedBy = [ "multi-user.target" ];
96 serviceConfig = {
97 Type = "oneshot";
98 RemainAfterExit = true;
99 ExecStartPre = "${pkgs.bash}/bin/bash -c '${pkgs.coreutils}/bin/mkdir -p /var/log/account && ${pkgs.coreutils}/bin/touch /var/log/account/pacct'";
100 ExecStart = "${pkgs.acct}/bin/accton /var/log/account/pacct";
101 ExecStop = "${pkgs.acct}/bin/accton off";
102 };
103 };
104}