Skip to content

Nix development

Open a Python shell in a test virtual machine

  1. Start the interactive test driver:

    nix run .#checks.x86_64-linux.<machine-name>-test.driverInteractive
    

    To exit the test driver, use the CTRL-d key combination.

  2. Start all machines:

    start_all()
    
  3. Open a Linux shell:

    machine.shell_interact()
    

Nix GitOps

Nix machines run comin to implement GitOps.

Pushing commits to branches named testing-<host-name> makes comin pull changes, apply them, but not update the bootloader to boot from the newly generated configuration. Comin updates the bootloader when commits are pushed to the default branch. For more info, see Comin how-tos.

If the default branch changes, update config/nix/roles/comin/default.nix accordingly.

Nix commands

  • nix flake metadata <path>: show flake metadata
  • nix flake show <path>: show information about the flake
  • nix fmt . -- --clear-cache: format the Nix codebase
  • nix build .#checks.x86_64-linux.lint-treefmt-nix --verbose: run linting and formatting checks
  • nixos-rebuild switch --flake ".#<host>" --target-host "<ssh-user>@<host>" --sudo: apply changes to host when it's not running comin.
  • nix flake check <path>: run all flake checks
  • nix build <path>#checks.<check-name>: run a specific check
  • nix build <path>#<package-name>: build specific package
    • nix build --rebuild <path>#<package-name>: rebuild a package
    • nix build --print-build-logs <path>#<package-name>: print build log
  • nix-store --gc: clean the Nix store