1 { inputs, pkgs, lib, config, ... }:
2 let inherit (lib) types;
3 inherit (config.networking) hostName domain;
9 (inputs.julm-nix + "/nixos/profiles/security.nix")
10 defaults/predictable-interface-names.nix
13 #binaryCaches = lib.mkForce [];
16 autoOptimiseStore = lib.mkDefault true;
17 # Use gc.automatic to keep disk space under control.
18 gc.automatic = lib.mkDefault true;
19 gc.dates = lib.mkDefault "weekly";
20 gc.options = lib.mkDefault "--delete-older-than 30d";
21 # Setting NIX_PATH is useless now that flake.nix are used.
22 nixPath = lib.mkForce [];
24 environment.variables.NIXPKGS_CONFIG = lib.mkForce "";
26 documentation.nixos = {
27 # NOTE: useless on a server, and CPU intensive.
28 enable = lib.mkDefault false;
31 console.font = "Lat2-Terminus16";
32 console.keyMap = lib.mkDefault "fr";
33 i18n.defaultLocale = "fr_FR.UTF-8";
34 nixpkgs.config.allowUnfree = false;
35 time.timeZone = "Europe/Paris";
37 # Always try to start all the units (default.target)
38 # because systemd's emergency shell does not try to start sshd.
39 # https://wiki.archlinux.org/index.php/systemd#Disable_emergency_mode_on_remote_host
40 systemd.enableEmergencyMode = false;
42 # On a remote headless server: always reboot on a kernel panic,
43 # to not have to physically go power cycle the server.
44 # Which may happen for instance if the wrong ZFS password is used
45 # but the boot is manually forced to continue.
46 # Using kernelParams instead of kernel.sysctl
47 # sets this up as soon as the initrd.
48 boot.kernelParams = [ "panic=10" ];
50 boot.cleanTmpDir = lib.mkDefault true;
51 boot.tmpOnTmpfs = lib.mkDefault true;
55 # See: https://github.com/NixOS/nixpkgs/issues/10183#issuecomment-537629621
57 "127.0.1.1" = lib.mkForce [ "${hostName}.${domain}" hostName ];
58 "::1" = lib.mkForce [ "${hostName}.${domain}" hostName "localhost" ];
61 usePredictableInterfaceNames = true;
64 services.logrotate.enable = true;
66 services.openssh.enable = true;
68 environment.systemPackages = with pkgs; [
71 config.boot.kernelPackages.cpupower
82 #mailutils # builds guile
101 environment.variables.SYSTEMD_LESS = "FKMRX";
102 environment.etc."inputrc".text = lib.readFile defaults/readline/inputrc;
104 boot.kernel.sysctl = {
105 # Improve MTU detection
106 # This can thaw TCP connections stalled by a host
107 # requiring a lower MTU along the path,
108 # though it would do so after a little delay
109 # so it's better to set a low MTU when possible.
110 "net/ipv4/tcp_mtu_probing" = 1;
115 interactiveShellInit = ''
116 bind '"\e[A":history-search-backward'
117 bind '"\e[B":history-search-forward'
119 # Ignore duplicate commands, ignore commands starting with a space
120 export HISTCONTROL=erasedups:ignorespace
121 export HISTSIZE=42000
123 # Append to the history instead of overwriting (good for multiple connections)
126 # Enable ** file pattern
130 mkcd() { mkdir -p "$1" && cd "$1"; }
131 stress-mem() { fac="$1"; stress-ng --vm 1 --vm-keep --vm-bytes $(awk "/MemAvailable/{ printf \"%d\n\", \$2 * $fac; }" </proc/meminfo)k; }
132 sysenter() { srv="$1"; shift; nsenter -a -t "$(systemctl show --property MainPID --value "$srv")" "$@"; }
133 systrace() { srv="$1"; shift; strace -f -p "$(systemctl show --property MainPID --value "$srv")" "$@"; }
134 zfs-mount () { for d in $(zfs list -rH -o name "$@"); do sudo zfs mount -l "$d"; done; }
135 zfs-unmount () { sudo zfs unmount -u "$@"; }
141 ls = "ls --color=tty";
142 mem = "ps -e -orss=,user=,args= | sort -b -k1,1n";
143 mem-top = "smem --sort rss --autosize";
146 st="sudo systemctl status";
147 u="systemctl --user";
148 ut="systemctl --user status";
149 j="sudo journalctl -u";
151 nixos-clean="sudo nix-collect-garbage -d";
152 nixos-history="sudo nix-env --list-generations --profile /nix/var/nix/profiles/system";
153 nixos-rollback="sudo nixos-rebuild switch --rollback";
156 gnupg.agent.pinentryFlavor = "curses";
157 mosh.enable = lib.mkDefault true;
158 mtr.enable = lib.mkDefault true;
159 traceroute.enable = lib.mkDefault true;