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

Draft: nix-darwin module #558

Closed
wants to merge 5 commits into from
Closed

Draft: nix-darwin module #558

wants to merge 5 commits into from

Conversation

j-baker
Copy link

@j-baker j-baker commented May 5, 2024

Fixes #409.

The home manager module covers most cases on Darwin, but does not cover headless devices as agents don't run unless a user session exists. This is a (draft) small copy-paste job of the home-manager integration which is enough to get nix-darwin working.

I'd like feedback on:

  • What tests would be useful/how this should be tested?
  • What sort of code sharing should occur between this and normal Nix?
  • Any documentation that'd be nice?

and honestly anything else.

This is somewhat but not entirely duplicative with the home manager
support. The difference is primarily for MacOS servers, for which there
is no LaunchAgent support (as launch agents are tied to user sessions).

This PR adds a nix-darwin module (configured similarly to the home
manager module) which is suitable for e.g. other launchd daemons.
@j-baker j-baker marked this pull request as draft May 5, 2024 09:19
description = ''
Path where secrets are symlinked to.
If the default is kept no other symlink is created.
`%r` is replaced by $XDG_RUNTIME_DIR on linux or `getconf
Copy link
Owner

Choose a reason for hiding this comment

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

This does not exist on macos, right?


defaultSecretsMountPoint = lib.mkOption {
type = lib.types.str;
default = "%r/secrets.d";
Copy link
Owner

Choose a reason for hiding this comment

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

Same question here.

options.sops = {
logFile = lib.mkOption {
type = lib.types.path;
default = "/var/log/sops.log";
Copy link
Owner

Choose a reason for hiding this comment

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

Do applications need to log themselves to files?

@Mic92
Copy link
Owner

Mic92 commented May 9, 2024

I'd like feedback on:

* What tests would be useful/how this should be tested?

Automatic tests in the CI would be great, but I don't know how this is done on macOS. I do have a macos builder in buildbot, if that helps.

* What sort of code sharing should occur between this and normal Nix?

I don't think we need to butcher the nixos options to share them between platforms.
It's fine to just share the go code.

* Any documentation that'd be nice?

Yes, would be. I assume it's not that different from other platforms?

and honestly anything else.

'';
};

mode = lib.mkOption {
Copy link
Owner

Choose a reason for hiding this comment

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

We also want owner/group here.

Copy link

Choose a reason for hiding this comment

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

Is there more than these two options (juspay@8580716) that need to be done here in this PR? Because, the installed secrets are still root owned:

-sh-3.2# ls -l /var/root/sops-nix/secrets/
total 16
-r--------  1 root  wheel  13 Jun 19 02:36 example_key
-r--------  1 root  wheel   5 Jun 19 02:36 hello

@srid
Copy link

srid commented Jun 19, 2024

I've tried out this PR. It sort of works (except for setting right permissions, per my comment above), but when activation fails there's no indication on the nix-darwin run side. You have to catch those silently ignored errors by tailing /var/log/sops.log.

@Mic92
Copy link
Owner

Mic92 commented Jun 30, 2024

I can now also finally properly review macOS: https://github.com/Mic92/dotfiles/tree/main/darwin

@niklasravnsborg
Copy link

Hi, I'm really looking forward using the nix-darwin module, because I want to use some sensitive information in my darwin configuration and assume without this module there is no way to do that currently.

I would be very happy if you could share something on the current status of this :)

@zimbatm
Copy link
Contributor

zimbatm commented Nov 15, 2024

Talked with @Mic92, on thing that could help is to add darwin-test

@Mic92
Copy link
Owner

Mic92 commented Nov 15, 2024

Not needed for merging but nice for - maintenance. Also this is the up-to-date branch: #647

@Mic92
Copy link
Owner

Mic92 commented Nov 17, 2024

This is now merged.

@Mic92 Mic92 closed this Nov 17, 2024
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.

darwin-nix support
6 participants