Nixpkgs: Apache httpd NixOS module can no longer serve up content from the store

Created on 5 Jan 2017  Â·  8Comments  Â·  Source: NixOS/nixpkgs

Back in the day, we had a super-cute example in the manual that served up valgrind documentation with something like the following configuration:

{ pkgs, ... }:

{
  services.httpd = {
    enable = true;
    adminAddr = "[email protected]";
    documentRoot = "${pkgs.valgrind}/share/doc/valgrind/html";
  };
  networking.firewall.allowedTCPPorts = [ 80 ];
}

Now something appears to have changed in the httpd module that causes httpd to fail at startup:

Jan 05 18:19:12 ip-172-29-89-171.ec2.internal systemd[1]: Starting Apache HTTPD...
Jan 05 18:19:12 ip-172-29-89-171.ec2.internal httpd-pre-start[3259]: mkdir: cannot create directory ‘/nix/store/ns640dwilpd8d8irlc5mycc661gyan02-valgrind-3.11.0/share’: Read-only file system
Jan 05 18:19:12 ip-172-29-89-171.ec2.internal systemd[1]: httpd.service: Control process exited, code=exited status=1
Jan 05 18:19:12 ip-172-29-89-171.ec2.internal systemd[1]: Failed to start Apache HTTPD.
Jan 05 18:19:12 ip-172-29-89-171.ec2.internal systemd[1]: httpd.service: Unit entered failed state.
Jan 05 18:19:12 ip-172-29-89-171.ec2.internal systemd[1]: httpd.service: Failed with result 'exit-code'.
Jan 05 18:19:17 ip-172-29-89-171.ec2.internal systemd[1]: httpd.service: Service hold-off time over, scheduling restart.
Jan 05 18:19:17 ip-172-29-89-171.ec2.internal systemd[1]: Stopped Apache HTTPD.

I see a few instances of other people encountering this but no obvious fix: https://groups.google.com/forum/#!topic/nixops-users/vDE67k480uM and https://github.com/NixOS/nixops/issues/391

I'm guessing someone added a wrapper to httpd that tries to modify the documentRoot directory? That seems unfortunate, and I love to serve up content from the store (so I can build it with nix and revert/restore like I do with everything else).

bug regression nixos

Most helpful comment

Okay, so I'll close this, and later file a PR getting rid of that line, if nobody objects.

All 8 comments

I have used this technique before and I'm sorry to hear that it's broken. We should fix it.

This is useful!

It works fine with "${pkgs.valgrind.doc}/share/doc/valgrind/html" 😊

Oh! I guess it's this stuff hiding the real bug then:

            ${optionalString (mainCfg.documentRoot != null)
            ''
              # Create the document root directory if does not exists yet
              mkdir -p ${mainCfg.documentRoot}
            ''
            }

Is that really necessary? How often do you want to point your server at a directory that doesn't exist and have the server create it? @svanderburg

Yes it is, I thought it wasn't conditional, then I figured out that the directory doesn't exist.

So I guess this isn't a real bug and I can close it, but I still don't see why it should need to mkdir -p that directory. It should just check that it exists and complain if not?

I agree it doesn't make a lot of sense, since it's supposed to have content.

Okay, so I'll close this, and later file a PR getting rid of that line, if nobody objects.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  Â·  3Comments

edolstra picture edolstra  Â·  3Comments

tomberek picture tomberek  Â·  3Comments

domenkozar picture domenkozar  Â·  3Comments

ob7 picture ob7  Â·  3Comments