!zghijEASpYQWYFzriI:nixos.org

Hydra

392 Members
110 Servers

Load older messages


SenderMessageTime
10 Apr 2022
@ulrikstrid:matrix.org@ulrikstrid:matrix.orgActually, can I do it at any branch?13:00:16
@ulrikstrid:matrix.org@ulrikstrid:matrix.orgI have commit rights/own the repo(s) I want to use this on13:01:24
@tilpner:tx0.cotilpneryes, you can specify the branch while fetching an input13:01:35
@ulrikstrid:matrix.org@ulrikstrid:matrix.orgOkay, nice 👌 I'll see if I can find some time this evening to play with it13:02:23
@tilpner:tx0.cotilpnerI have an application flake with one derivation for building in staging mode and one for building in production mode. This flake exists on two different branches (you guessed it, staging and production), which I'd both like to deploy automatically. It's only a slight annoyance, but hydra build both branches in both modes, even though the staging build of the production branch and the production build of the staging branch won't be needed. If I could pass arguments to a flake jobset, I could conditionally present a different hydraJobs attrset, but AFAIK there's no way to pass arguments to a flake jobset. Is there an easy workaround here?13:14:00
@tilpner:tx0.cotilpner * I have an application flake with one derivation for building in staging mode and one for building in production mode. This flake exists on two different branches (you guessed it, staging and production), which I'd both like to deploy automatically. It's only a slight annoyance, but hydra builds both branches in both modes, even though the staging build of the production branch and the production build of the staging branch won't be needed. If I could pass arguments to a flake jobset, I could conditionally present a different hydraJobs attrset, but AFAIK there's no way to pass arguments to a flake jobset. Is there an easy workaround here?13:19:31
@tomberek:matrix.orgtomberek no, no inputs from the outside. But a flake can do something like check the existence or contents of another file: builtins.pathExists. Perhaps something like hydraJobs = if builtins.pathExists x then import x self else null; or something like that 13:22:09
@tilpner:tx0.cotilpner
In reply to @tomberek:matrix.org
no, no inputs from the outside. But a flake can do something like check the existence or contents of another file: builtins.pathExists. Perhaps something like hydraJobs = if builtins.pathExists x then import x self else null; or something like that
surely this only allows checking the existence of paths inside the flake? I don't want the branches to diverge (also to avoid any git merge pain), just have production lag behind staging for a few days
13:25:45
@tomberek:matrix.orgtomberekperhaps this is what i don't understand: "but hydra builds both branches in both modes"13:35:27
@tilpner:tx0.cotilpner
In reply to @tomberek:matrix.org
perhaps this is what i don't understand: "but hydra builds both branches in both modes"
to make hydra build and test both branches, I have to create two jobsets, one for each branch. the production jobset still has two jobs (because it doesn't know it's going to be used for production),one for a production build and one for a staging build. but only the production build of the production jobset is going to be deployed, the staging build is unnecessary
13:38:11
@tilpner:tx0.cotilpnerbut maybe I'm doing this all wrong, I'm mostly guessing how these parts should fit together, there's not that much information out there for automatic application deployment with hydra :)13:39:13
@tomberek:matrix.orgtomberekyou'd need to do something conditional on the branch... there may be a few ways of doing that,,, but sadly even git doesn't even persist branch information (essentially because they are mutable)13:51:13
@casey:hubns.netcransomi do deployments in hydra, but there's no flake involved. hydra doesn't know the difference between production and staging, they are all just different environments being fed by different branches. the jobset builder creates a jobset for each environment where the inputs are specific to that branch/env13:53:21
@tomberek:matrix.orgtomberek

another possibility: create a flake that has inputs:

inputs.production.url = "github:org/repo/production";
inputs.staging.url = "github:org/repo/staging":

and go from there

13:54:56
@tilpner:tx0.cotilpner
In reply to @tomberek:matrix.org

another possibility: create a flake that has inputs:

inputs.production.url = "github:org/repo/production";
inputs.staging.url = "github:org/repo/staging":

and go from there

I have considered that, but then wouldn't I have to update those inputs and push an updated flake.lock, in order for hydra to evaluate the updated branches?
13:56:14
@tilpner:tx0.cotilpner
In reply to @casey:hubns.net
i do deployments in hydra, but there's no flake involved. hydra doesn't know the difference between production and staging, they are all just different environments being fed by different branches. the jobset builder creates a jobset for each environment where the inputs are specific to that branch/env
yes, the "legacy" mode seems a lot better suited to what I need, but I started with a flake because legacy usually implies it's not going to be supported forever :/
13:57:40
@casey:hubns.netcransomI agree. but also, flakes have been experimental for how long and I haven't seen an announcement as to when flakes won't be experimental.13:58:53
@casey:hubns.netcransomflakes are there to dismiss nix-channel, which for hydra and deployment like this, it's not using channels.13:59:40
@casey:hubns.netcransomi've been on the fence about moving to flakes for a couple years for work and I don't see the upside yet. it's a moving target. for personal projects, thats ok. if i have to subject the teams/company to it, it needs to be stable. so i would say that the non flake method shouldn't be called legacy, but stable.14:01:39
@tomberek:matrix.orgtomberekOr.... just build both jobs in both cases.... doesn't seem too onerous. 14:07:20
@tomberek:matrix.orgtomberekIf just starting out, i'd say adopting flakes is a good idea. If you have a large Nix codebase already, it's okay to delay a bit longer. It's really a question of how much "novelty budget" you have. Kinda like Python2/3 transition: it's painful, but eventually unavoidable.14:08:27
@tilpner:tx0.cotilpnerI already have a few flakes, but (though I haven't tried it yet) I hope I can use flake-compat to use them even in legacy mode14:11:28
@tomberek:matrix.orgtomberekback to the problem.... the trouble is that branch names and tags are not reproducible, so it's not something normally included into an evaluation14:11:30
@tomberek:matrix.orgtomberekeg: should a specific git commit checkout behave differently based on what branches and tags exist due to the git server it happens to live on?14:12:18
@tilpner:tx0.cotilpnerAnd yes, though building both variants works, there are actually two applications, and building just one variant for it takes a few minutes, so eliminating unused variants could decrease valuable push-to-deployed latencies14:12:35
@tilpner:tx0.cotilpner
In reply to @tomberek:matrix.org
eg: should a specific git commit checkout behave differently based on what branches and tags exist due to the git server it happens to live on?
Perhaps not in an unchecked universal way, but it would certainly make this task easier
14:14:11
@tilpner:tx0.cotilpner... how hard would it be to make hydra expose the branch name to builds?14:14:55
@tomberek:matrix.orgtomberekyeah.... i'm thinking.... you can have something in the production branch, a file like .version (nixpkgs has one)14:15:04
@tilpner:tx0.cotilpner(alternatively, this is solved-ish by https://github.com/NixOS/hydra/pull/1143)14:15:51
@tomberek:matrix.orgtomberekthe problem is that now the branch name leaks into builds... and changes behavior... the whole point of flakes is that it must be reproducible, and the branch name leaking in means even if I'm on the same commit as you, i may get different behavior.14:15:52

Show newer messages


Back to Room ListRoom Version: 6