deploy-rs + nixos-anywhere

This commit is contained in:
Squibid 2025-11-25 10:42:04 -05:00
parent 469f4dcd43
commit d28ec06ae9
Signed by: squibid
GPG key ID: BECE5684D3C4005D
8 changed files with 182 additions and 24 deletions

View file

@ -1,25 +1,35 @@
IP ?=
HOST ?=
deploy:
# push flake config to a remote server
init:
ifeq ($(IP),)
$(error IP not set)
endif
ifeq ($(HOST),)
$(error HOST not set)
endif
nix run github:nix-community/nixos-anywhere -- --flake .#$(HOST) --generate-hardware-config nixos-generate-config ./hosts/$(HOST)/hardware-configuration.nix --target-host nixos@$(IP)
deploy:
# no impurity allowed
ifneq ($(shell git diff),)
git add .
git commit -m "auto commit on build" -m "`PAGER=cat git diff --name-only --cached`"
endif
rsync -azr ./ crown@$(IP):~/flake-config
ssh crown@$(IP) "sudo NIX_CONFIG='experimental-features = flakes pipe-operators' nixos-rebuild switch --flake ~/flake-config#$(HOST)"
# push flake config to a remote server(s)
nix run github:serokell/deploy-rs .
sops:
# update sops keys
# For setting up a new host: to generate a sops key from an existing ssh key
# just run `cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age` and then add
# that to the .sops.yaml file
sops updatekeys secrets.yaml
.DEFAULT_GOAL := default
.PHONY: default deploy sops
.PHONY: default deploy init sops
default:
# noop
# This is my tiny makefile to create new machines and update existing ones
# it requires you to have nix and sops installed to correctly setup a new
# system and nix to deploy to an existing one.
#
# I'm not using just cause I've already got make installed everywhere and I
# know how to use it.