diff options
Diffstat (limited to 'pkgs/krops/default.nix')
-rw-r--r-- | pkgs/krops/default.nix | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/pkgs/krops/default.nix b/pkgs/krops/default.nix index 4760287..ab74bc3 100644 --- a/pkgs/krops/default.nix +++ b/pkgs/krops/default.nix @@ -5,7 +5,7 @@ in { nix, openssh, populate, writers }: rec { build = target: - remoteCommand target (lib.concatStringsSep " " [ + runShell target (lib.concatStringsSep " " [ "nix build" "-I ${lib.escapeShellArg target.path}" "--no-link -f '<nixpkgs/nixos>'" @@ -13,20 +13,23 @@ in ]); rebuild = args: target: - remoteCommand target "nixos-rebuild -I ${lib.escapeShellArg target.path} ${ + runShell target "nixos-rebuild -I ${lib.escapeShellArg target.path} ${ lib.concatMapStringsSep " " lib.escapeShellArg args }"; - remoteCommand = target: command: - writers.writeDash "build.${target.host}" '' - exec ${openssh}/bin/ssh ${lib.escapeShellArgs (lib.flatten [ - (lib.optionals (target.user != "") ["-l" target.user]) - "-p" target.port - "-t" - target.extraOptions - target.host - (if target.sudo then "sudo ${command}" else command)])} - ''; + runShell = target: command: + if lib.isLocalTarget target + then command + else + writers.writeDash "krops.${target.host}.${lib.firstWord command}" '' + exec ${openssh}/bin/ssh ${lib.escapeShellArgs (lib.flatten [ + (lib.optionals (target.user != "") ["-l" target.user]) + "-p" target.port + "-T" + target.extraOptions + target.host + (if target.sudo then "sudo ${command}" else command)])} + ''; writeCommand = name: { command ? (targetPath: "echo ${targetPath}"), @@ -40,7 +43,7 @@ in writers.writeDash name '' set -efu ${populate { inherit backup force source; target = target'; }} - ${remoteCommand target' (command target'.path)} + ${runShell target' (command target'.path)} ''; writeDeploy = name: { |