Skip to content

Commit

Permalink
Added new host configuration for my GPD Pocket 2
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitawootten committed Dec 8, 2023
1 parent 7fe6438 commit 5d4b78a
Show file tree
Hide file tree
Showing 8 changed files with 342 additions and 106 deletions.
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,44 @@ define IN_NIXSHELL
nix-shell shell.nix --command '$1'
endef

.PHONY: help test update switch-home switch-nixos remote-switch-nixos

# This help command was adapted from https://github.com/tiiuae/sbomnix
# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?##.*$$' $(MAKEFILE_LIST) | awk 'BEGIN { \
FS = ":.*?## "; \
printf "\033[1m%-30s\033[0m %s\n", "TARGET", "DESCRIPTION" \
} \
{ printf "\033[32m%-30s\033[0m %s\n", $$1, $$2 }'

.PHONY: test
test: ## Test flake outputs with "nix flake check"
$(call IN_NIXSHELL,nix flake check)

.PHONY: update
update: ## Update "flake.lock"
$(call IN_NIXSHELL,nix flake update)

.PHONY: switch-home
switch-home: ## Switch local home-manager config
$(call IN_NIXSHELL,home-manager switch --flake .)

.PHONY: build-home
build-home: ## Build local home-manager config
$(call IN_NIXSHELL,home-manager build --flake .)

.PHONY: switch-nixos
switch-nixos: ## Switch local NixOS config
$(call IN_NIXSHELL,sudo nixos-rebuild switch --flake .#)

.PHONY: build-nixos
build-nixos: ## Build local NixOS config
$(call IN_NIXSHELL,sudo nixos-rebuild dry-activate --flake .#)

# Default to connecting to the hostname directly
ADDR=$(HOST)

.PHONY: remote-switch-nixos
remote-switch-nixos: ## Switch a remote NixOS config (e.x. make remote-switch-nixos HOST="" USER="" ADDR="") ADDR defaults to HOST
@if [[ -z "$(HOST)" || -z "$(USER)" || -z "$(ADDR)" ]]; then \
echo 'one or more variables are undefined'; \
Expand All @@ -47,3 +53,9 @@ remote-switch-nixos: ## Switch a remote NixOS config (e.x. make remote-switch-ni

$(call IN_NIXSHELL,NIX_SSHOPTS=-t nixos-rebuild --flake ".#$(HOST)" \
--target-host "$(USER)@$(ADDR)" --use-remote-sudo switch)

# Utility roles

.PHONY: get-hosts
list-hosts: ## List NixOS configuration names
@$(call IN_NIXSHELL,nix flake show --json 2>/dev/null | jq -r ".nixosConfigurations | keys | .[] | @text")
Loading

0 comments on commit 5d4b78a

Please sign in to comment.