Skip to content

Fixes for NixOps issue #350#10546

Merged
zimbatm merged 2 commits intoNixOS:masterfrom
aszlig:nixops-issue-350
Feb 26, 2016
Merged

Fixes for NixOps issue #350#10546
zimbatm merged 2 commits intoNixOS:masterfrom
aszlig:nixops-issue-350

Conversation

@aszlig
Copy link
Member

@aszlig aszlig commented Oct 22, 2015

These fixes are not only related to NixOS/nixops#350 of course but also fix two other things:

  • Correct system activation for dashes in pathnames for fileSystems.
  • Nix Daemon being dependant on whether /nix/store is/was mounted.

Cc: @edolstra

Clearly it would be the best if we'd directly generate mount units
instead of converting /etc/fstab. But in order to do that we need to
test it throughly so this approach is for the next stable release.

This fix however is intended for inclusion into release-14.12 and
release-15.09.

Using a simple regular expression unfortunately isn't sufficient for
proper mount unit name quoting/escaping and there is a utility in
systemd called systemd-escape which does nothing less than that.

Of course, using an external program to escape the unit name is way more
expensive and causes us to fork for each mount point.

But given that we already do quite a lot of forks just for unit starting
and stopping, I think it doesn't matter that much. Well, except if you
have a whole bunch of mount points.

However, if the latter is the case and you have thousands of mount
points, you probably have stumbled over this already if your mount point
contains a dash.

As for my motivation to fix this: I've stumbled on this while trying to
fix the "none" backend test for NixOps (see NixOS/nixops#350), where the
target machines use /nix/.ro-store and /nix/.rw-store as mount points.

The implementation we had so far did improperly escape it so those mount
points got the following unit files:

 * nix-.ro-store.mount
 * nix-.rw-store.mount

The correct names for these units are however:

 * nix-.ro\x2dstore.mount
 * nix-.rw\x2dstore.mount

So using systemd-escape now properly generates these names.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Also related to NixOS/nixops#350, because while switching to the new
configuration, depending on /nix/store also propagates to the mount
points for /nix/.ro-store and /nix/.rw-store and we don't get an error
while trying to unmount them (because nix-daemon needs to be stopped for
unmounting these paths).

While Nix does have the option to set a different store path, I've found
only hardcoded references in nix-daemon.nix, so I'm using a hardcoded
reference here as well, because after all customizing the store path
will probably only make sense on non-NixOS systems.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
@aszlig aszlig added 0.kind: bug Something is broken 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 9.needs: reporter feedback This issue needs the person who filed it to respond labels Oct 22, 2015
@jagajaga
Copy link
Member

cc @edolstra

aszlig added a commit to aszlig/nixops that referenced this pull request Oct 23, 2015
We have virtualisation.writableStore active for the targets that are not
yet deployed by NixOps but not within the NixOps network specification.

This has worked regardless in the past, because using a writable store
was implemented solely using boot.initrd.postMountCommands, so switching
to a new configuration didn't change anything and left the store
untouched.

But after NixOS/nixpkgs@e68b0c7, the mounts for the writable store are
now using the fileSystems configuration attribute, which causes the
mount points to be changed on switch.

Another problem is that the mount units weren't escaped properly. But
that isn't the problem here anymore (because we don't change the mounts
between activation) and has been (or is going to be) dealt with in
NixOS/nixpkgs#10546.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
@domenkozar
Copy link
Member

cc @rbvermaa

zimbatm added a commit that referenced this pull request Feb 26, 2016
@zimbatm zimbatm merged commit b73c5ae into NixOS:master Feb 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.kind: bug Something is broken 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 9.needs: reporter feedback This issue needs the person who filed it to respond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants