!BgJZHVOYkwVcEKLAyM:nixos.org

NixOS Deployments

1246 Members
NixOS Deployment tooling307 Servers

Load older messages


SenderMessageTime
25 Jul 2021
@dearrude:nitro.chatdearrude joined the room.20:56:44
26 Jul 2021
@avaq:matrix.orgAldwin

Hi. Is it normal to want to run nixops deploy in a GitHub action? I'm asking because if it's normal, I feel like it should be easier. But it's not easy, so maybe I'm taking a wrong approach.

It seems like an obvious next step to me to want to automate the deployment once you've got a network configured with NixOps. But I've been surfing the web for any examples or tutorials, but can't really find anything.
I did find some stuff on https://nix.dev (thank you Domen Kožar) that shows how to do nix-build on a GitHub action and possibly use Cachix, but nothing about nixops or deployment.

I'm also a bit confused/concerned about the the NixOps stateful stuff. It seems to generate a keypair on first deployment which it expects to reuse. Not sure if that can work when deploying from a clean environment every time.

15:02:53
@avaq:matrix.orgAldwin *

Hi. Is it normal to want to run nixops deploy in a GitHub action? I'm asking because if it's normal, I feel like it should be easier. But it's not easy, so maybe I'm taking a wrong approach.

It seems like an obvious next step to me to want to automate the deployment once you've got a network configured with NixOps. But I've been surfing the web for any examples or tutorials, and can't really find anything.
I did find some stuff on https://nix.dev (thank you Domen Kožar) that shows how to do nix-build on a GitHub action and possibly use Cachix, but nothing about nixops or deployment.

I'm also a bit confused/concerned about the the NixOps stateful stuff. It seems to generate a keypair on first deployment which it expects to reuse. Not sure if that can work when deploying from a clean environment every time.

15:03:32
@avaq:matrix.orgAldwin *

Hi. Is it normal to want to run nixops deploy in a GitHub action? I'm asking because if it's normal, I feel like it should be easier. But it's not easy, so maybe I'm taking a wrong approach.

It seems like an obvious next step to automate deployment once you've got a network configured with NixOps. But I've been surfing the web for any examples or tutorials, and can't really find anything.
I did find some stuff on https://nix.dev (thank you Domen Kožar) that shows how to do nix-build on a GitHub action and possibly use Cachix, but nothing about nixops or deployment.

I'm also a bit confused/concerned about the the NixOps stateful stuff. It seems to generate a keypair on first deployment which it expects to reuse. Not sure if that can work when deploying from a clean environment every time.

15:04:36
@domenkozar:matrix.orgDomen Kožar Aldwin: my recommendation would be to use terraform + plain deploy 15:04:42
@domenkozar:matrix.orgDomen Kožarit depends a bit on the usage case, but you can get very far with that15:04:54
@avaq:matrix.orgAldwinWhat do you mean by a "plain deploy"?15:05:31
@domenkozar:matrix.orgDomen KožarI need to write a tutorial for this :)15:05:55
@domenkozar:matrix.orgDomen KožarI mean: nixos-rebuild switch --target-host ip15:06:12
@avaq:matrix.orgAldwin --target-host :o 15:06:44
@domenkozar:matrix.orgDomen Kožaranother option is https://nix.dev/tutorials/deploying-nixos-using-terraform that has this built in15:07:15
@avaq:matrix.orgAldwinI think terraform might be overkill for my case. I started small with a single nginx server that only redirects requests.15:08:01
@domenkozar:matrix.orgDomen Kožarah yeah, then nixos-rebuild switch --target-host is what you want15:08:21
@avaq:matrix.orgAldwin So you propose ditching nixops altogether, and doing a "normal" nixos-rebuild, relying on this --target-host option to "deploy". 15:10:50
@avaq:matrix.orgAldwinI never knew about --target-host15:10:56
@domenkozar:matrix.orgDomen Kožarthat's why I need to write a tutorial for it :D15:11:07
@avaq:matrix.orgAldwinI've been using nixops for a while, and most of my "networks" only have a single machine. Would you say that those might all be good candidates for just using a deploy script that sets the appropriate target-host?15:13:07
@avaq:matrix.orgAldwinAnd I guess I need to manage my own ssh access when using --target-host15:15:35
@avaq:matrix.orgAldwinAs opposed to with nixops, which sort of manages it for me15:15:56
@domenkozar:matrix.orgDomen Kožarexactly, nixops puts all of that into an sqlite15:22:23
@domenkozar:matrix.orgDomen Kožarhaving those keys specified as secrets makes it a tiny bit more transparent I think15:37:22
@avaq:matrix.orgAldwin

Domen Kožar: Are you using the --target-host method already to deploy something from a GitHub action? I have a few questions:

  1. Do you simply use the NIXOS_CONFIG env var to point nixos-rebuild to your config file?
  2. To provision, do you:
    • Generate an ssh key locally or whatever;
    • put the public part in your configuration.nix#users.users.root.openssh.authorizedKeys.keys;
    • upload the private part to a GitHub secret;
    • and use the NIX_SSHOPTS env var to expose the private key to nixos-rebuild?
15:37:28
@domenkozar:matrix.orgDomen KožarSee https://github.com/shimataro/ssh-key-action15:39:25
@gytis-ivaskevicius:matrix.orgGytis IvaskeviciusRedacted or Malformed Event15:40:13
@avaq:matrix.orgAldwinAh, handy. :)15:40:34
@avaq:matrix.orgAldwin But that still only goes instead of the NIX_SSHOPTS, right? The rest seems like I had it right. 15:41:26
@domenkozar:matrix.orgDomen Kožaryeah you got everything else right :)15:43:11
@avaq:matrix.orgAldwin Domen Kožar: NIXOS_CONFIG needs an absolute path. Did you find a handy way to give it one in a GitHub workflow env spec? 16:04:10
@domenkozar:matrix.orgDomen KožarNIXOS_CONFIG=$(pwd)/mymachine.nix16:05:00
@domenkozar:matrix.orgDomen Kožarwhen invoking nixos-rebuild16:05:07

There are no newer messages yet.


Back to Room ListRoom Version: 6