by 96bcaa76-0f27-45e7-9aa3-65c535e53a05

Nixos debian backup

Often it is helpful to have a non nix environment to test things in, my go to choice is debian. this is my config. it just starts a debian instance via nspawn so its very fast.

First get the image and their public key from here hub nspawn

sudo sudo gpg --no-default-keyring \
         --keyserver=keys.openpgp.org \
         --keyring=/etc/systemd/import-pubring.gpg \
         --search 9E31BD4963FC2D19815FA7180E2A1E4B25A425F6
    
sudo machinectl pull-tar \
         --verify=signature \ 
         https://hub.nspawn.org/storage/debian/bookworm/tar/image.tar.xz \
         debian-bookworm

here is the configuation.


{ config, lib, pkgs, ... }:

{
  systemd.targets.machines.enable = true;
  systemd.nspawn."debian-bookworm" = {
    enable = true;
    execConfig = { Boot = true; };

    filesConfig = {
      BindReadOnly =
        [ "/etc/resolv.conf:/etc/resolv.conf" "/etc/hosts:/etc/hosts" ];
    };
    networkConfig = { Private = false; };
  };
  systemd.services."systemd-nspawn@debian-bookworm" = {
    enable = true;
    requiredBy = [ "machines.target" ];
    overrideStrategy = "asDropin";
  };
}

and I can enter it easily

machinectl login debian-bookworm