Skip to content

Initial Darwin support (except agent)#140

Open
winterqt wants to merge 7 commits into
manic-systems:mainfrom
winterqt:push-mkxmprvtlrvw
Open

Initial Darwin support (except agent)#140
winterqt wants to merge 7 commits into
manic-systems:mainfrom
winterqt:push-mkxmprvtlrvw

Conversation

@winterqt

@winterqt winterqt commented Jul 4, 2026

Copy link
Copy Markdown

Please review commit-by-commit, I think everything is split up decently well enough.

I haven't run the container tests as nix flake check is bad and doesn't let you skip incompatible derivations with --keep-going.

@winterqt winterqt changed the title Initial Darwin support for development and administration Initial Darwin support (except agent) Jul 4, 2026
let bavail = stat.blocks_available().saturating_mul(block_size);
let bfree = stat.blocks_free().saturating_mul(block_size);
let btotal = stat.blocks().saturating_mul(block_size);
let bavail = stat.blocks_available().saturating_mul(block_size.try_into().map_err(|e| CiError::Io(std::io::Error::other(e)))?);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I’m going to hope these get elided away on Linux (where block_size is the same type as stat.blocks_available()).

Comment thread flake.nix Outdated
vmTests
filteredNixosTests
// {
nixos-module-agent-package = nixosModuleAgentPackage;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Why is there both this and the completely different circus-agent definition above?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This was introduced by @amaanq, iirc for the purpose of easing builds for exotic arches earlier.

@NotAShelf
NotAShelf requested a review from amaanq July 4, 2026 04:55
Comment thread nix/common/base.nix
inherit (lib.modules) mkDefault mkForce;
circus-packages = self.packages.${pkgs.stdenv.hostPlatform.system};
in {
documentation.enable = false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was under the impression that this is done in runNixOSTest? Haven't traced too carefully, but looks like nodes.nix in nixos/lib/testing already sets documentation.info.enable = lib.mkDefault false;

@winterqt winterqt Jul 4, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I don’t think those two options are equivalent — I saw Python docs being built for the one test that had it in its environment.systemPackages.

I can look into this further later.

@amaanq amaanq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

left some comments, sorry for taking a while to get to this

Comment on lines +164 to +166
let bavail = stat.blocks_available().saturating_mul(block_size.try_into().map_err(|e| CiError::Io(std::io::Error::other(e)))?);
let bfree = stat.blocks_free().saturating_mul(block_size.try_into().map_err(|e| CiError::Io(std::io::Error::other(e)))?);
let btotal = stat.blocks().saturating_mul(block_size.try_into().map_err(|e| CiError::Io(std::io::Error::other(e)))?);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fsblkcnt_t is c_uint (aka u32) on Darwin, so we should probably widen this to u64 before multiplying because it will saturate at 4GB. maybe a helper widen fn like so:

fn widen(n: impl Into<u64>) -> u64 {
  n.into()
}

can be used to wrap the statvfs values before multiplying.

Comment thread flake.nix
postgresql_18

# circus-evaluator builds evix's Nix C bindings.
# nixVersions.nix_2_34.dev

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we uncomment this? nix_2_34.dev evaluates fine on darwin

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nix 2.34.8 was tagged earlier, I'll be able to make a 0.2348.0 release for the Nix bindings, which'll include better Darwin support per NotAShelf/nix-bindings#73 is not yet updated, but we can handle it once I tag evix 2.0 and update in #133

Comment thread nix/demo-vm.nix
Comment on lines 11 to 12
adminPasswordFile = pkgs.writeText "admin-password" "AdminPassword123!";
demoPasswordFile = pkgs.writeText "demo-password" "DemoPassword123!";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we update this to also use builtins.toFile?

Comment thread flake.nix
Comment on lines 115 to +116
// lib.optionalAttrs (muslCrossAttr ? ${system}) {
circus-agent = callCratePackage ./nix/packages/circus-agent.nix "circus-agent" "--package circus-agent";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

with this, we lose the agent on systems like powerpc64le and s390x, gating on it being in the muslCrossAttr is not the right choice here. i think we can just gate circus-agent on stdenv.hostPlatform.isLinux no? and keep the muslCrossAttr check just for circus-agent-static.

Comment thread nix/demo-vm.nix
Comment on lines 32 to 34
virtualisation = {
memorySize = mkForce 4096;
cores = mkForce 4;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we should set virtualisation.host.pkgs to the outer package set, because NixOS guest evaluation selects Linux packages on Darwin. you could declare an outer hostPkgs = pkgs and then declare host.pkgs = hostPkgs

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.

3 participants