Skip to content
one hour, hands-on
Branch: master
Clone or download
Latest commit be04ac8 Apr 23, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
nixos fix username Mar 2, 2019 Update Apr 23, 2019 update apt and nix commands in cheatsheet Apr 14, 2018 better examples Feb 27, 2019

check the cheatsheet


  • setup (5m)
  • nix-env package management (10m)
  • nix-shell isolated environments (10m)
  • NixOS declarative operating system configuration
    • introduction (5m)
    • service (5m)
    • network (5m)
    • user (5m)
  • conclusion (5m)


package management with nix-env

update package list sudo nix-channel --update
search nix search hello
live search
install nix-env -i hello run with hello
uninstall nix-env -e hello running hello fails
rollback nix-env --rollback hello is back

isolated environments with nix-shell

  • start a shell in an environment with some packages available:
    • nix-shell -p toilet
      • toilet hello
      • Ctrl+D to exit nix-shell
      • toilet hello
    • nix-shell -p toilet --run 'toilet --gay hello
    • python example
  • nix-shell on its own will load default.nix or shell.nix from the current directory, where you can define an environment for a project

NixOS declarative operating system configuration

  • edit /etc/nixos/configuration.nix
    • eg. add services.openssh.enable = true; before the last }
  • nixos-rebuild switch to the new configuration
  • see option's current value and documentation by running nixos-option services.openssh.enable
  • search, click the result, click the link after "Declared in:"
  • nixos-rebuild switch --rollback to previous configuration

let's try a few configuration options:





  • networking.hostname = "darkstar";
  • networking.firewall.allowedTCPPorts = [ 22 80 8000 ];


  • declarative - say what you want, not how to get there
  • safe (atomic, rollback, isolated, consistent)
  • reliable (deterministic, reproducible)
  • fast (lazy, perfect cache)
You can’t perform that action at this time.