panacea/configuration.nix

146 lines
4.0 KiB
Nix

{ config, lib, pkgs, ... }:
{
# Kernel configuration
boot = {
kernelPackages = pkgs.linuxPackages_latest;
kernelParams = [ "zfs.zfs_arc_max=536870912" ];
kernelModules = [ "i915" "acpi_call" "kvm-intel" ];
extraModulePackages = with config.boot.kernelPackages; [ acpi_call ];
supportedFilesystems = [ "zfs" ];
zfs.requestEncryptionCredentials = true;
};
# Intel CPU tweaks
hardware.cpu.intel.updateMicrocode =
lib.mkDefault config.hardware.enableRedistributableFirmware;
hardware.opengl.extraPackages = with pkgs; [
vaapiIntel
vaapiVdpau
libvdpau-va-gl
];
# Bootloader configuration
boot.loader = {
efi.canTouchEfiVariables = true;
systemd-boot = {
enable = true;
configurationLimit = 50;
};
};
# Run Nix garbage collector, while avoiding compiling
nix = {
gc = {
automatic = true;
options = "--delete-older-than 14d";
dates = "14:30";
};
extraOptions = ''
keep-outputs = true
gc-keep-outputs = true
'';
};
# Clean tmp directory on shutdown
boot.cleanTmpDir = true;
# Rotate logs after 7 days
services.journald.extraConfig = "SystemMaxFiles=7";
# Allow propietary software
nixpkgs.config = {
allowUnfree = true;
pulseaudio = true;
};
# Scrub zpool monthly
services.zfs.autoScrub = {
enable = true;
interval = "monthly";
};
# Set timezone and synchronize NTP
time.timeZone = "Europe/Brussels";
services.timesyncd.enable = true;
# Enable the TLP daemon
services.tlp = {
enable = true;
extraConfig = ''
# Use the new CPU frequency scaling governor
CPU_SCALING_GOVERNOR_ON_AC=schedutil
CPU_SCALING_GOVERNOR_ON_BAT=schedutil
# Adjust CPU frequencies accordingly to the power state
CPU_SCALING_MIN_FREQ_ON_AC=800000
CPU_SCALING_MAX_FREQ_ON_AC=3000000
CPU_SCALING_MIN_FREQ_ON_BAT=800000
CPU_SCALING_MAX_FREQ_ON_BAT=2300000
# Enable audio power saving for Intel HDA, AC97 devices (timeout in secs).
# A value of 0 disables, >=1 enables power saving (recommended: 1).
# Default: 0 (AC), 1 (BAT)
SOUND_POWER_SAVE_ON_AC=0
SOUND_POWER_SAVE_ON_BAT=1
# Runtime Power Management for PCI(e) bus devices: on=disable, auto=enable.
# Default: on (AC), auto (BAT)
RUNTIME_PM_ON_AC=on
RUNTIME_PM_ON_BAT=auto
# Battery feature drivers: 0=disable, 1=enable
# Default: 1 (all)
NATACPI_ENABLE=1
TPACPI_ENABLE=1
TPSMAPI_ENABLE=1
'';
};
# NixOS version
system.stateVersion = "20.09";
# Create coolneng user
users.users.coolneng = {
isNormalUser = true;
home = "/home/coolneng";
extraGroups = [ "wheel" "video" "audio" "libvirtd" "lp" ];
shell = pkgs.fish;
};
# Set shell and SSH for root user
users.users.root = {
shell = pkgs.fish;
openssh.authorizedKeys.keys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC9mMwf7yXwtiEABwq5zkNEXgveUhNEPfqa3VLdnG2UYArB6f2l2aFM+MkGc8s84T8cj7JDF2N1pEBvilGMNWmLT32IBfwjyJov/38/PTpWb3301hCck5EOWmykGWMXdRlIEj6vsR4UqeRFwbr8QBlxv2dTPe9wTrCLvkKOuaPWMyMgtEwnNHvB8e7eqUZZYVmRSQkWCqYmK7a6TCvHUg3XsmjQU3OSmTH+eXJEUL4OiSFKxd9eO5QU04uYDbX8f8jY/slReoEWbuJ/InSWFbPs6L3bUYQrl3ht/7DR9FqzcOpAN4AcrJFyIJzot8inpp6f5IsVVjy0dhNUGWtXMkOgNf6lmylokqFBb1Jcy/lJbgUtJZ5ZNjlJFCbjXHe6J0q7bYKJgMQKuY1N3rexhZIMsBXi8aYaSKaGqX7TPnBEPlr1hXda2lGm2l6jQq5Lj2U5aj5aBa/BYmKFGVxcMpRFlsWfYPyQ/2wxRcpNcDiJt0eWP70mhu8OcupPO9kxGw0= coolneng@panacea"
];
};
# Auto-upgrade the system
system.autoUpgrade = {
enable = true;
dates = "14:00";
};
# Suspend to RAM/disk when battery is critical
services.upower = {
enable = true;
percentageAction = 5;
criticalPowerAction = "HybridSleep";
};
# Import other configuration modules
imports = [
./modules/software.nix
./modules/networking.nix
./modules/gui.nix
./modules/datasync.nix
./modules/audio.nix
./modules/development.nix
./modules/printing.nix
./modules/hardware-configuration.nix
];
}