aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md10
-rw-r--r--pkgs/krops/default.nix10
2 files changed, 18 insertions, 2 deletions
diff --git a/README.md b/README.md
index 39ed6cb..7c17d6d 100644
--- a/README.md
+++ b/README.md
@@ -129,6 +129,16 @@ architecture.
Run `nixos-rebuild` immediately without building the system in a dedicated `nix
build` step.
+### `flake` (optional)
+
+Name of the source containing the flake to deploy, optionally followed by `#`
+and the name of the NixOS configuration, e.g. `"myconf#myhost"`. If the source
+draws inputs from other sources, its generated flake gets deployed, see
+[Flake inputs from sources](#flake-inputs-from-sources). This makes
+`nixos-rebuild` use `--flake`, and requires Nix with flake support (Nix 2.4 or
+later) on the build target. Without the name of the NixOS configuration,
+`nixos-rebuild` uses the host name of the build target.
+
### `force` (optional, defaults to false)
Create the sentinel file (`/var/src/.populate`) before syncing the new source.
diff --git a/pkgs/krops/default.nix b/pkgs/krops/default.nix
index 04c38cf..93f9d0e 100644
--- a/pkgs/krops/default.nix
+++ b/pkgs/krops/default.nix
@@ -5,13 +5,18 @@ in
{ nix, openssh, populate, writers }: rec {
rebuild = {
+ flake ? null,
useNixOutputMonitor
}:
args: target:
runShell target {}
(withNixOutputMonitor target useNixOutputMonitor /* sh */ ''
+ ${lib.optionalString (flake != null)
+ (lib.shell.requireFlakes "deploying a flake")}
NIX_PATH=${lib.escapeShellArg target.path} \
- nixos-rebuild ${lib.escapeShellArgs args}
+ nixos-rebuild ${lib.escapeShellArgs (args ++ lib.optionals (flake != null) [
+ "--flake" "${target.path}/${flake}"
+ ])}
'');
runShell = target: {
@@ -91,6 +96,7 @@ in
buildTarget ? null,
crossDeploy ? false,
fast ? null,
+ flake ? null,
force ? false,
operation ? "switch",
source,
@@ -109,7 +115,7 @@ in
${lib.optionalString (buildTarget' != target')
(populate { inherit backup force source; target = buildTarget'; })}
${populate { inherit backup force source; target = target'; }}
- ${rebuild { inherit useNixOutputMonitor; } ([
+ ${rebuild { inherit flake useNixOutputMonitor; } ([
operation
] ++ lib.optionals crossDeploy [
"--no-build-nix"