1 { 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=${toString pkgs.path}:nixpkgs-overlays=${../nixpkgs}/overlays.nix"
33 packageOverrides = pkgs: {
34 postfix = pkgs.postfix.override {
40 overlays = import ../nixpkgs/overlays.nix;
43 documentation.nixos = {
44 enable = false; # NOTE: useless on a server, and CPU intensive.
48 timeZone = "Europe/Paris";
52 defaultLocale = "fr_FR.UTF-8";
56 font = "Lat2-Terminus16";
60 # Always try to start all the units (default.target)
61 # because systemd's emergency shell does not try to start sshd.
62 # https://wiki.archlinux.org/index.php/systemd#Disable_emergency_mode_on_remote_machine
63 systemd.enableEmergencyMode = false;
65 # This is a remote headless server: always reboot on a kernel panic,
66 # to not have to physically go power cycle the apu2e4.
67 # Which happens if the wrong ZFS password is used
68 # but the boot is manually forced to continue.
69 # Using kernelParams instead of kernel.sysctl
70 # sets this up as soon as the initrd.
71 boot.kernelParams = [ "panic=10" ];
73 boot.cleanTmpDir = true;
74 boot.tmpOnTmpfs = true;
78 # See: https://github.com/NixOS/nixpkgs/issues/10183#issuecomment-537629621
80 "127.0.1.1" = lib.mkForce [ "${hostName}.${domain}" hostName ];
81 "::1" = lib.mkForce [ "${hostName}.${domain}" hostName "localhost" ];
89 passwordAuthentication = false;
96 MaxRetentionSec=3month
104 #checkConfigurationOptions = false;
105 #etc.nixpkgs.source = (pkgs.runCommandLocal "pkgs.path" {propagatedBuildInputs=[pkgs.path]; buildInputs=[pkgs.path];} "mkdir $out");
106 systemPackages = with pkgs; [
107 pkgs.path # WARNING: this is a hack to register the path to Nixpkgs. See nix.nixPath.
119 linuxPackages.cpupower
136 etc."inputrc".text = lib.readFile defaults/readline/inputrc;
138 variables.SYSTEMD_LESS = "FKMRX";
143 interactiveShellInit = ''
144 bind '"\e[A":history-search-backward'
145 bind '"\e[B":history-search-forward'
147 # Ignore duplicate commands, ignore commands starting with a space
148 export HISTCONTROL=erasedups:ignorespace
149 export HISTSIZE=42000
151 # Append to the history instead of overwriting (good for multiple connections)
154 # Enable ** file pattern
157 # Convenient mkdir wrapper
158 mkcd() { mkdir -p "$1" && cd "$1"; }
164 ls = "ls --color=tty";
165 mem = "ps -e -orss=,user=,args= | sort -b -k1,1n";
168 st="sudo systemctl status";
169 s-u="systemctl --user";
170 j="sudo journalctl -u";
172 nixos-clean="sudo nix-collect-garbage -d";
173 nixos-history="sudo nix-env --list-generations --profile /nix/var/nix/profiles/system";
174 nixos-rollback="sudo nixos-rebuild switch --rollback";
175 nixos-update="sudo nix-channel --update";
176 nixos-upgrade="sudo nixos-rebuild switch";
177 nixos-upstream="sudo nix-channel --list";
182 pinentryFlavor = "curses";