diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 29 |
1 files changed, 21 insertions, 8 deletions
@@ -1,20 +1,25 @@ -.PHONY: install update rollback +.PHONY: install update rollback nixos-update nixos-install -SRCDIR = ./nixos +SYSTEM = $(shell uname -n) +SRCDIR = ./$(SYSTEM) DSTDIR = $(HOME) SOURCES := $(shell find -L $(SRCDIR)/ -type f) CONFIGS := $(subst $(SRCDIR)/,$(DSTDIR)/,$(SOURCES:%.org=%)) +UPDATE_TARGET := +INSTALL_TARGET := + +ifeq ($(SYSTEM), nixos) + UPDATE_TARGET += nixos-update + INSTALL_TARGET += nixos-install +endif + all: update -update: install - nix flake update $(DSTDIR)/.flake - cp $(DSTDIR)/.flake/flake.lock $(SRCDIR)/.flake - sudo nixos-rebuild switch --flake $(DSTDIR)/.flake +update: install $(UPDATE_TARGET) -install: $(CONFIGS) - sudo nixos-rebuild switch --flake $(DSTDIR)/.flake +install: $(CONFIGS) $(INSTALL_TARGET) $(DSTDIR)/%: $(SRCDIR)/%.org mkdir -p $(dir $@) @@ -23,3 +28,11 @@ $(DSTDIR)/%: $(SRCDIR)/%.org $(DSTDIR)/%: $(SRCDIR)/% mkdir -p $(dir $@) cp $< $@ + +nixos-update: install + nix flake update $(DSTDIR)/.flake + cp $(DSTDIR)/.flake/flake.lock $(SRCDIR)/.flake + sudo nixos-rebuild switch --flake $(DSTDIR)/.flake + +nixos-install: $(CONFIGS) + sudo nixos-rebuild switch --flake $(DSTDIR)/.flake |