-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
nixos/onedrive: init #77734
nixos/onedrive: init #77734
Conversation
Hey @SRGOM. First of all, I'm not using onedrive, I just thought it's cool and that we should package it and I don't mind maintaining it much. But, upstream provides a systemd service. Do we package it? If we do, I don't think we should add our own version of it. If we don't package it, let's start by adding it to our package and perhaps make sure everything here: https://github.com/abraunegg/onedrive/tree/master/contrib Will get packaged as well. BTW it needs a small version update (see) it could be nice to get on the way.. |
@doronbehar thanks for responding. I have to confess :
That said, this code allows multiple oned instances for the same user. So at least one of the two services is different. Also, sorry I don't know what you mean by "adding it to our package". Don't modules live in diff hierarchy? (First time module writer ) I may not be able to spend effort to package other things, sorry. I believe a service is critical hence adding. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review-may-2019/3032/107 |
@doronbehar I did a |
@doronbehar I have addressed your comment and incorporated the service from onedrive upstream. Any other comments you'd like to add? |
@jonringer Since you too reviewed (and approved) #73360, may I further abuse your hospitality by requesting you to review this too? I still have to add documentation but the service part is done (as best as I can- please see the Ideal Todo part in my original post) |
you may, however, I'm still largely ignorant of nixos module best practices cc @infinisil |
@SRGOM I'm pretty sure @doronbehar meant you should use Also please keep to a consistent 2 spaces per level of indentation. |
When I said "package files from upstream", I meant that we need to make sure our In general, my comment comes from the question: What does this service / module does that the package doesn't provide by it self? And if the package should provide something, I think it'd be better to leave it that way. |
Alright, I'm going to address your comments as soon as I can (I'll probably need to read up quite a bit). But quickly, @doronbehar- my code allows running the service for an unlimited number of onedrive accounts for the same user with very little effort. Just list all the config dirs in ~/.config/onedrive-launcer and onedrive services will be instantiated for all those accounts. |
Actually I just re-read both your comments and yeah, I happen to (fortunately) understand nix packaging. I understand (now) how services in Nix are handled, just like bins are moved to $out/bin, services are moved to $out/....servies path.... Fine. With that understanding I want to say that the module I am submitting is very different and cannot make use of anything but adapted code from upstream. In my code- I have two things- one is an instantiable "onedrive@" service, which instantiates on config directories. The other is a launcher service which launches each of these instantiated services. The upstream code cannot be reused for that purpose without adapting. @aanderse I will fix spacing. |
I am also adding |
@SRGOM Looks great! |
Just out of curiosity... is this module something which might be better suited for |
I'm not sure what defines the boundaries and shared regions but in this particular case, if multiple users use a single OneDrive account, no configuration on their part besides the initial oauth is required once the sysadmin enables the service. That's a strong argument in favor of having a "global " service. That said, I'm always curious why somebody would use home manager at all? Having packages on a multi user system, sure- but it's a bad idea as far as config management is concerned - you cannot edit a file and let things apply on the fly (unlike the dotfile + stow approach). And you don't have a "stateless" config directory anyway- things are very stateful. Also when I open my ~/.ssh/config in vim, ProxyCommand is colored but PoxyCommand isn't. Not something home manager can give yopu. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Great question. Based on extensive testing and fixing issues / bugs from the original client, many distro's do not set correctly the In the code itself (config.d) there is the following:
This allows to check if If NixOS is reliably setting Other than that, the documentation changes / additions look fine to me. |
@abraunegg Thank you, clearly you've spent time worrying about stability. That
Interesting. |
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.
Not sure about this module, having the user write a config file to their home directory to configure something is not really in the spirit of NixOS at all (which is about declarative system config, not stateful user services). Perhaps home-manager is a better place for such a module, since it's focused on single users, allowing you to control home directory paths too.
You mention "not sure". Is that a final in which case I will close because I have no motivation to write a home manager module. As I noted above, and I'm not being snarky,
Also when I open my ~/.ssh/config in vim, This isn't the occasion to talk about Home Manager but suggesting an unofficial solution here seems a bit off when it fits well in the official solution just fine. Creating a config file in the home directory is like creating a vimrc or emacs Thank you for spending the time to look and for maintaining NixOS. (I hope I didn't sound ungrateful with my above comments, it's just that I feel a bit strongly about home manager I feel that HM is the nail to the (amazing) Nix hammer. I am 100% against entitlement, this is your repo and you guys are free to do whatever and I am free to fork NixOS (and get nowhere). But I think most of what I'm doing is inline with other projects. |
What if there was a compromise that meant the system admin could declare which users OneDrive is enabled for? {
services.onedrive.package = pkgs.onedrive;
services.onedrive.users."ian" = {
enable = true;
configDirs = [ ".config/onedrive" ".config/office365" ];
};
} This means the The module would only set up the services where declared users have a config file in one of the prescribed config directories.
|
A general problem with NixOS modules that control user-level things is that users can't control it unless they're a super-user: If you want to enable such a service, you need to be able to call In contrast, home-manager allows you to do that, because it runs on a per-user basis, with its config file in {
home-manager.users.alice = {
services.onedrive.enable = true;
};
} home-manager is nowadays pretty much the standard way to configure user-level things. Yes it's a third-party tool, but I think we should embrace this, because nixpkgs is really quite big already. Once NixOS/rfcs#42 is finished it will also allow easier usage of third-party Nix code and libraries. |
Given I have absolutely no knowledge of NixOS, please can you keep this in mind when reading below & making your decision as how best to run this under your OS / distribution:
See above - unless you enable the right user service, then it will cause issues when downloading files as a non super / system admin user. |
@abraunegg said...
Yup, this module for NixOS only creates user level systemd units, and only starts the service for the user if they have a recognised config dir for onedrive. |
Thank you, I appreciate the good faith discussion. I can see how home manager shines here. I want to add one thing though (I hope I'm not answering a non-question)- Unlike other distros, NixOS allows users to install their own packages. So I can see how it might be a concern that admins are required for a service. But that's true for a lot of other services, (redshift comes to mind). So this service isn't much different from others really. Also, just to give an idea of how this interacts with config files. Assume disabled service. Nothing happens. Assume enabled service. If I as a user have .config/OneDrive, then I likely want the service to run anyway. But the module gives you an option anyway to not run the individual service if you do not wish. Basically once the admin enables the service, only the oneshot onederivelauncher service starts mandatorily . Everything else is trivially manageable by the user. In fact I'd argue that redshift (and probably others) don't belong in nix because there is no way to configure different color temperature preferred by different people. I like 1800k candle flame, most are used to 2700k tungsten filament bulb. |
@ianmjones Sorry I missed your previous comment- I believe the concern infinisil's concern here is the lack of flexibility (please correct me if not). As such my previ0us comment tries to address that. Was your concern in response to that. If not, does my previous comment seem to address what your motivation might have been? Happy to answer more |
@SRGOM No worries, my previous comment was indeed trying to address @infinisil's original comment about not liking the requirement of users adding config files to their home dir that are specific to this module (that's how I read their comment). As you know, I too raised concerns about the It also doesn't feel right to me that we're currently needing to install a third party channel (home-manager) in order to get per user declarative config, hence my suggested compromise. However, I do like the format that @infinisil's follow-up home-manager example used for enabling the onedrive service on a per user basis, so I'm going to give home-manager a try. It is a shame though that we can't have a OneDrive service module that enables users to optionally use it simply by having the standard config in place, and doing the one-time manual authentication to confirm access. |
I actually think that allowing the user the flexibility of turning on and off sync without a system rebuild is a positive. I believed that your concern arose from it not being a package defined standard but something my module created ( I share that but I don't think it's a deal breaker). |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/how-to-setup-user-ssh-keys/5745/4 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Is there a status on this PR? Upstream OneDrive for Linux client author seems to believe it's been rejected? |
Definitely not rejected but there are a few things that need to be addressed. |
I am not an expert in linux systemd related aspects. That combined with my computer's internet issues which require me to manually start internet after every login make it hard for me to understand if the service has started at login. My original code did work fine for me (I had good internet then) That said, I want to thank @peterhoeg for the review and also clarify one bit about how the launcher works- You can definitely start and stop a single service (I do it all the time to save bandwidth). What the launcher adds is the ability to start all your onedrive instances in one go. So the oneDriveLauncher is a good thing. I am not sure when I will get time again to complete this PR. If someone else wants to go ahead with this, please feel free . |
Updated the documentation (abraunegg/onedrive@ed1d13b) to reflect that this is not rejected, but needs work |
@peterhoeg The way you made suggestions makes it sound like you understand systemd well, could you kindaly suggest a way to quickly test start-up of user services- I wonder if |
I'm sorry, I don't understand what you are asking. What exactly are you trying to do?
|
@peterhoeg hi, let me know if you need further changes here. I've spent some time today and I can spend more time fixing this since I'm (again) familiar with the code. The service starts perfectly for me upon reboot and the subsequent login. |
}; | ||
}; | ||
|
||
systemd.user.services.onedriveLauncher = { |
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.
Minor nitpick - following our naming convention it would be onedrive-launcher
.
|
||
systemd.user.services.onedriveLauncher = { | ||
wantedBy = [ "default.target" ]; | ||
after = [ "network-online.target" ]; |
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.
network-online.target
is not available to user services.
@peterhoeg I have continued this work in #91765 due to GitHub login issues. |
Documentation
#77734 (comment)
Ideal Todo but I fail:
Use full path instead of just a dir name.
Currently this module allows using only a directory name inside ~/.config. Should actually allow full directory paths. I believe that using paths as instance name is not allowed by systemd.
Use
$XDG_CONFIG_HOME
instead of.config
. The author of the main package- onedrive, uses .config and not$XDG_CONFIG_HOME
inhttps://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md
. I would prefer using XDG but would go with .config because that's what the author seemingly uses, not sure what he's doing in code** User abraunegg comments that XDG_CONFIG_HOME isn't a safe value to use anyway.
Todo that I wouldn't be able to spend time on...
Manual testing steps:
imports
section, add a line with absolute path to the fileonedrive.nix
services.onedrive.enable = true; services.onedrive.package= <SOME RECENT CHANNEL>.onedrive