-
Notifications
You must be signed in to change notification settings - Fork 0
Get rid of most of make targets #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+315
−226
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
2517501
Remove inputs-update target
booxter 0716381
Define default make target to print available targets
booxter e247ecd
Untangle update script from make
booxter 2ab5669
flake: add fleet-upgrade app for machine updates
booxter de5aa3d
flake: expose pi-image package and drop make target
booxter 1152012
formatter: keep trailing newline in Makefile
booxter e96b629
make: remove switch convenience targets
booxter c37dee9
make: drop unused local build convenience targets
booxter 351bf8b
make: remove bats convenience target
booxter a316adf
docs: clarify local test commands
booxter b550ed5
make: clarify REMOTE support for darwin build target
booxter d57b093
ci: build qemu attrs directly and drop make wrapper
booxter 28ef04e
make: drop nixos-run-vm target
booxter 0a63928
ci: drop nixos-build-vm make target
booxter 05409df
ci: use platform-specific home-manager build targets
booxter a5260de
apps: make fleet-apply a dispatcher for deploy and home
booxter 004249b
apps: add disko mode to fleet-apply and remove make target
booxter 3d5c063
apps: add vm app and drop make local-vm target
booxter 15d0f97
make: rename build targets and improve nixos host resolution
booxter 1393c32
apps: rename fleet app to fleet-deploy and simplify docs
booxter fbb076f
apps: add pinned get-local-builders app for make
booxter 353383e
ci: update build-targets matrix for renamed make targets
booxter 401bda4
Merge remote-tracking branch 'origin/master' into get-rid-of-make-tar…
booxter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [formatter] | ||
| ensure_final_newline = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,129 +1,87 @@ | ||
| # Define common args | ||
| .DEFAULT_GOAL := help | ||
| .PHONY: help nixos darwin linux-home darwin-home | ||
|
|
||
| ARGS = -L --show-trace | ||
| HM_ARGS = -b backup | ||
| USERNAME ?= ihrachyshka | ||
|
|
||
| NIX_OPTS = \ | ||
| --extra-experimental-features 'nix-command flakes' | ||
|
|
||
| NIXOS_CONFIGS = nix flake show --json 2>/dev/null | jq -r -c '.nixosConfigurations | keys[]' | ||
| VM_TYPES = $(NIXOS_CONFIGS) | grep '^$(1)-.*vm$$' | sed 's/vm$$//' | sed 's/^$(1)-//' | ||
| define home-targets-for-system | ||
| nix eval --json --apply 'hc: builtins.mapAttrs (_: v: v.activationPackage.drvAttrs.system) hc' .#homeConfigurations \ | ||
| | jq -r 'to_entries[] | select(.value=="$(1)") | .key' \ | ||
| | sed 's/^$(USERNAME)@//' | ||
| endef | ||
|
|
||
| REMOTE ?= true | ||
| LOCAL_LOCAL_BUILDERS := $(shell ./scripts/get-local-builders.sh --local) | ||
| LOCAL_LOCAL_BUILDERS = $(shell nix run --quiet --option builders '' .#get-local-builders -- --local) | ||
|
|
||
| define builder-opts | ||
| $(if $(filter false,$(REMOTE)),--option builders '$(LOCAL_LOCAL_BUILDERS)',) | ||
| endef | ||
|
|
||
| define nix-vm-action | ||
| # $(1): VM prefix (local/prox) | ||
| # $(2): nix command (run/build) | ||
| # $(3): build output (vm/toplevel) | ||
| @if [ "x$(WHAT)" = "x" ]; then \ | ||
| echo "Usage: make $@ WHAT=type"; echo; echo "Available vms:"; \ | ||
| $(call VM_TYPES,$(1)); \ | ||
| exit 1; \ | ||
| fi | ||
|
|
||
| nix $(2) \ | ||
| $(call builder-opts) \ | ||
| .#nixosConfigurations.$(1)-$(WHAT)vm.config.system.build.$(3) $(ARGS) | ||
| endef | ||
|
|
||
| define nix-config-action | ||
| # $(1): build target attribute path | ||
| @if [ "x$(WHAT)" = "x" ]; then \ | ||
| echo "Usage: make $@ WHAT=host"; \ | ||
| echo "Usage: make $@ WHAT=host [REMOTE=false]"; \ | ||
| exit 1; \ | ||
| fi | ||
|
|
||
| nix build $(call builder-opts) $(1) $(ARGS) | ||
| endef | ||
|
|
||
| # Also the default target (just call `make`) | ||
| inputs-update: | ||
| nix flake update | ||
|
|
||
| ########### tests | ||
| bats: | ||
| nix build .#checks.$(shell nix eval --impure --raw --expr builtins.currentSystem).bats-tests --no-link | ||
|
|
||
| ########### local vms | ||
| local-vm: | ||
| $(call nix-vm-action,local,run,vm) | ||
|
|
||
| build-local-vm: | ||
| $(call nix-vm-action,local,build,vm) | ||
|
|
||
| ########### nixos vms | ||
| nixos-run-vm: | ||
| $(call nix-vm-action,prox,run,vm) | ||
|
|
||
| nixos-build-vm: | ||
| $(call nix-vm-action,prox,build,vm) | ||
|
|
||
| ########### nixos qemu | ||
| nixos-build-vm-qemu: | ||
| # Build standalone QEMU host package check output (no nixosConfigurations coupling). | ||
| $(eval QEMU_CHECK_SYSTEM := $(if $(filter Darwin,$(shell uname -s)),aarch64-darwin,x86_64-linux)) | ||
| nix build .#packages.$(QEMU_CHECK_SYSTEM).qemu-host-package $(ARGS) | ||
|
|
||
| ########### proxmox iso | ||
| nixos-build-prox-iso: | ||
| @if [ "x$(WHAT)" = "x" ]; then \ | ||
| echo "Usage: make $@ WHAT=type"; echo; echo "Available vms:"; \ | ||
| $(call VM_TYPES,prox); \ | ||
| define standalone-home-build-action | ||
| @if [ "x$(TARGET)" = "x" ]; then \ | ||
| echo "Usage: make $@ TARGET=profile [USERNAME=<name>] [REMOTE=false]"; \ | ||
| echo; \ | ||
| echo "Available $(1) home profiles:"; \ | ||
| $(call home-targets-for-system,$(2)); \ | ||
| exit 1; \ | ||
| fi | ||
| # Proxmox VMs are x86_64 in this setup; use prox-* VM configs. | ||
| nix build $(call builder-opts) .#nixosConfigurations.prox-$(WHAT)vm.config.virtualisation.proxmox.iso $(ARGS) | ||
|
|
||
| ########### nixos | ||
| nixos-build-target: | ||
| $(call nix-config-action,.#nixosConfigurations.$(WHAT).config.system.build.toplevel) | ||
|
|
||
| nixos-build: | ||
| nix build $(call builder-opts) .#nixosConfigurations.$(shell hostname).config.system.build.toplevel $(ARGS) | ||
|
|
||
| nixos-switch: | ||
| sudo nixos-rebuild switch --flake .#$(shell hostname) $(call builder-opts) $(ARGS) | ||
|
|
||
| disko-install: | ||
| @if [ "x$(WHAT)" = "x" -o "x$(DEV)" = "x" ]; then \ | ||
| echo "Usage: make $@ WHAT=host DEV=/dev/XXX"; \ | ||
| @if ! ($(call home-targets-for-system,$(2)) | grep -Fxq "$(TARGET)"); then \ | ||
| echo "Unknown $(1) home profile: $(TARGET)"; \ | ||
| echo; \ | ||
| echo "Available $(1) home profiles:"; \ | ||
| $(call home-targets-for-system,$(2)); \ | ||
| exit 1; \ | ||
| fi | ||
| sudo nix $(NIX_OPTS) run $(ARGS) \ | ||
| 'github:nix-community/disko/latest#disko-install' -- --flake .#$(WHAT) --disk main $(DEV) | ||
|
|
||
| ########### darwin | ||
| darwin-build: | ||
| nix build .#darwinConfigurations.$(shell hostname).config.system.build.toplevel $(ARGS) | ||
|
|
||
| darwin-build-target: | ||
| $(call nix-config-action,.#darwinConfigurations.$(WHAT).system) | ||
| nix build $(call builder-opts) .#homeConfigurations.$(USERNAME)@$(TARGET).activationPackage $(ARGS) | ||
| endef | ||
|
|
||
| darwin-switch: | ||
| sudo -H nix run nix-darwin -- switch --flake .#$(shell hostname) $(ARGS) | ||
| help: | ||
| @echo "Available targets:" | ||
| @echo " make nixos WHAT=<host> [REMOTE=false]" | ||
| @echo " make darwin WHAT=<host> [REMOTE=false]" | ||
| @echo " make linux-home TARGET=<profile> [USERNAME=<name>] [REMOTE=false]" | ||
| @echo " make darwin-home TARGET=<profile> [USERNAME=<name>] [REMOTE=false]" | ||
|
|
||
| switch: | ||
| @if [ "$(shell uname -s)" = "Darwin" ]; then \ | ||
| $(MAKE) darwin-switch; \ | ||
| elif [ "$(shell uname -s)" = "Linux" ]; then \ | ||
| $(MAKE) nixos-switch; \ | ||
| else \ | ||
| echo "Unsupported OS: $(shell uname -s)" >&2; \ | ||
| nixos: | ||
| @if [ "x$(WHAT)" = "x" ]; then \ | ||
| echo "Usage: make $@ WHAT=host [REMOTE=false]"; \ | ||
| exit 1; \ | ||
| fi | ||
| @resolved="$(WHAT)"; \ | ||
| known="$$(nix eval --json .#nixosConfigurations --apply builtins.attrNames | jq -r '.[]')"; \ | ||
| if ! printf '%s\n' "$$known" | grep -Fxq "$$resolved"; then \ | ||
| for candidate in "prox-$(WHAT)vm" "local-$(WHAT)vm"; do \ | ||
| if printf '%s\n' "$$known" | grep -Fxq "$$candidate"; then \ | ||
| resolved="$$candidate"; \ | ||
| break; \ | ||
| fi; \ | ||
| done; \ | ||
| fi; \ | ||
| if ! printf '%s\n' "$$known" | grep -Fxq "$$resolved"; then \ | ||
| echo "Unknown nixos host: $(WHAT)"; \ | ||
| echo; \ | ||
| echo "Available nixos hosts:"; \ | ||
| printf '%s\n' "$$known"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| nix build $(call builder-opts) ".#nixosConfigurations.$$resolved.config.system.build.toplevel" $(ARGS) | ||
|
|
||
| ########### standalone home-manager | ||
| home-build-nv: | ||
| nix run nixpkgs#home-manager -- build --flake .#${USERNAME}@nv $(ARGS) | ||
| darwin: | ||
| $(call nix-config-action,.#darwinConfigurations.$(WHAT).system) | ||
|
|
||
| home-switch-nv: | ||
| nix run nixpkgs#home-manager -- switch --flake .#${USERNAME}@nv $(ARGS) $(HM_ARGS) | ||
| linux-home: | ||
| $(call standalone-home-build-action,linux,x86_64-linux) | ||
|
|
||
| ############# raspberry pi | ||
| pi-image: | ||
| nix build .#nixosConfigurations.pi5.config.system.build.sdImage -o pi5.sd $(ARGS) | ||
| darwin-home: | ||
| $(call standalone-home-build-action,darwin,aarch64-darwin) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flake attribute path includes
@in the attribute name segment ($(USERNAME)@$(TARGET)), which is not a standard unquoted Nix identifier and is commonly represented as a quoted attribute (e.g.,"user@profile"innix flake show). To avoid selector parsing failures, quote/escape the$(USERNAME)@$(TARGET)segment when buildinghomeConfigurationsactivation packages.