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 nix-darwin #107

Closed
wants to merge 6 commits into from
Closed

Conversation

montchr
Copy link
Contributor

@montchr montchr commented Mar 14, 2022

This is an updated take on @cmhamill's work in #79 accommodating a lot of recent changes to the module in main. Props to @cmhamill for getting this most of the way there.

I'm tracking this branch in my own system flake and it's working well on macOS. I haven't tested on NixOS.

Fixes #60

@mitchty
Copy link

mitchty commented Mar 24, 2022

Just as a note from a random nix-darwin user, this all seems to work fine in testing with my own flake setup and thanks for getting it to work!

What I would add to the pr is these outputs to stay close to what home-manager does:

Unstaged changes (1)
modified   flake.nix
@@ -10,6 +10,9 @@
     agenix = system: nixpkgs.legacyPackages.${system}.callPackage ./pkgs/agenix.nix {};
   in {
 
+    darwinModules.age = import ./modules/age.nix;
+    darwinModule = self.darwinModules.age;
+
     nixosModules.age = import ./modules/age.nix;
     nixosModule = self.nixosModules.age;
 

If anyone else wants to poke around or play along at home, my nix flake config commit using this pr for restic backups is here:
mitchty/nix@ccaf2fa

Thanks again for getting this to work on macos!

@rtimush
Copy link

rtimush commented Mar 31, 2022

I can also confirm that it works on macos. It's a bit annoying though to remember to run darwin-rebuild on reboot. I guess a launchd service would be needed to overcome this.

montchr and others added 6 commits May 16, 2022 20:31
Signed-off-by: Chris Montgomery <chris@cdom.io>
Signed-off-by: Chris Montgomery <chris@cdom.io>
Signed-off-by: Chris Montgomery <chris@cdom.io>
the `keys` group does not exist by default on nix-darwin so the chown
command fails.
@alexghr
Copy link

alexghr commented Jul 25, 2022

Hey, to add to this, I have migrated my nix config to this fork of agenix and I can confirm that it works with both NixOS and nix-darwin. I've got the same config shared by two different systems 🙌

@rtimush
Copy link

rtimush commented Jul 26, 2022

As a follow-up to my previous comment, this is the branch that adds a launchd script activating secrets on boot. I haven't tested it too thoroughly, but it works for me.

@misuzu
Copy link

misuzu commented Sep 22, 2022

Any updates on this?

@ryantm
Copy link
Owner

ryantm commented Sep 22, 2022

This is looking simpler than I remembered! My main concern (beyond needing another round of merge conflict fixes) is having some kind of test for this in GitHub Actions. I'm worried people working only on NixOS will break it by accident.

@ryantm
Copy link
Owner

ryantm commented Sep 25, 2022

Maybe this can provide some inspiration for making a GitHub action for testing this? https://github.com/LnL7/nix-darwin/blob/master/.github/workflows/test.yml

@montchr
Copy link
Contributor Author

montchr commented Oct 15, 2022

Hey all, sorry for the delay in getting back to this. I did not have access to a Mac for a few months, as I only use it when provided as a work computer and I recently changed employers... After many delays, I now have a new aarch64-darwin laptop running with my existing nix-darwin/home-manager configs.

So with all that said, I'll fix the merge conflicts and look into adding some tests.

@montchr
Copy link
Contributor Author

montchr commented Oct 15, 2022

Well, quite a lot has changed here in the past few months! The conflicts unfortunately don't appear to have a straightforward resolution, as the underlying approaches changed on main since this branch was originally cut. So I'm thinking it may be best to start this work over on a new branch from the current state of main and compare with my additions on this branch.

@rtimush
Copy link

rtimush commented Oct 17, 2022

Speaking of the GitHub Action tests, I have actually added some to my branch (rtimush@bc6d151) before I realized that there are so many conflicts to resolve.

@JayRovacsek
Copy link

Keen to help if it's needed at all @montchr, super keen to have age behaving nicely under one flake input 😁

n8henrie added a commit to n8henrie/agenix that referenced this pull request Jan 29, 2023
Merges work by @montchr, @cmhamill, and @rtimush and rebases on main.

- fixes ryantm#60
- fixes ryantm#120
- closes ryantm#107
n8henrie added a commit to n8henrie/agenix that referenced this pull request Jan 29, 2023
Merges work by @montchr, @cmhamill, and @rtimush and rebases on main.

- fixes ryantm#60
- fixes ryantm#120
- closes ryantm#107
@n8henrie
Copy link
Collaborator

@ryantm @montchr @rtimush

It looks like this has stalled a bit -- I'm a relatively new nix user and brand new to agenix, looking for a solution for secrets on aarch64-darwin (nix-darwin, my primary machine), aarch64-linux (nixos), and nixos x86_64-linux (nixos), and it looks like agenix is probably the best solution.

Because the merge conflicts were a little too hairy for me to rebase, I tried to manually pluck them out as well as add in the launchd code and the GitHub Actions tests. I've put it together in #141 -- I hope you don't mind me piggybacking off your work.

The provided tests are passing but I don't think it's ready to merge, as I am still trying to figure out how all this works, and trying to make sure I remapped the dependencies properly for things like installNonRootSecrets that no longer exist. I would love if we can get a few extra eyes on this and hopefully get it merged!

@n8henrie
Copy link
Collaborator

It's a bit annoying though to remember to run darwin-rebuild on reboot. I guess a launchd service would be needed to overcome this.

@rtimush you might not need the launchd script -- do you have https://daiderd.com/nix-darwin/manual/index.html#opt-services.activate-system.enable enabled (default is true)?

@rtimush
Copy link

rtimush commented Jan 30, 2023

@n8henrie I do, it's just that nix-darwin only runs a couple of built-in scripts on activation, and any custom scripts we add will not be executed:
https://github.com/LnL7/nix-darwin/blob/3db1d870b04b13411f56ab1a50cd32b001f56433/modules/services/activate-system/default.nix#L39-L40

@ryantm ryantm closed this in 351e874 Jan 31, 2023
@ryantm ryantm closed this in #141 Jan 31, 2023
n8henrie added a commit to n8henrie/agenix that referenced this pull request Feb 12, 2023
Merges work by @montchr, @cmhamill, and @rtimush and rebases on main.

- fixes ryantm#60
- fixes ryantm#120
- closes ryantm#107
n8henrie added a commit to n8henrie/agenix that referenced this pull request May 5, 2023
Merges work by @montchr, @cmhamill, and @rtimush and rebases on main.

- fixes ryantm#60
- fixes ryantm#120
- closes ryantm#107
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 build failure: system.activationScripts.users.deps does not exist
9 participants