The Purely Functional Linux Distribution – NixOS (by Dolstra, Eelco).
NixOS is a Linux distribution with a unique approach to package and configuration management. Built on top of the Nix package manager, it is completely declarative, makes upgrading systems reliable, and has many other advantages.
The configuration is also on GitHub: My NixOS configuration files.
Also, earlier on this site: NixOS.
My configuration
configuration.nix
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
#
# https://nixos.org/nixos/manual/index.html
# https://nixos.org/nixos/options.html
# https://nixos.wiki/wiki/Configuration_Collection
#
... }:
{ config, pkgs,
let unstable = import <nixos-unstable> { config = { allowUnfree = true; }; };
in {
=
imports # Include the results of the hardware scan.
[ ./hardware-configuration.nix
./fs-configuration.nix
./network-configuration.nix
./env-configuration.nix
./vpn-configuration.nix
./cachix.nix
];
# Disable automatic storage optimization (computer needs to be responsive at all times).
# https://nixos.wiki/wiki/Storage_optimization
#nix.gc = {
# automatic = true;
# dates = "weekly";
# options = "--delete-older-than 31d";
#};
# nix.extraOptions = ''
# min-free = ${toString (5 * 1024 * 1024 * 1024)} # 5 GB
# max-free = ${toString (10* 1024 * 1024 * 1024)}
# '';
# Use the GRUB 2 boot loader.
.loader.grub.enable = true;
boot.loader.grub.version = 2;
boot# boot.loader.grub.efiSupport = true;
# boot.loader.grub.efiInstallAsRemovable = true;
# boot.loader.efi.efiSysMountPoint = "/boot/efi";
# Define on which hard drive you want to install Grub.
.loader.grub.device = "/dev/disk/by-id/ata-WDC_WD5000BEKT-60KA9T0_WD-WXG1AA0N9929"; # or "nodev" for efi only
boot# boot.loader.grub.extraConfig = "terminal_input_console terminal_output_console";
# Kernel parameters.
.kernelParams = [ "acpi_osi=Linux" ];
boot
# Obelisk/Reflex -- https://github.com/obsidiansystems/obelisk
= {
nix = [
binaryCaches "https://nixcache.reflex-frp.org"
];= [
binaryCachePublicKeys "ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI="
];
};
.wireshark = {
programs= true;
enable = pkgs.wireshark;
package
};
# Disable automatic refresh of ClamAV signatures database (do this manually).
#services.clamav = {
# # daemon.enable = true;
# updater.enable = true;
#};
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Docker host. The --iptables=false makes sure that Docker doesn't alter
# the firewall (as a default containers should no be accessible from outside).
#
= {
virtualisation = {
docker = true;
enable .enable = true;
autoPrune= "overlay2";
storageDriver #extraOptions = "--iptables=false";
};
.enable = true;
libvirtd
};
# Enable nested virtualization for your guests to run KVM hypervisors
.extraModprobeConfig = "options kvm_intel nested=1";
boot
# Font size.
.fontconfig.dpi=96;
fonts
# Select internationalisation properties.
= {
i18n #consoleFont = "Lat2-Terminus16";
#consoleKeyMap = "us";
= "en_US.UTF-8";
defaultLocale = { LC_MESSAGES = "en_US.UTF-8"; LC_TIME = "nl_NL.UTF-8"; };
extraLocaleSettings
};
= {
console = "Lat2-Terminus16";
font = "us";
keyMap
};
# Set your time zone.
.timeZone = "Europe/Amsterdam";
time
# Allow packages with non-free licenses.
.config.allowUnfree = true;
nixpkgs
# List packages installed in system profile. To search, run:
# `nix search wget`
.systemPackages = with pkgs; [
environment-file-transfer
android
apktool-run
appimage
arandr
ark
ascii.en
aspellDicts.en-computers
aspellDicts.en-science
aspellDicts.nl
aspellDicts
banner
beep-unwrapped
binutils
bpytop-progs
btrfs-install
cabal
cabal2nix
cachix
calibre
castnow
ccache
chromium
clamav
clementineUnfree
cmus
cowsay
cryptsetup
darcs#digikam
docker
docker_compose
dos2unix
e2fsprogs
emacs
entr
ffmpeg
figlet
file
filezilla
firefox
fortune
freetype
ghc
ghcid-with-plugins
gimp
git-crypt
git.gitRemoteGcrypt
gitAndTools.tig
gitAndTools
gnumake
gnupg-chrome
google
gqview
graphviz
hddtemp-gui
heimdall
hledger-ui
hledger
hlint-tidy
html
htop#jdk11
jitsi#kdiff3-qt5
keepassxc
killall
kismet#krita
lftp
libav
libreoffice
lshw
lsof
lynis
mercurial
metasploit
microcodeIntel
mkvtoolnix-with-scripts
mpv
mupdf-index
nix-prefetch-scripts
nix
nmap
nodejs
nomacs
notmuch
offlineimap
openh264
openssl
ormolu
p7zip
pandoc
par
pciutils
pcmanfm#pinentry
-config
pkg
pstree
python3
ranger
rawtherapee
restic
rmlint
sabnzbd
screen
scrot-searcher
silver
smartmontools
snapper-cli
speedtest
sshfs
stack
subdl
tcpdump
telnet.combined.scheme-full
texlive.thunar-volman
xfce
thunderbird#tmux # TODO tmux server crashes after a while...
treeunzip
usbutils
vim
virtmanager
vlc
wcalc
wget
wirelesstools
wmctrl
wmctrl
wpa_supplicant
xclip
xdotool
xlockmore
xmobar#xmonad-with-packages
.xdpyinfo
xorg.xev
xorg.xeyes
xorg.xhost
xorg.xinit
xorg.xkill
xorg.xmessage
xorg.xmodmap
xorg.xwininfo
xorg
xsane
yara-dl
youtube-us
zoom
];
.fwupd.enable = true;
services
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = { enable = true; enableSSHSupport = true; };
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
.openssh = {
services= true;
enable
# Only pubkey auth
= false;
passwordAuthentication = false;
challengeResponseAuthentication
};
# Start ssh-agent as a systemd user service
.ssh.startAgent = true;
programs
# Pinentry.
.gnupg.agent.enable = true;
programs
.tmux = {
programs= true;
enable = true;
clock24 = ''
extraConfig -option -g prefix C-z
set-key C-b
unbind-key C-z send-prefix
bind
'';
};
# Printing. Enable CUPS to print documents.
# https://nixos.wiki/wiki/Printing
.printing.enable = true;
services.printing.drivers = with pkgs; [ hplipWithPlugin ];
services
# Scanning with sane.
.sane.enable = true;
hardware.sane.extraBackends = with pkgs; [ hplipWithPlugin ];
hardware
# Enable sound.
.enable = true;
sound.pulseaudio = {
hardware= true;
enable = true;
support32Bit
};
# OpenGL configuration.
.opengl = {
hardware= true;
enable = true;
driSupport32Bit
};
# Enable Redshift.
.redshift = {
services= true;
enable = {
brightness = "1";
day = "0.90";
night
};= {
temperature = 6500;
day = 3500;
night
};
};.provider = "geoclue2";
location
# Enable the X11 windowing system.
.xserver.enable = true;
services.xserver.layout = "us";
services# services.xserver.xkbVariant = "altgr-intl";
#services.xserver.xkbOptions = "eurosign:e";
# services.xserver.xkbOptions = "compose:caps,shift:both_capslock";
.xserver.xkbOptions = "compose:sclk";
services
# Legacy video driver for NVIDIA GeForce 335M (?) support.
# TODO Package is marked as broken in NixOS stable 20.09 (...)
#services.xserver.videoDrivers = [ "nvidiaLegacy304" ];
# https://nixos.wiki/wiki/Android
.adb.enable = true;
programs
# Enable touchpad support.
.xserver.libinput.enable = true;
services
# Compositor (supposedly fixes screen tearing).
# services.compton.enable = true;
# Required for screen-lock-on-suspend functionality.
.logind.extraConfig = ''
servicesLidSwitchIgnoreInhibited=False
HandleLidSwitch=suspend
HoldoffTimeoutSec=10
'';
# Graphical environment.
.xserver = {
services= {
desktopManager .enable = false;
xterm.enable = true;
xfce
};.defaultSession = "xfce";
displayManager
# Enable the KDE Desktop Environment.
#displayManager.sddm.enable = true;
#desktopManager.plasma5.enable = true;
# Enable xmonad tiling window manager.
# windowManager.xmonad = {
# enable = true;
# enableContribAndExtras = true;
# extraPackages = haskellPackages: [
# haskellPackages.xmonad-contrib
# haskellPackages.xmonad-extras
# haskellPackages.xmonad
# ];
# };
# https://nixos.wiki/wiki/Using_X_without_a_Display_Manager
#displayManager.startx.enable = true; # BEWARE: lightdm doesn't start with this enabled.
.lightdm.enable = true;
displayManager#displayManager.defaultSession = "none+xmonad";
#displayManager.sessionCommands = with pkgs; lib.mkAfter
# ''
# xmodmap /path/to/.Xmodmap
# '';
};
# https://nixos.wiki/wiki/Fonts
.fonts = with pkgs; [
fonts-font
hack-fonts
noto-fonts-cjk
noto-fonts-emoji
noto-fonts
google# liberation_ttf
# fira-code
# fira-code-symbols
# mplus-outline-fonts
# dina-font
# proggyfonts
];
# Define a user account. Don't forget to set a password with ‘passwd’.
.users.mdo = {
users= true;
isNormalUser = [ "wheel" "docker" "libvirtd" "kvm"
extraGroups "audio" "disk" "video" "network"
"systemd-journal" "lp" "scanner" "adbusers" ];
};
.users.csp = {
users= true;
isNormalUser = [ "audio" "disk" "video" ];
extraGroups
};
# This value determines the NixOS release with which your system is to be
# compatible, in order to avoid breaking some software such as database
# servers. You should change this only after NixOS release notes say you
# should.
.stateVersion = "20.03"; # Did you read the comment?
system }
hardware-configuration.nix
# Do not modify this file! It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
... }:
{ config, lib, pkgs,
{=
imports <nixpkgs/nixos/modules/installer/scan/not-detected.nix>
[
];
.initrd.availableKernelModules = [ "ehci_pci" "ahci" "xhci_pci" "usbhid" "usb_storage" "sd_mod" "sdhci_pci" "rtsx_pci_sdmmc" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
boot
.maxJobs = lib.mkDefault 4;
nix }
fs-configuration.nix
... }:
{ config, pkgs,
{# Root filesystem.
#
."/" =
fileSystems= "/dev/disk/by-uuid/8be69c44-b987-4eb8-a1b6-c67ed80c9512";
{ device = "btrfs";
fsType = [ "noatime" "space_cache" ];
options
};
# Boot filesystem.
#
."/boot" =
fileSystems= "/dev/disk/by-uuid/bc62f488-7c99-4a12-816c-1aa671557a9d";
{ device = "ext4";
fsType
};
# Encrypted partition.
#
.initrd.luks.devices."cr-home" = {
boot= "/dev/disk/by-uuid/75236c0e-cad4-43a7-986c-a5f82f68cf65";
device
};
."/home" =
fileSystems= "/dev/mapper/cr-home";
{ device = "btrfs";
fsType = [ "noatime" "space_cache" ];
options
};
# Swap partition.
#
=
swapDevices = "/dev/disk/by-uuid/99be5bc9-fac4-4386-83c0-63632edef9dc"; }
[ { device
];
# Enable NTFS support.
.supportedFilesystems = [ "ntfs" ];
boot }
network-configuration.nix
... }:
{ config, pkgs,
{#networking.networkmanager.enable = true;
#networking.networkmanager.wifi.powersave = false;
.hostName = "yourhostname"; # Define your hostname.
networking.nameservers = [ "1.1.1.1" "9.9.9.9" ];
networking.wireless.enable = false; # Wireless support via wpa_supplicant.
networking.wireless.networks = {
networking"home" = {
= "home wireless network pre-shared-key";
psk
};#free.wifi = {}; # Public wireless network
};.wireless.userControlled = {
networking= true;
enable group = "network";
};
# Open ports in the firewall.
.firewall.allowedTCPPorts = [ 22 80 443 ];
networking# networking.firewall.allowedUDPPorts = [ ... ];
.firewall.enable = true;
networking
# The global useDHCP flag is deprecated, therefore explicitly set to false here.
# Per-interface useDHCP will be mandatory in the future, so this generated config
# replicates the default behaviour.
.useDHCP = false;
networking.interfaces.ens5.useDHCP = true;
networking.interfaces.wlp3s0.useDHCP = true;
networking
# Workaround for the no network after resume bug.
.resumeCommands = ''
powerManagement${pkgs.systemd}/bin/systemctl restart wpa_supplicant
'';
# https://github.com/NixOS/nixpkgs/issues/49630
# (the suggested --load-media-router-component-extension=1 appears to be no longer required.)
.avahi.enable = true;
services }
env-configuration.nix
... }:
{ config, pkgs,
{# Environment variables.
.variables = {
environment#PATH="$PATH:$HOME/bin";
TERM = "xterm-256color";
# PS1 = "\[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]\$\[\033[00m\] ";
EDITOR = "vi";
HISTCONTROL = "ignoredups:erasedups";
QT_LOGGING_RULES = "*=false";
FREETYPE_PROPERTIES = "truetype:interpreter-version=38";
.interactiveShellInit = ''
environment#alias config='git --git-dir=/home/mdo/.cfg/ --work-tree=/home/mdo'
''; }
vpn-configuration.nix
Disclaimer: didn’t test this configuratiion yet.
... }:
{ config, pkgs,
{# https://nixos.wiki/wiki/OpenVPN
.openvpn.servers = {
services= { config = '' config /root/vpn/nl1-mdonkers.ovpn ''; autoStart = false;};
nl1VPN = { config = '' config /root/vpn/fr1-mdonkers.ovpn ''; autoStart = false;};
fr1VPN = { config = '' config /root/vpn/es1-mdonkers.ovpn ''; autoStart = false;};
es1VPN = { config = '' config /root/vpn/us1-mdonkers.ovpn''; autoStart = false;};
us1VPN
}; }