NixOS examples
With the power of the NixOS options, you can customize all the parts of your system without having to switch between contexts / different configuration paradigms / languages.
You can share variables in the Nix configuration across the different components
- e.g. when configuring server, the domain name and specific service ports can be defined at the top of the configuration file and then reused everywhere
- this removes duplication in your system configuration
Boot opions
Latest kernel + kernel parameter + systemd-boot instead of grub
{
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.kernelParams = [ "amd_pstate=active" ];
boot.loader.systemd-boot.enable = true;
}
System packages
Packages available to all system users:
{
environment.systemPackages = with pkgs; [
gnome.seahorse
sshfs
]
}
User management
{
users.users.tom = {
isNormalUser = true;
description = "T.K.";
extraGroups = [ "networkmanager" "wheel" "video" ];
};
users.users.nixremote = {
isNormalUser = true;
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFa5xTjWp9+btqQ0hkJiU3gys0xD3/uCXK48ZbzlMvjL"
];
};
}
Install hardware drivers
{
hardware.bluetooth.enable = true;
hardware.opengl.enable = true;
}
Installing fonts
{
fonts.packages = with pkgs; [
font-awesome
nerdfonts
cantarell-fonts
iosevka
];
}
Networking
{
networking = {
hostName = "ideapad";
networkmanager.enable = true;
networkmanager.dns = "none";
nameservers = [ "127.0.0.1" "::1" ];
};
}
Enable services
SSH
{
services.openssh = {
enable = true;
settings.PasswordAuthentication = false;
};
}
Builtin services
{
services.fstrim.enable = true;
services.printing.enable = true;
services.gnome.gnome-keyring.enable = true;
services.blueman.enable = true;
services.dnscrypt-proxy2.enable = true;
}
Custom systemd service
{
systemd.services.suspend = {
description = "User suspend actions";
before = [ "sleep.target" ];
wantedBy = [ "sleep.target" ];
serviceConfig = {
ExecStart = "systemd-run --user --machine=tom@ ${pkgs.swaylock}/bin/swaylock";
ExecStartPost = "${pkgs.coreutils}/bin/sleep 1";
};
};
}
Custom systemd timer
{
systemd.timers.inadyn = {
description = "Sync ddns every ${cfg.period}";
wantedBy = [ "default.target" ];
timerConfig = {
OnBootSec = "2m";
OnUnitActiveSec = cfg.period;
};
};
}
Experiment without fear!
- different kernels + kernel arguments
- different gpu drivers
- different OpenCL + Vulkan implementations
- kernel modules (zram + zswap)
- power management
- custom cpu microcode updates
- custom dns server
- get rid of x11
- ...
when you're done... you're done!