2020-04-12 18:12:01 -07:00
|
|
|
USER := hlissner
|
|
|
|
HOST := kuro
|
|
|
|
|
2020-04-22 16:52:48 -07:00
|
|
|
NIXOS_VERSION := 20.03
|
2020-01-12 15:17:45 -08:00
|
|
|
NIXOS_PREFIX := $(PREFIX)/etc/nixos
|
2020-01-12 17:42:17 -08:00
|
|
|
COMMAND := test
|
2020-02-01 18:05:55 -08:00
|
|
|
FLAGS := -I "config=$$(pwd)/config" \
|
|
|
|
-I "modules=$$(pwd)/modules" \
|
|
|
|
-I "bin=$$(pwd)/bin" \
|
|
|
|
$(FLAGS)
|
2020-01-12 15:17:45 -08:00
|
|
|
|
2020-01-12 17:42:17 -08:00
|
|
|
# The real Labowski
|
2020-01-13 21:33:45 -08:00
|
|
|
all: channels
|
2020-01-12 17:42:17 -08:00
|
|
|
@sudo nixos-rebuild $(FLAGS) $(COMMAND)
|
2020-01-12 15:17:45 -08:00
|
|
|
|
2020-01-13 16:56:39 -08:00
|
|
|
install: channels update config
|
|
|
|
@sudo nixos-install --root "$(PREFIX)" $(FLAGS)
|
2020-01-13 14:57:52 -08:00
|
|
|
|
2020-01-12 15:17:45 -08:00
|
|
|
upgrade: update switch
|
|
|
|
|
2020-01-13 16:56:39 -08:00
|
|
|
update:
|
|
|
|
@sudo nix-channel --update
|
|
|
|
|
2020-01-12 15:17:45 -08:00
|
|
|
switch:
|
2020-01-12 17:42:17 -08:00
|
|
|
@sudo nixos-rebuild $(FLAGS) switch
|
2020-01-12 15:17:45 -08:00
|
|
|
|
2020-03-27 18:33:34 -07:00
|
|
|
build:
|
|
|
|
@sudo nixos-rebuild $(FLAGS) build
|
|
|
|
|
2020-01-17 01:23:19 -08:00
|
|
|
boot:
|
|
|
|
@sudo nixos-rebuild $(FLAGS) boot
|
|
|
|
|
|
|
|
rollback:
|
|
|
|
@sudo nixos-rebuild $(FLAGS) --rollback $(COMMAND)
|
|
|
|
|
|
|
|
dry:
|
|
|
|
@sudo nixos-rebuild $(FLAGS) dry-build
|
|
|
|
|
2020-01-13 15:07:59 -08:00
|
|
|
gc:
|
|
|
|
@nix-collect-garbage -d
|
|
|
|
|
2020-03-27 18:33:34 -07:00
|
|
|
vm:
|
|
|
|
@sudo nixos-rebuild $(FLAGS) build-vm
|
|
|
|
|
2020-01-12 15:17:45 -08:00
|
|
|
clean:
|
2020-01-13 21:33:45 -08:00
|
|
|
@rm -f result
|
2020-01-12 15:17:45 -08:00
|
|
|
|
|
|
|
|
|
|
|
# Parts
|
|
|
|
config: $(NIXOS_PREFIX)/configuration.nix
|
|
|
|
|
|
|
|
channels:
|
2020-01-12 17:42:17 -08:00
|
|
|
@sudo nix-channel --add "https://nixos.org/channels/nixos-${NIXOS_VERSION}" nixos
|
|
|
|
@sudo nix-channel --add "https://github.com/rycee/home-manager/archive/release-${NIXOS_VERSION}.tar.gz" home-manager
|
|
|
|
@sudo nix-channel --add "https://nixos.org/channels/nixpkgs-unstable" nixpkgs-unstable
|
2020-01-12 15:17:45 -08:00
|
|
|
|
|
|
|
$(NIXOS_PREFIX)/configuration.nix:
|
2020-01-13 16:56:39 -08:00
|
|
|
@sudo nixos-generate-config --root "$(PREFIX)"
|
2020-04-06 20:06:47 -07:00
|
|
|
@echo "import /etc/dotfiles \"$${HOST:-$$(hostname)}\" \"$$USER\"" | sudo tee "$(NIXOS_PREFIX)/configuration.nix"
|
2020-04-12 18:12:01 -07:00
|
|
|
@[ -f machines/$(HOST).nix ] || echo "WARNING: hosts/$(HOST)/default.nix does not exist"
|
2020-01-12 15:17:45 -08:00
|
|
|
|
2020-01-12 17:42:17 -08:00
|
|
|
|
|
|
|
# Convenience aliases
|
|
|
|
i: install
|
|
|
|
s: switch
|
|
|
|
up: upgrade
|
|
|
|
|
|
|
|
|
2020-01-17 01:22:50 -08:00
|
|
|
.PHONY: config
|