For what it’s worth, I don’t think you’re ignorant, I don’t think hydra is the easiest to use/comprehend or setup. The most helpful thing I can do is just give you pointers, since I just went through this:
-
Here’s the nix to configure Hydra, since … it takes a bit to actually get it useful/usable
https://github.com/cole-mickens/nixcfg/tree/main/hosts/azdev/hydrahighlights:
- the hydra machine txt file builder (specify hydra machine config in nice attr sets and it builds the single-line for you)
- the hydra patch to allow unrestricted eval (basically needed for modern nixos systems, afaict)
- placing an SSH key for
hydra
(or ratherhydra-queue-runner
) since its auth story is also different than the daemon - ignore the
auto.nix
for now (it’s a module to idempotently auto-setup hydra). It’s not complete. For now, seemisc/reset-hydra.sh
in that repo for a script that will AUTO-RESET hydra, setup a user, and setup my project: https://github.com/cole-mickens/nixcfg/blob/49d2d92139f593b29043a994bf8bc1030aa3df1a/misc/reset-hydra.sh
-
Here’s the bit of my flake to generate the declarative
.jobsets
job:
https://github.com/cole-mickens/nixcfg/blob/49d2d92139f593b29043a994bf8bc1030aa3df1a/flake.nix#L217-L225 -
Here’s the bit of the flake that actually have the hydra jobs
https://github.com/cole-mickens/nixcfg/blob/49d2d92139f593b29043a994bf8bc1030aa3df1a/flake.nix#L228-L234
Hope it helps!
Extra notes:
- Flakes is just some import syntax, it’s not necessary here. You can do declarative jobs, etc, all the same, the hydra config is just slightly different
- I think the hydra specs part, where the project is actually configured - I think I still use non-flakes for that (hydra-specs.nix → flakes-compat → #hydraSpecs), but I think hydra supports a flake ref here too, I haven’t tested yet.
Extra random notes, apropos of nothing:
- It would be really cool if hydra could decompose flake references and track them. I’d love to see "all hydra jobs where
nixcfg
was an input, or “show me the inputs and their rev changes that occurred for this instance of a job”. You could see failures based on inputs pop out, etc. - shout out to
clever from freenode
for thehydralib
that I stole to generate the jobspecs - shout out to nixpkgs ‘stdlib’ somewhere where I stole the beginnings of the hydra machine line builder and huge shout out to @grahamc for the pointer about configuring a specific identity key for a given machine (which is now incorporated in the machines-txt-builder helper), and some others I’ve forgotten.