Skip to content

fix: darwin buildOnTarget as root + enable apply-local on macOS#1

Closed
sini wants to merge 5 commits into
zw3rk:darwin-supportfrom
sini:pr/darwin-enhancements
Closed

fix: darwin buildOnTarget as root + enable apply-local on macOS#1
sini wants to merge 5 commits into
zw3rk:darwin-supportfrom
sini:pr/darwin-enhancements

Conversation

@sini

@sini sini commented May 25, 2026

Copy link
Copy Markdown

Summary

  • fix: use full nix-store path on darwin for buildOnTargetrealize_remote() called nix-store without a full path, failing on macOS when connecting as root since /nix/var/nix/profiles/default/bin is not in root's PATH. Uses DARWIN_NIX_BIN_PATH, matching the existing pattern for nix-env in activate().

  • feat: enable apply-local on macOS for nix-darwin — Removes the #[cfg(target_os = "linux")] gate that prevented apply-local from compiling on macOS. Replaces 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.

  • test: add coverage for darwin system type — Tests that systemType defaults to NixOS, parses "darwin" correctly, and is accepted as valid config.

Test plan

  • cargo test — 38 passed, 0 failed
  • nix build — builds successfully
  • Manual: colmena apply --on <darwin-host> with buildOnTarget = true and targetUser = "root"
  • Manual: colmena apply-local on a macOS machine with nix-darwin

angerman and others added 5 commits December 9, 2025 17:39
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
@sini

sini commented May 25, 2026

Copy link
Copy Markdown
Author

Hope you don't mind the contribution -- hoping this could get the colmena PR pushed along. :)

@angerman

Copy link
Copy Markdown

Hope you don't mind the contribution -- hoping this could get the colmena PR pushed along. :)

Absolutely not. I just didn't expect anyone to open a PR against this repo 🤣

nix-community#319 should include this now.

@angerman angerman closed this Jun 30, 2026
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.

2 participants