Darwin support#1
Merged
Merged
Conversation
Add support for deploying to macOS machines using nix-darwin.
Changes:
- Add SystemType enum (NixOS vs Darwin) in mod.rs
- Add evalDarwinNode in eval.nix using nix-darwin's darwinSystem
- Add darwinDefaults support for darwin-specific defaults
- Auto-detect darwin nodes from flake's darwinConfigurations
- Add deployment.systemType option for explicit system type
- Handle darwin-specific profile activation commands
- Fix macOS PATH issues for root user:
- Add DARWIN_NIX_BIN_PATH constant (/nix/var/nix/profiles/default/bin)
- Use remote-program parameter for ssh-ng:// nix-daemon
- Use full path for nix-env during profile activation
Usage in flake.nix:
colmena = {
meta.nix-darwin = inputs.darwin; # Required for darwin nodes
my-mac = {
deployment.systemType = "darwin";
deployment.targetHost = "my-mac.local";
# ... darwin configuration
};
};
Fix two issues causing CI failures in PR nix-community#319: 1. Code formatting: Run rustfmt to fix formatting in host module and profile.rs where multi-parameter function signatures weren't split across lines per Rust style guidelines. 2. Test compilation: Add missing system_type field to NodeConfig in node_filter.rs test code. The field was added as part of the darwin support feature but the test template wasn't updated accordingly.
realize_remote() called nix-store without a full path, which fails on macOS when connecting as root since /nix/var/nix/profiles/default/bin is not in root's PATH. Use DARWIN_NIX_BIN_PATH for nix-store on darwin, matching the existing pattern for nix-env in activate().
Remove the #[cfg(target_os = "linux")] gate that prevented apply-local from compiling on macOS. Replace the NixOS-only /etc/os-release check with a platform-aware guard: macOS is accepted directly (for nix-darwin), Linux still validates NixOS via os-release.
Add tests for: - systemType defaults to NixOS - systemType parses "darwin" correctly - darwin systemType is accepted as valid config
Addresses issues found while reviewing the nix-darwin support. No change to
existing NixOS deployments.
Correctness:
* systemType detection now reads `deployment.systemType` through the module
system, so function-form node modules (not just attrsets) are routed to the
darwin evaluator; the `meta.nix-darwin` assertion is now actually forced (it
was bound to an unreferenced `let` and never ran).
* apply-local ran `nix-store`/`nix-env` by bare name, which fails on macOS under
sudo's `secure_path`; resolve them to an absolute path when the local machine
is macOS. `DARWIN_NIX_BIN_PATH` is hoisted to a shared const.
* `readlink -e` (GNU-only) errors on BSD/macOS targets; use `readlink -f` with an
`[ -e … ]` guard that preserves the CURRENT_PROFILE fallback on both.
* Non-flake darwin copies used legacy `nix-copy-closure` (relies on the remote
PATH); force the ssh-ng `nix copy` path for darwin.
Cleanup:
* Remove dead `Profile::from_store_path_with_type` (can't be wired in — its local
`exists()` checks would break `buildOnTarget`) and the now-unused
`InvalidProfile`, `SystemType::is_nixos()`, and `RebootOptions::get_system_type()`.
* Add `remote_nix_bin`/`local_nix_bin` helpers; factor eval.nix's duplicated
`specialArgs`/nixpkgs selection into `mkSpecialArgs`/`npkgsFor`; drop redundant
Nix (`or {}`, `nullOr`, unused arg); tighten visibility; tidy darwin tests.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
nix-community#319