-
Notifications
You must be signed in to change notification settings - Fork 119
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 home-manager module #180
Conversation
I have yet to write a NixOS/Darwin test for this module, this should shake out any bug. EDIT: if anybody feels like doing that before I eventually get around to it, please do so! EDIT2: I added a home-manager section to the NixOS integration test. |
Added fixups to address this round of reviews. Kept the EDIT: since those commits are fixups, please EDIT2: a EDIT3: rebased to remove the fixups and re-word the test commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This is looking pretty good. Left a few comments. Also, lets get CI passing.
Force pushed to address the review comments, as well as:
|
Force pushed once again to fix a place where I had missed the |
hey, this is absolutely amazing, thank you for this contribution! I'm currently testing this branch on darwin in the following way.
and then trying to use the secret like
however when I try to switch I get the following error
Did I misundertand how to use this ? |
@happysalada unfortunately, since the This is a limitation of the default value for So try to do the following :
|
The other solution is to adapt the way you do things to accommodate the shell expansion. You could write something like (I'm assuming some things about
In this case you're letting the shell do the expansion to get the path to the decrypted file. |
Thanks a lot for your answer.
With the rest being
Having said that, trying to switch to my new system and going into the (getconf DARWIN_USER_TEMP_DIR) directory, I can't find any agenix directory there. |
I don't have a Darwin system to test unfortunately, this is based on If you find errors in the service definition, don't hesitate to suggest patches. |
All good, i was wondering if i had missed something. |
For the record here is what I tried so far But even with those, this still fails. I'm going to give this a bit more thought. |
@ryantm Would you know someone with darwin experience that could be interested to just give hypotheses as what would work, I would be happy to test any ideas ? |
Also my personal opinion (I'm on darwin and I've been waiting for this feature) is that this PR should not be delayed because of darwin support. We could just say it isn't working for darwin and someone with better knowledge will fix this later. (just my opinion considering the fact that this feature will make a few people happy). |
I'm on Darwin and should be able to investigate a little today. |
There certainly seems to be a lot of interest in a HM module; I'm a happy HM user but haven't quite figured out the use case people have in mind. At the end of the day, if this module was working as desired, are people just hoping to have a Just hoping to make sure I know how to test that it is working as people hope. Also, I'm surprised that so much had to be duplicated for the new module, I had expected there to be more opportunity for code reuse. |
Currently not building on Darwin, complains about If I override that (just for testing) with
or
depending on if I put I'm importing Am I supposed to put my age config somewhere other than Does anyone have this PR working on Linux and a config they'd like to share so I can compare? |
The point to me is that some of my secrets are not system-wide, and instead belong specifically to my user. I could use a NixOS/Darwin scoped Adding an home-manager module takes care of both:
I think that can come in a second wave.
Do you use a recent version of home-manager? This module has only been tested on unstable (read:
Just making sure, are you importing the module in your home-manager configuration? See how it is done in the test.
Same as above, feel free to look at the test. Don't hesitate to ask more questions, I'll try to answer as I can. If you want, we can also take this to Matrix. |
Just making sure I understand -- in concrete terms, what this would look like:
Does that sound like a fair summary?
I'd hope for it to come sooner rather than later, as this seems like it would roughly double the maintenance burden for the module until reconciled.
No, all of my systems track the most recent stable nixpkgs release (22.11 as of now). It looked like you were aiming for compatibility with "older" HM releases -- is that no longer the case?
Yes, I was following the example in the test, the issue is likely my HM version as you pointed out above. Let me see if I can get HM unstable working. |
Gah, not that easy: nix-community/home-manager#3928 |
I'm having trouble getting it to import to my flake. My
result:
Trying to get at it more directly results in infinite recursion:
Unfortunately using the test as an example doesn't help me sort this out, since it is passing the module as a path instead of a flake input. |
Yup, sounds right to me.
It is, but I meant older unstable releases. I don't think it is advisable to try and support older HM given that the next stable release is imminent. I think the best way to go about testing this would be if someone with Darwin build access could modify the test in a way that is similar to the NixOS one and debug its potential issues. As for your import problems, I'm not sure what is going wrong there unfortunately. |
I'm trying not to switch into it because then my whole environment gets screwed up! But yes. |
Hmmm, well the good news is I got the tests running and passing. The bad news is that some git wires got crossed when I went to rebase and squash, as I'm sure you all noticed. EDIT: That looks better. |
Im adding this on my list of todos to test tomorrow. |
Darwin module is passing. I added a standalone test using |
@n8henrie just tested and it's working beautifully! |
@n8henrie I kind of disagree with setting a default value for the Do we need to explicitly EDIT: I force pushed a history clean-up. EDIT2: And removed the default value for |
I figured it should be analogous to the existing module. Unreadable (or nonexistent) paths are skipped, so I don't see what is "unsafe" about this, and it sets a useful example for users to follow, and will be correct in many cases (uses the default filenames that ssh-keygen suggests, and the customary path). No strong feelings, but it doesn't seem like a problem to me.
Trying to test the "standalone" usage in a way that gives non-Darwin contributors like yourself the best representation of how it will work for Darwin users. Also a bit more work to test the launchd scripts (with no benefit I can see) otherwise. What problem is it presenting? |
As additional context, at least some of the paths added by the existing module don't exist in Darwin either, and don't seem to present a big problem. |
This is to update and fix the issues I saw in [1] and [2]. Using a service definition instead of an activation script should resolve the issue about the secrets disappearing after rebooting. Removed the `user` and `group` option as they do not make sense to me for a home-manager module, which should target a single user. They can always be added back if somebody comes screaming. This is somewhat modeled after sops-nix's own module [3]. [1]: #58 [2]: #109 [3]: https://github.com/Mic92/sops-nix/blob/master/modules/home-manager/sops.nix
@ryantm unless I missed something, I think this is ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good to me! Just one question.
It's clear a bunch of you are getting value out of this already. Great! I hope someone writes some docs in the Readme too! |
This broke my system flake using flake-utils-plus. Reverting to the commit before makes it work again.
|
darwinConfigurations.integration.system = self.checks."x86_64-darwin".integration; | ||
# Work-around for https://github.com/nix-community/home-manager/issues/3075 | ||
legacyPackages = nixpkgs.lib.genAttrs ["aarch64-darwin" "x86_64-darwin"] (system: { | ||
homeConfigurations.integration-darwin = home-manager.lib.homeManagerConfiguration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably because of this, usually legacyPackages
is followed by the system, so maybe this should be:
${system}.homeConfigurations.integration-darwin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
genAttrs
already prefixes it with the system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, right, so it should be because flake-utils-plus assume anything containing legacyPackages
will also contain x86-64-linux
inside. I'll create an issue there.
Just reporting what I've found to be happening after a bit of usage.
removing the faulty file produces another warning on the next update
trying an update once more succeeds, however the agent is not run. |
I'm curious if anyone has tried this on a machine where they have both system wide secrets and user level secrets. I can't make |
@happysalada I believe this is done in the tests IIRC? I haven't checked though. |
nixos tests only test for one user on the home-manager tests it seems |
Well yes, but that is testing systemd-wide secrets and user-level secrets on the same host. Anecdotally, it works on my machine ™️. |
This is to update and fix the issues I saw in 1 and 2.
Using a service definition instead of an activation script should resolve the issue about the secrets disappearing after rebooting.
Removed the
user
andgroup
option as they do not make sense to me for a home-manager module, which should target a single user. They can always be added back if somebody comes screaming.This is somewhat modeled after sops-nix's own module 3.