1 { flakes, pkgs, lib, config, ... }:
 
   2 let inherit (lib) types;
 
   3     inherit (config.networking) hostName domain;
 
   8   defaults/predictable-interface-names.nix
 
  11   #binaryCaches = lib.mkForce [];
 
  14   # Use gc.automatic to keep disk space under control.
 
  16     automatic = lib.mkDefault true;
 
  17     dates = lib.mkDefault "weekly";
 
  18     options = lib.mkDefault "--delete-older-than 30d";
 
  21     # WARNING: this is a hack to avoid copying Nixpkgs
 
  22     # a second time into the Nix store.
 
  23     # It makes only sense when Nixpkgs is already in the Nix store,
 
  25     "nixpkgs=/etc/nixpkgs:nixpkgs-overlays=/etc/nixpkgs-overlays/overlays.nix"
 
  28 environment.etc."nixpkgs".source = flakes.nixpkgs;
 
  29 environment.etc."nixpkgs-overlays".source = flakes.self + "/nixpkgs";
 
  35     packageOverrides = pkgs: {
 
  36       postfix = pkgs.postfix.override {
 
  44 documentation.nixos = {
 
  45   enable = false; # NOTE: useless on a server, and CPU intensive.
 
  49   timeZone = "Europe/Paris";
 
  53   defaultLocale = "fr_FR.UTF-8";
 
  57   font   = "Lat2-Terminus16";
 
  61 # Always try to start all the units (default.target)
 
  62 # because systemd's emergency shell does not try to start sshd.
 
  63 # https://wiki.archlinux.org/index.php/systemd#Disable_emergency_mode_on_remote_machine
 
  64 systemd.enableEmergencyMode = false;
 
  66 # This is a remote headless server: always reboot on a kernel panic,
 
  67 # to not have to physically go power cycle the apu2e4.
 
  68 # Which happens if the wrong ZFS password is used
 
  69 # but the boot is manually forced to continue.
 
  70 # Using kernelParams instead of kernel.sysctl
 
  71 # sets this up as soon as the initrd.
 
  72 boot.kernelParams = [ "panic=10" ];
 
  74 boot.cleanTmpDir = true;
 
  75 boot.tmpOnTmpfs = true;
 
  79   # See: https://github.com/NixOS/nixpkgs/issues/10183#issuecomment-537629621
 
  81     "127.0.1.1" = lib.mkForce [ "${hostName}.${domain}" hostName ];
 
  82     "::1"       = lib.mkForce [ "${hostName}.${domain}" hostName "localhost" ];
 
  90     passwordAuthentication = false;
 
  97       MaxRetentionSec=3month
 
 104 environment.systemPackages = with pkgs; [
 
 116   linuxPackages.cpupower
 
 132 environment.variables.SYSTEMD_LESS = "FKMRX";
 
 133 environment.etc."inputrc".text = lib.readFile defaults/readline/inputrc;
 
 137     interactiveShellInit = ''
 
 138       bind '"\e[A":history-search-backward'
 
 139       bind '"\e[B":history-search-forward'
 
 141       # Ignore duplicate commands, ignore commands starting with a space
 
 142       export HISTCONTROL=erasedups:ignorespace
 
 143       export HISTSIZE=42000
 
 145       # Append to the history instead of overwriting (good for multiple connections)
 
 148       # Enable ** file pattern
 
 151       # Convenient mkdir wrapper
 
 152       mkcd() { mkdir -p "$1" && cd "$1"; }
 
 158       ls = "ls --color=tty";
 
 159       mem = "ps -e -orss=,user=,args= | sort -b -k1,1n";
 
 162       st="sudo systemctl status";
 
 163       s-u="systemctl --user";
 
 164       j="sudo journalctl -u";
 
 166       nixos-clean="sudo nix-collect-garbage -d";
 
 167       nixos-history="sudo nix-env --list-generations --profile /nix/var/nix/profiles/system";
 
 168       nixos-rollback="sudo nixos-rebuild switch --rollback";
 
 169       nixos-update="sudo nix-channel --update";
 
 170       nixos-upgrade="sudo nixos-rebuild switch";
 
 171       nixos-upstream="sudo nix-channel --list";
 
 176       pinentryFlavor = "curses";