Closed NelsonJeppesen closed 2 years ago
@NelsonJeppesen Without investigating at all, my first guess is that your use of the ~ to mean home might be an issue. That would typically be interpreted by a shell, but in this case that might not happen.
Ah okay looking a bit more closely, you are using nix path objects, because you are not quoting the paths. These are likely getting coerced into strings, and in nix, this causes the path to be pulled in to the nix store.
I believe that if you provide a string instead, by quoting the values, you should get the behavior that you want.
Specifically, I am saying: this line
services.git-sync.repositories.notes.path = ~/s/notes;
shoudl be replaced with
services.git-sync.repositories.notes.path = "~/s/notes";
Hmm. I'm sort of surprised this even works for you. When I set the path to a similar value, I get:
error: A definition for option home-manager.users.imalison.services.git-sync.repositories.config.path' is not of type
path'.
Ah wait, nevermind ignore what I said about the quoting fix, that does not quite work.
I think this question may be relevant to the issue: https://stackoverflow.com/questions/43850371/when-does-a-nix-path-type-make-it-into-the-nix-store-and-when-not
Wow, thank you for the feedback!
I just tiried this
services.git-sync.repositories.notes.path = /home/nelson/s/notes;
then this:
services.git-sync.repositories.notes.path = "/home/nelson/s/notes";
The first made no change, but the second one worked, with quotes. So, for me, it works with quotes
Regardless of how it does work on my box, what is the prefered way to do this?
Yeah so I had it set up for me like:
services.git-sync.repositories.notes.path = "/home/nelson/s/notes";
and I hadn't tested other ways of specifying paths or the home directory.
It would be nice if there were some way to reference the home directory where you did not need to be explicit about it like that.
I'm going to look in to it some more and hopefully have it try to behave a bit more intelligently w.r.t. paths.
Regardless of how it does work on my box, what is the prefered way to do this?
I do think that you have uncovered a genuine issue here, so I will do some more investigation and get back to you on this.
I do think it should be possible to use something like this: https://github.com/nix-community/home-manager/blob/f6d1cad6ba228b81bf7045f1124aa99dfdcf3daa/nixos/default.nix#L34
to interact with the home directory.
I think it also makes sense to put a warning, or perhaps fail, if the directory is found in the nix store.
Regardless of how it does work on my box, what is the prefered way to do this?
I do think that you have uncovered a genuine issue here, so I will do some more investigation and get back to you on this.
I do think it should be possible to use something like this:
to interact with the home directory.
I think it also makes sense to put a warning, or perhaps fail, if the directory is found in the nix store.
Anything I can test on my end to help?
Would it make sense to close this issue?
@NelsonJeppesen Not quite yet. I think I can add some mitgations.
@NelsonJeppesen I would recommend you do this the way I do it here: https://github.com/IvanMalison/dotfiles/blob/d505e8c79dd99af12d4790d27838acc71e58b666/nixos/home-manager.nix#L84
I think the solution is to simply call toString
when generating the configuration:
mkUnit = name: repo: {
Unit.Description = "Git Sync ${name}";
Install.WantedBy = [ "default.target" ];
Service = {
Environment = [
"GIT_SYNC_DIRECTORY=${repo.path}"
"GIT_SYNC_COMMAND=${cfg.package}/bin/git-sync"
"GIT_SYNC_REPOSITORY=${toString repo.uri}"
"GIT_SYNC_INTERVAL=${toString repo.interval}"
];
ExecStart = "${cfg.package}/bin/git-sync-on-inotify";
Restart = "on-abort";
};
};
If someone wants to test this and open a PR it would be great.
Thank you for your contribution! I marked this issue as stale due to inactivity. If this remains inactive for another 7 days, I will close this issue. Please read the relevant sections below before commenting.
* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you have nothing of substance to add, please refrain from commenting and allow the bot close the issue. Also, don't be afraid to manually close an issue, even if it holds valuable information.
Closed issues stay in the system for people to search, read, cross-reference, or even reopen--nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.
Is there an existing issue for this?
Issue description
I have the following configuration
I have created the repo with a simply git clone
logs show issues with readonly fs
I belive the mistake is the dir is set to the nixstore, not the dir specifed in my configuration
I've read the code, but not really sure why it's doing this
Maintainer CC
@IvanMalison
System information