krebs / krops

Mirror of https://cgit.krebsco.de/krops/about/ (PRs / issues accepted, as can be seen by not having them disabled)
Do What The F*ck You Want To Public License
132 stars 18 forks source link

Possibility to call krops-deploy without actually switching the configuration on a target host #34

Closed seberm closed 2 years ago

seberm commented 2 years ago

Hello, I am still very new to NixOS and krops. I just want to ask if there is a possibility to configure krops to do a deploy without switching to the new configuration on a target host.

What I basically need is to just make the sources available on the target machine in /var/src. That's all. There are some cases where I need to run the nixos-build boot instead of a nixos-build switch. Is this possible with current implementation?

Thank you! Ota

Lassulus commented 2 years ago

sure, you can for example use populate (which is the part to put everything into /var/src on the target system):

...
    pkgs.populate "deploy" {
    source = source;
    target = "root@YOUR_IP_ADDRESS_OR_HOST_NAME_HERE";
  }

to run other commands than nixos-rebuild switch you can use writeComamnd:

  pkgs.krops.writeCommand "deploy-boot" {
    command = targetPath: ''
      nixos-rebuild -I ${targetPath} boot
    '';
    source = source;
    target = "root@YOUR_IP_ADDRESS_OR_HOST_NAME_HERE";
  }
seberm commented 2 years ago

Thank you Lassulus for you help! It seems it's finally working as expected :).