Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 1.13 KB

nixos.md

File metadata and controls

40 lines (30 loc) · 1.13 KB

How to switch to flakes from path-based nix

  1. drop this in /etc/nixos/flake.nix
{
  description = "system flake";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  };

  outputs = {nixpkgs, ...}: {
    nixosConfigurations = {
      hostname = nixpkgs.lib.nixosSystem {
        modules = [
          ./configuration.nix
        ];
      };
    };
  };
}
  1. change hostname (and optionally, the nixpkgs url if e.g. you want to use a stable branch)
  2. run nix flake update
  3. rebuild your system (nixos-rebuild boot)
  4. congrats you now use flakes

How to update your system

  1. run nix flake update
  2. rebuild your system

You can also freely move the flake (the contents of /etc/nixos to any other location, and/or create a version-controlled (e.g. git-controlled) repo out of it. If you do so, you can pass --flake /PATH/TO/FLAKE to nixos-rebuild.

Refer to man nixos-rebuild and man nix3-flake for more info.

If you do use git, do not ignore the flake.lock; always include it in commits. That's how you keep reproducibility of your config and allow rolling back in case of breakage.