[Nix-dev] Hydra on NixOS

Mateusz Kowalczyk fuuzetsu at fuuzetsu.co.uk
Sun Aug 10 09:38:46 CEST 2014


Hi,

I'm trying to set up Hydra on NixOS. After some searching I followed
[1], checking out from the revision that's currently master.

I did not reboot as stated on the page there so maybe that's the source
of my trouble but nixos-switch started up all hydra-foo.service just fine.

It did not create /var/lib/hydra/.pgpass as it was apparently meant to
so when I got to the interface I could not log in. I followed to the
Hydra manual which tells me to run postgres and add hydra user but
hydra-init.service already handled that so I don't do it. I scroll down
and find that I am meant to run hydra-init and then use
hydra-create-user. I do this while still logged in as root.

I now find that I still can't log in to my Hydra instance. I start
messing around and thinking it might be permissions problem because I
now have root files in /var/lib/hydra. I delete those and try to
hydra-init again as hydra user but the result is similar, can't log in.
At this point I decide to scrap it and try again, just disable hydra and
postgres in my configuration.nix, rebuild, --gc, re-enable. However
there is a problem: if I nixos-rebuild switch more than once with Hydra,
I get

● hydra-init.service
   Loaded: loaded
(/nix/store/pvcv6z3yzgy3vzws5is0sd5r2hz9pjv3-unit/hydra-init.service)
   Active: failed (Result: exit-code) since Sun 2014-08-10 09:23:33
CEST; 28ms ago
  Process: 6714
ExecStartPre=/nix/store/zlsf8wn19rl5qhs27lr5cs08xx718vdx-unit-script/bin/hydra-init-pre-start
(code=exited, status=1/FAILURE)

Aug 10 09:23:33 lenalee hydra-init-pre-start[6714]: createuser: creation
of new role failed: ERROR:  role "hydra" already exists
Aug 10 09:23:33 lenalee systemd[1]: hydra-init.service: control process
exited, code=exited status=1
Aug 10 09:23:33 lenalee systemd[1]: Failed to start hydra-init.service.
Aug 10 09:23:33 lenalee systemd[1]: Unit hydra-init.service entered
failed state.

So this means I can't ever run nixos-rebuild switch more than once with
Hydra around… OK.

I can't run postgres as hydra user and delete it because it doesn't know
where to find the db. I can't run it as root because postgres stops that
as a security measure. So I am stuck here unless I disable postgres and
Hydra.

If I stop Hydra services, run hydra-init as root, hydra-create-user and
run hydra-server then I can actually log in but I am of course stuck
with a system which can't rebuild and requires I manually run Hydra as
root which is two terrible things.

I also notice that the postgres and hydra system users don't go away if
I revert my config and rebuild which seems strange to me, is this by design?

In the end my question is simply “How do I actually properly install
Hydra on NixOS?!”. The manual itself makes zero mention of doing it on
NixOS through configuration.nix as far as I can see. Worse, it's unclear
what users are being using to execute which commands so even following
that, permissions may end up being a problem.

I will for now remove anything Hydra related from my config, delete
generations, --gc/-d and hope it all goes away until someone can provide
some guidance.


[1]: https://nixos.org/wiki/Installing_hydra_as_nixos_module
[2]:
http://hydra.nixos.org/build/13164007/download/1/hydra/manual.html#chap-installation
-- 
Mateusz K.


More information about the nix-dev mailing list