Skip to content
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

Add Support for Darwin/macOS Hosts #438

Merged
merged 34 commits into from
Apr 28, 2022
Merged

Add Support for Darwin/macOS Hosts #438

merged 34 commits into from
Apr 28, 2022

Conversation

montchr
Copy link
Collaborator

@montchr montchr commented Feb 28, 2022

Redo of https://github.com/divnix/digga-old/pull/111

Fixes #440 (used to be divnix/digga-old#16)

TODO

  • Checks succeed in each example flake
    • hmOnly
    • groupByConfig
    • devos
  • Fix Darwinia.tests = [ allProfiles ] in groupByConfig example
  • Update devos example for compatibility
  • Test on a real Apple computer to manage a real system configuration

Miscellaneous/Cleanup

Notes

  • I wanted to take as much "magic" as possible out of the new changes to fup-adapter.nix to make it easier to debug. So there may be some opportunity for introducing some abstractions in that file down the line, but for now I'd like to keep things less complex through repetition.

src/mkFlake/fup-adapter.nix Outdated Show resolved Hide resolved
@@ -75,14 +126,10 @@ let
)
config.channels;

hostDefaults = flake-utils-plus.lib.mergeAny (stripHost config.nixos.hostDefaults) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@montchr montchr marked this pull request as ready for review February 28, 2022 02:17
shell.nix Outdated Show resolved Hide resolved
@montchr
Copy link
Collaborator Author

montchr commented Feb 28, 2022

I'm now using digga.lib.mkFlake in all my system configurations, including three darwin systems, one of which is my primary machine. The switch from flake-utils-plus was actually really seamless! More deletions than additions in the diff, which I usually take as a good sign. montchr/dotfield@aa49be3

I'm not yet making use of the home-manager profiles because currently my "user" profiles are laced with a lot of system-scoped config, among other oddities. It's a work in progress.

So with that, I've checked off the "Test on a real Apple computer to manage a real system configuration" task. There's a few more to go but it feels like this is getting pretty close to done 😸

Next up, I'll be taking a look into the DevOS example and identifying what might need updating there.

@Pacman99
Copy link
Member

Wow thats amazing :) This is indeed looking close to being done!

You should add your flake to the "In the Wild" section in the README

bors bot added a commit that referenced this pull request Mar 5, 2022
441: fix: use gnu sed in shell tests for cross-platform compatibility r=montchr a=montchr

Darwin's use of BSD `sed` breaks here because BSD `sed` has a different
argument signature.

Spun off from #438 as suggested in #438 (comment)

Co-authored-by: Chris Montgomery <[email protected]>
bors bot added a commit that referenced this pull request Mar 5, 2022
441: fix: use gnu sed in shell tests for cross-platform compatibility r=montchr a=montchr

Darwin's use of BSD `sed` breaks here because BSD `sed` has a different
argument signature.

Spun off from #438 as suggested in #438 (comment)

Co-authored-by: Chris Montgomery <[email protected]>
@montchr montchr force-pushed the darwin-support branch 2 times, most recently from bcf1acf to dc86f3a Compare March 27, 2022 18:40
@montchr

This comment was marked as resolved.

bors bot added a commit that referenced this pull request Mar 29, 2022
@montchr

This comment was marked as outdated.

@bors

This comment was marked as outdated.

@montchr

This comment was marked as resolved.

@montchr

This comment was marked as resolved.

@bors

This comment was marked as resolved.

@montchr

This comment was marked as resolved.

@montchr
Copy link
Collaborator Author

montchr commented Apr 24, 2022

@bjw-s I've force-pushed some updates to this branch, which includes a fix for the issue you ran into while building the example host.

@montchr
Copy link
Collaborator Author

montchr commented Apr 24, 2022

@Pacman99 I think this is ready to merge, aside from rebuilding my nix-darwin system with the latest from this branch, in addition to addressing your suggestion:

One change I want to make before merging is to have all the templates refer to the digga release instead of main, so we can test main a bit more before people start using it.

What did you have in mind exactly? Since the examples have all been updated for compatibility with this branch, pinning them to the previous version would break, right? Also feel free to push commits to this branch or open a PR against it. I don't plan on making any more force-pushes at this point so let's consider the history stable.

@bjw-s
Copy link

bjw-s commented Apr 25, 2022

@bjw-s I've force-pushed some updates to this branch, which includes a fix for the issue you ran into while building the example host.

Thanks for the update! I can confirm that I am able to get nix build .#darwinConfigurations.delphi.system to work now (delphi is my hostname), however, when running ./result/sw/bin/darwin-rebuild switch --flake . I get this:

building the system configuration...
error: The option `_module.args.pkgs' is defined multiple times.

       Definition values:
       - In `/nix/store/2asxcb3djbp24yz7kg2j7lj5m0yqfh3b-source/eval-config.nix'
       - In `<unknown-file>'
(use '--show-trace' to show detailed location information)

My repo is here, should that provide any additional insight.

Edit:
Additionally, if I set the machine system to aarch64-darwin, the build will fail because nix-index cannot be compiled for it (it seems to be coming from the core.common profile).

I've found this gist (through this NixOS forum post) where the author is overriding the package arch, but unfortunately I have no idea how I would port this to the devos structure.

@grimsleydl
Copy link

If it helps narrow it down, I get the same error: The option `_module.args.pkgs' is defined multiple times error on an Intel Mac, both with the trivial default config as-is and with the hostname/username adjusted to reflect the actual host.

@kid
Copy link

kid commented Apr 27, 2022

that error seems to comes from gytis-ivaskevicius/flake-utils-plus#113

I've been facing the same issue for days while using flake-utils-plus directly with nix-darwin and only found the culprit today

@Pacman99
Copy link
Member

Yeah I'm good with merging this directly. I guess I was thinking of a way to encourage people to use the release tag for digga, instead of main. But its fine, the checks pass in this branch and the code all looks good so it should be stable.

the version in the 21.11 channel is old and doesn't include support for
`aarch64-darwin`. this version does.
@montchr
Copy link
Collaborator Author

montchr commented Apr 28, 2022

@bjw-s

Additionally, if I set the machine system to aarch64-darwin, the build will fail because nix-index cannot be compiled for it (it seems to be coming from the core.common profile).

Looks like this is fixed in nix-community/nix-index@0634333 which is not available in the version of nix-index pulled from nixos-21.11. The stable channel version is from 2018! Looks like nixos-unstable currently has a version that should work. I've added it to overrides.nix in e6b14d3 – does that fix the issue you ran into with that package?

I've found this gist (through this NixOS forum post) where the author is overriding the package arch, but unfortunately I have no idea how I would port this to the devos structure.

As an overlay, it could be added directly to channels.nixpkgs-darwin-stable.overlays:

overlays = [ ];

Or you could, for example, create a file in the overlays/ directory, which would be imported automatically by the existing importOverlays invocation in channels.nixpkgs-darwin-stable.imports.

I don't have a sense of how common a scenario like the one you ran into with nix-index might be – at this point, the M1 Macs have been out for a while so I'm guessing a lot of folks have already updated their packages? nix-index seems like it might be an outlier since I take it you didn't run into that error with any other packages included by default in examples/devos/, and also as mentioned above, the version in the stable channel is very old. Perhaps we could add an overlay like that as a future enchantment later, but I'm not even able to test it at the moment 🙂

@montchr
Copy link
Collaborator Author

montchr commented Apr 28, 2022

If it helps narrow it down, I get the same error: The option `_module.args.pkgs' is defined multiple times error on an Intel Mac, both with the trivial default config as-is and with the hostname/username adjusted to reflect the actual host.

@bjw-s @grimsleydl @kid Assuming that the issue is coming from gytis-ivaskevicius/flake-utils-plus#113 do either of these fixes help?

@montchr montchr merged commit 6a31b63 into main Apr 28, 2022
@montchr montchr deleted the darwin-support branch April 28, 2022 00:24
@montchr montchr restored the darwin-support branch April 28, 2022 00:24
@Pacman99
Copy link
Member

Thank you for the amazing work @montchr!! Glad to see Darwin support become a reality.

@montchr
Copy link
Collaborator Author

montchr commented Apr 28, 2022

Thanks for the support! It's been a journey.

@Pacman99 Pacman99 deleted the darwin-support branch May 4, 2022 20:15
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.

nix-darwin support
6 participants