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
locatedb: fix startup fail due to systemd path capabilities #30312
locatedb: fix startup fail due to systemd path capabilities #30312
Conversation
in systemd 231.
nixos/modules/misc/locate.nix
Outdated
mkdir -m 0755 -p ${dirOf cfg.output} | ||
''; | ||
requiredBy = [ "update-locatedb.service" ]; | ||
before = [ "update-locatedb.service" ]; |
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.
I would probably make this of type oneshot
and RemainAfterExit=true
.
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.
Oh I forgot. This was probably causing the first invocation problems.
nixos/modules/misc/locate.nix
Outdated
{ description = "Create locatedb state on first run"; | ||
script = '' | ||
mkdir -m 0755 -p ${dirOf cfg.output} | ||
''; |
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.
The following should save building a dedicated script derivation:
serviceConfig.ExecStart = "${pkgs.coreutils}/bin/mkdir -m 0755 -p ${dirOf cfg.output}"
nixos/modules/misc/locate.nix
Outdated
serviceConfig.ReadWriteDirectories = dirOf cfg.output; | ||
serviceConfig.ReadOnlyPaths = "/"; | ||
# TODO: one could try to further reduce this to cfg.output by pre-creating the file in locatedb-setup | ||
serviceConfig.ReadWritePaths = dirOf cfg.output; |
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.
ConditionPathExists=
might also lead to better error messages.
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.
Just tested it, sadly neither ConditionPathExists
nor AssertPathExists
seem to have any effect, it's always just the NAMESPACE
error. 😞
I wonder, if we just could use |
by using systemd-tmpfiles. Also document what's happening there.
7372279
to
70c3f56
Compare
Forgot about @Mic92 thanks alot for the hint, just updated the PR. |
also in 17.09 now. |
Motivation for this change
On fresh NixOS 17.09 installs,
update-locatedb.service
continuously fails with:This is because of the
ReadWritePaths=/var/cache
namespace restriction, as on new installs,/var/cache
does not exist and therefore results in theno such file or directory
. To reproduce this, delete your/var/cache
directory.I try to fix this by pulling out the mkdir part in a separate service. Note that this still fails on the first invocation with the same error, but creates the directory and then works on all subsequent invocations. I don't know why that happens. Maybe because the namespace restrictions are evaluated instantly when the unit is started, or because I did something wrong with the depency specification?
In any case, working the second day after being enabled is an improvement over always failing until the user creates
/var/cache
manually.Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)