NixOS-Configs/makefile
2024-11-04 22:24:29 -06:00

75 lines
2.1 KiB
Makefile

HOSTNAME := $(shell hostname -s)
all: test
test:
@alejandra . &> nixos-switch.log || ( cat nixos-switch.log && false)
@colmena build --on $(HOSTNAME)
switch: prep
@colmena apply --on ${HOSTNAME}
world: prep
@colmena apply
workstation: prep
@colmena apply --on @workstation
server: prep
@colmena apply --on @server
web: prep
@colmena apply --on @web
vm:
@alejandra . &> nixos-switch.log || ( cat nixos-switch.log && false)
@rm -f nixos-switch.log
@echo Running iso build
@nix build --impure ./#nixosConfigurations.vm.config.system.build.isoImage &> nixos-switch.log || ( grep -E --color '(error|For full logs)' nixos-switch.log && false)
weekly: pull clean update world ci push clean-world
cweekly: clean pull switch clean
update:
@echo "Updating flake.lock"
@nix flake update &> nixos-switch.log || ( cat nixos-switch.log && false)
@rm -f nixos-switch.log
clean:
@echo "Cleaning old entries and store"
@home-manager expire-generations "-5 days"
@echo "Garbage Collection"
@colmena exec nix-collect-garbage --quiet --log-format bar --no-build-output --delete-old
@echo "Store optimise"
@colmena exec nix store optimise
clean-world:
@colmena exec 'home-manager expire-generations "-5 days"'
@colmena exec 'nix-collect-garbage --quiet --log-format bar --no-build-output --delete-old'
@colmena exec 'nix store optimise'
push:
@echo pushing to git
@git push
pull:
@echo Updating from git repo
@git pull &> nixos-switch.log || ( cat nixos-switch.log && false)
@rm -f nixos-switch.log
@doas nix-prefetch-url file://$$PWD/$$(ls -1 src/linuxx64* | tail -n1) &> nixos-switch.log || ( cat nixos-switch.log && false)
@rm -f nixos-switch.log
@ # doas nix-prefetch-url file://$$PWD/$$(ls -1 src/linuxarm64* | tail -n1) &> nixos-switch.log || ( cat nixos-switch.log && false)
@ # rm -f nixos-switch.log
ci:
@echo "git commit all"
@git commit -m"updates from makefile" --all &> nixos-switch.log || ( cat nixos-switch.log && false)
@rm -f nixos-switch.log
prep:
@alejandra . &> nixos-switch.log || ( cat nixos-switch.log && false)
@colmena exec "locate home-manager-backup | sort -u | xargs rm -f"
reboot:
@doas reboot