Skip to content

NixOS

NixOS Wiki

Forums

Basic NixOS commands

  • sudo nixos-collect-garbage --delete-older-than 15d` - deletes NixOS configurations older than 15 days\

Example Flake

see the NixOS Wiki for helpful notes.

Building a configuration.nix the nixos-unstable channel

{
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
  };
  outputs = { self, nixpkgs }: {
    # replace 'joes-desktop' with your hostname here.
    nixosConfigurations.media = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [ ./configuration.nix ];
    };
  };
}

ZFS on NixOS

see the NixOS Wiki on ZFS, or look up specific options using the NixOS options search

Example Configuration Settings

# Networking
networking.hostId = "4f98920a"; # used to make sure the pool is imported correctly

# Basic ZFS Settings
boot.supportedFilesystems = [ "zfs" ]; # enable zfs
boot.zfs.forceImportRoot = false; # force the import of zfs root pools
boot.zfs.extraPools = [ "my-pool" "my-other-pool" ]; # mount the pools listed on boot

# Autoscrubbing settings
services.zfs.autoScrub = {
  enable = true; # enable autoscrubbing
  interval = monthly; # default interval for autoscrub is every month
};

# Autosnapshot settings
services.zfs.autoSnapshot = {
  enable = true; # enable snapshots
  montly = 12; # number of monthly snapshots to keep
  weekly = 52; # number of weekly snapshots to keep
  daily = 7; # dido
  hourly = 24; # dido
  frequent = 4; # number of 15 min interval snapshots to keep
};