Skip to content

feat: detect platform in make#335

Merged
himkt merged 2 commits intomainfrom
cleanup-recipe
Feb 18, 2026
Merged

feat: detect platform in make#335
himkt merged 2 commits intomainfrom
cleanup-recipe

Conversation

@himkt
Copy link
Owner

@himkt himkt commented Feb 18, 2026

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Makefile to detect the platform automatically and provide unified target names instead of platform-specific ones. The change aims to simplify the developer experience by using the same command names (e.g., make build, make switch) on both macOS and NixOS systems.

Changes:

  • Introduced platform detection using uname -s to differentiate between Darwin (macOS) and other systems (NixOS)
  • Replaced platform-specific targets (macos-build, nixos-build, etc.) with unified targets (build, switch, etc.)
  • Made Nix build and switch commands platform-aware through conditional variable assignment

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +23 to +24
clean:
sudo nix-env --delete-generations +7 --profile /nix/var/nix/profiles/system
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clean target now uses a unified profile path that is incorrect for macOS. On macOS (Darwin), the profile path should be /nix/var/nix/profiles/system-profiles/darwin as in the original macos-clean target, not /nix/var/nix/profiles/system. This will cause the clean operation to fail or target the wrong profile on macOS systems. Consider adding platform-specific logic similar to the build and switch commands.

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +43
brew-install:
$(PWD)/brew/bin/setup.sh

nixos-switch:
sudo nixos-rebuild switch --flake .#nixos
brew:
brew bundle --verbose --file=$(PWD)/brew/config.d/base/Brewfile

nixos-update:
nix flake update
brew-gui:
brew bundle --verbose --file=$(PWD)/brew/config.d/gui/Brewfile

nixos-clean:
sudo nix-env --delete-generations +7 --profile /nix/var/nix/profiles/system
brew-optional:
brew bundle --verbose --file=$(PWD)/brew/config.d/optional/Brewfile

nixos-gc:
sudo nix-collect-garbage -d
brew-himkt:
brew bundle --verbose --file=$(PWD)/brew/config.d/himkt/Brewfile
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The brew targets are labeled as "macOS only" but lack platform guards. When these targets are run on non-macOS systems, they will fail because the brew command and Brewfiles are not available. Consider adding conditional checks or making these targets conditional based on the detected platform, similar to how NIX_BUILD_CMD and NIX_SWITCH_CMD are set conditionally.

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +15
build:
$(NIX_BUILD_CMD)
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new unified build target breaks existing CI workflows. The GitHub Actions workflows at .github/workflows/macos.yml (line 14) and .github/workflows/nixos.yml (line 14) still reference the old target names macos-build and nixos-build respectively. These files need to be updated to use the new build target, otherwise the CI will fail after this change is merged.

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +15
build:
$(NIX_BUILD_CMD)
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README.md documentation is now outdated. It still documents the old target names (macos-build, macos-switch, macos-brew, macos-brew-gui, nixos-build, nixos-switch, etc.) in the Setup section (lines 33-47) and Makefile Targets table (lines 51-67). These need to be updated to reflect the new platform-aware target names (build, switch, brew, brew-gui, etc.) to avoid user confusion.

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +8
NIX_BUILD_CMD := nix build .\#darwinConfigurations.macos.system
NIX_SWITCH_CMD := sudo darwin-rebuild switch --flake .\#macos
else
NIX_BUILD_CMD := nix build .\#nixosConfigurations.nixos.config.system.build.toplevel
NIX_SWITCH_CMD := sudo nixos-rebuild switch --flake .\#nixos
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hash character in the flake references is escaped with a backslash (e.g., .\#darwinConfigurations.macos.system), but the original working Makefile used unescaped hashes (.#darwinConfigurations.macos.system). In Makefile recipe lines (commands after tabs), the hash character is typically passed literally to the shell and does not start a comment, so the backslash escaping may be unnecessary and could potentially cause the command to fail. Verify that these commands work correctly with the escaped syntax, or revert to the unescaped syntax that was previously working.

Copilot uses AI. Check for mistakes.
@himkt himkt merged commit ea1f96f into main Feb 18, 2026
2 checks passed
@himkt himkt deleted the cleanup-recipe branch February 18, 2026 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments