1 { inputs, pkgs, lib, config, ... }:
2 let inherit (lib) types;
3 inherit (config.networking) hostName domain;
9 defaults/predictable-interface-names.nix
12 #binaryCaches = lib.mkForce [];
15 # Use gc.automatic to keep disk space under control.
17 automatic = lib.mkDefault true;
18 dates = lib.mkDefault "weekly";
19 options = lib.mkDefault "--delete-older-than 30d";
22 # WARNING: this is a hack to avoid copying Nixpkgs
23 # a second time into the Nix store.
24 # It makes only sense when Nixpkgs is already in the Nix store,
26 "nixpkgs=/etc/nixpkgs:nixpkgs-overlays=/etc/nixpkgs-overlays/overlays.nix"
29 environment.etc."nixpkgs".source = pkgs.path;
30 environment.etc."nixpkgs-overlays".source =
31 pkgs.writeTextDir "overlays.nix" ''
32 import ${inputs.self + "/nixpkgs/overlays.nix"} ++
33 import ${inputs.julm-nix + "/nixpkgs/overlays.nix"}
40 packageOverrides = pkgs: {
41 postfix = pkgs.postfix.override {
49 documentation.nixos = {
50 enable = false; # NOTE: useless on a server, and CPU intensive.
54 timeZone = "Europe/Paris";
58 defaultLocale = "fr_FR.UTF-8";
62 font = "Lat2-Terminus16";
63 keyMap = lib.mkDefault "fr";
66 # Always try to start all the units (default.target)
67 # because systemd's emergency shell does not try to start sshd.
68 # https://wiki.archlinux.org/index.php/systemd#Disable_emergency_mode_on_remote_host
69 systemd.enableEmergencyMode = false;
71 # This is a remote headless server: always reboot on a kernel panic,
72 # to not have to physically go power cycle the apu2e4.
73 # Which happens if the wrong ZFS password is used
74 # but the boot is manually forced to continue.
75 # Using kernelParams instead of kernel.sysctl
76 # sets this up as soon as the initrd.
77 boot.kernelParams = [ "panic=10" ];
79 boot.cleanTmpDir = true;
80 boot.tmpOnTmpfs = true;
84 # See: https://github.com/NixOS/nixpkgs/issues/10183#issuecomment-537629621
86 "127.0.1.1" = lib.mkForce [ "${hostName}.${domain}" hostName ];
87 "::1" = lib.mkForce [ "${hostName}.${domain}" hostName "localhost" ];
90 usePredictableInterfaceNames = true;
96 passwordAuthentication = false;
103 MaxRetentionSec=1month
110 environment.systemPackages = with pkgs; [
122 linuxPackages.cpupower
143 environment.variables.SYSTEMD_LESS = "FKMRX";
144 environment.etc."inputrc".text = lib.readFile defaults/readline/inputrc;
148 interactiveShellInit = ''
149 bind '"\e[A":history-search-backward'
150 bind '"\e[B":history-search-forward'
152 # Ignore duplicate commands, ignore commands starting with a space
153 export HISTCONTROL=erasedups:ignorespace
154 export HISTSIZE=42000
156 # Append to the history instead of overwriting (good for multiple connections)
159 # Enable ** file pattern
162 # Convenient mkdir wrapper
163 mkcd() { mkdir -p "$1" && cd "$1"; }
169 ls = "ls --color=tty";
170 mem = "ps -e -orss=,user=,args= | sort -b -k1,1n";
173 st="sudo systemctl status";
174 s-u="systemctl --user";
175 j="sudo journalctl -u";
177 nixos-clean="sudo nix-collect-garbage -d";
178 nixos-history="sudo nix-env --list-generations --profile /nix/var/nix/profiles/system";
179 nixos-rollback="sudo nixos-rebuild switch --rollback";
180 nixos-update="sudo nix-channel --update";
181 nixos-upgrade="sudo nixos-rebuild switch";
182 nixos-upstream="sudo nix-channel --list";
187 pinentryFlavor = "curses";
192 traceroute.enable = true;