-
-
Notifications
You must be signed in to change notification settings - Fork 492
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
Tracking issue for switching to system-wide activation #96
Comments
When you get a minute, can you briefly describe the plan for ~/Applications and |
I just listed everything here that runs as the login user. For applications it's easy, that can be moved to /Applications. As for defaults, I'm not sure if that works when running as root. |
It would be convenient for me if this distinction went away, especially if #664 lands. I assume from the mention of In general it kind of seems like nix-darwin doesn't know whether it wants to be single- or multi-user... If per-user settings were scoped appropriately and could be done for multiple accounts then this wouldn't be a consideration. But I bet macOS might make that complicated in other ways. |
I'd be interested in taking a look at this if the question around user stuff was addressed. Should we just have configurations specify what their primary username is so the activation script can |
To me it me, as a user of both nix-darwin and home-manager, it makes sense to let nix-darwin handle system-level things and leave user-specific things to home-manager. I personally find it really confusing, for instance, that nix-darwin supports setting a bunch of defaults under home-manager already supports setting arbitrary user defaults for the user, setting up launch daemons and launch agents, and installing applications under ~/Applications. So nix-darwin can likely get away with dropping those kinds of things. The big thing left is Homebrew, which can perhaps be solved with a setting for which user it should run as rather than assuming it's the one running darwin-rebuild. |
I did forget that there are also several modules in nix-darwin around setting up launch agents, things like yabai or skhd. If nix-darwin removes support for launch agents, these modules would also need to move to home-manager. |
+100 to @mjm. When I wrote my previous comments I didn't realize that Home Manager supports setting As far as agents go, moving those services to HM is one option, but I believe we could also just install system-level agents, which will run as the current user for, I think, all desktop users. This leaves only Homebrew, which can grow a We could then drop hacks like I would be very happy if we agreed on this approach and am eager to implement it. |
I think that's also kind of the summary I described here. This was sort of a brainump asking whether by dropping a few things nix-darwin could just not have any user activation at all.
There are still launch agents available which run for the currently logged in user, nix-darwin agents would just always be global for all users in that case. Alternatively the current per-user agents could stay but with the actual target user specified (similar to eg. per-user ssh keys). This last one might make |
Thanks, it's good to know we're on the same page here; I agree that we shouldn't solve this by essentially staying single-user and just adding an option for that user. I'm not completely opposed to having user-specific options like defaults and agents under I have a local implementation of this that rips out user activation entirely and ensures that the activation script doesn't depend on |
Thanks @emilazy for pointing me at this issue--I created a POC #763 for this yesterday without knowing about it, + a follow-up patch to use I was also slightly confused by the activation vs user-activation split, although I ended up rationalizing it as "some tools don't like to be run as root, e.g. homebrew":
Where other parts of the activation script should obviously definitely be run as root. Then there are some settings which are "global" or "system-wide" (e.g. networking), and some settings which are "user-local", e.g. the login shell or the dock position. And of those local settings, some must be run as root ( Non-exhaustive:
You are suggesting, if I read it right, for nix-darwin to entirely stop supporting some of its current duties. I agree that stuff like menu bar and dock position don't feel very nix-darwiny, and could be spun off as home-manager modules. But others do feel to me like they would belong here, in particular anything which has a NixOS parallel, e.g. If I understand it right, this current issue is about a few things simultaneously:
These all seem orthogonal, so concretely I propose addressing them separately. I don't think the current activation vs user-activation split is necessarily a huge deal (homebrew does the same and it seems to work for people). Moving settings to home-manager where they belong is a good idea regardless of what else is decided. Supporting necessary per-user settings is also orthogonal, and a good feature to have which will end up looking the same no matter how the other two are completed (a script into which the root activation sudos once for every user). What do you think? |
For Homebrew I added a Running the two stages as separate scripts also brings its own host of problems: system-wide and per-user stuff cannot be interleaved, user activation runs before system activation(!), running only one of the scripts manually to recover from a broken I agree that supporting setting user shells seems like a good idea, if it can be made robust, and wouldn't consider that to be straying too much from "managing the system, not the users"; it's mostly stuff that touches |
Another consideration here is that anything in |
I'm totally on board with unifying the activation scripts, these are all good points. I think I come at it more from a "there are separate issues at play, so they can be solved separately", but overall: yes, agreed. |
What can I do to help make sure some progress is made on this issue? I'm wary that the scope of the original ticket makes this hard to pass, and if that's the case I would advocate for breaking it up into smaller pieces and taking wins where we can get them. If there is a big master PR which fixes everything and is ready to merge, I'm happy with that too, of course. What's the status, what is left to do, and if the issue has grown too large is Divide and Conquer an option? |
So, my branch works and would be easy to update; it's really more removing code than anything else. The tricky part is handling the options that implicitly assume the current user, which are just ripped out wholesale in my branch: for instance, do we want to keep the user defaults code around (duplicating Home Manager functionality) and move them under I'm currently busy in the middle of a move right now, but I'd like to get back to this and other things in a couple weeks time. |
@LnL7 what are your thoughts? This currently feels like a textbook "perfect is the enemy of good"--can we merge something small, something that just allows us to e.g. mirror the user options across all users? @emilazy do you maybe have a minimal set of changes that could be forked off of your branch without pulling in the more substantial stuff, just so we can get some small wins while waiting for the bigger works? |
Apologies if this isn't the correct place to post this. My issue is tangentially related but I can remove if it is an issue. On my personal machine, only used by myself, I keep an This has been fine, until I started working with Is there a known work-around for this use case? Any help is greatly appreciated. |
That’s actually a great motivating case for this that I hadn’t considered before! After I send out the PR for the first stage of the plan (should finally be due this week), you’ll be able to set In the long run we’d like to be able to manage multiple users at once, but I think this should work for your immediate use case. In the meantime, you could consider using Home Manager, which has per‐user defaults functionality and can integrate with nix-darwin; we may move some functionality out of nix-darwin entirely and into Home Manager over time. |
@emilazy Absolute legend! Thank you for your hard work. Did not realize how close this was to being resolved. I will keep an eye on this. Since I cooked up a quick workaround I will document the general idea here. Nobody should copy and paste this blindly. It might very possibly be a Very Bad Idea (tm). I only kept the core idea to keep things terse and to not takeover the thread. This script should be owned by whichever user has
|
launchd.user.agents
tousers.users.<user>.launchAgents
users.users.<user>.defaults
The text was updated successfully, but these errors were encountered: