Create new ssh key:
ssh-keygen -t ed25519 -C [email protected]Secrets are managed with agenix. Create agenix identity key:
mkdir -p ~/.ssh
cp ~/.ssh/id_ed25519 ~/.ssh/agenixTo see age public key use:
nix-shell -p ssh-to-age --run "ssh-to-age -i ~/.ssh/id_ed25519.pub"To create or edit a secret:
cd secrets
agenix -i ~/.ssh/agenix -e secret_name.ageWhen adding a new host key to secrets/secrets.nix, re-encrypt all secrets:
agenix -rTo rebuild and switch to new build:
sudo nixos-rebuild switch --flake .#We can build and test our nixos environment inside virtual machine.
nix build ./#nixosConfigurations.vm.config.system.build.vmStart virtual machine with:
./result/bin/run-nixos-vmTo be able to connect via SSH, we have to forward port 2222 to 22:
QEMU_NET_OPTS="hostfwd=tcp::2222-:22" ./result/bin/run-nixos-vmNow we can ssh to the vm:
ssh -p 2222 nixos@localhostnix --extra-experimental-features "nix-command flakes" run nix-darwin -- switch --flake .#To rebuild on remote host use --target-host, e.g:
nixos-rebuild switch --flake .#m910q1 --target-host 192.168.1.111