mirror of
https://cgit.krebsco.de/krops
synced 2024-11-23 11:39:48 +01:00
commit
f1b7112ac3
2 changed files with 57 additions and 7 deletions
43
README.md
43
README.md
|
@ -1,6 +1,6 @@
|
||||||
# krops (krebs ops)
|
# krops (krebs ops)
|
||||||
|
|
||||||
krops is a lightweigt toolkit to deploy NixOS systems, remotely or locally.
|
krops is a lightweight toolkit to deploy NixOS systems, remotely or locally.
|
||||||
|
|
||||||
|
|
||||||
## Some Features
|
## Some Features
|
||||||
|
@ -56,7 +56,9 @@ and run `$(nix-build --no-out-link krops.nix)` to deploy the target machine.
|
||||||
Under the hood, this will make the sources available on the target machine
|
Under the hood, this will make the sources available on the target machine
|
||||||
below `/var/src`, and execute `nixos-rebuild switch -I /var/src`.
|
below `/var/src`, and execute `nixos-rebuild switch -I /var/src`.
|
||||||
|
|
||||||
## Deployment Target Attribute
|
## Deployment Attributes
|
||||||
|
|
||||||
|
### `target`
|
||||||
|
|
||||||
The `target` attribute to `writeDeploy` can either be a string or an attribute
|
The `target` attribute to `writeDeploy` can either be a string or an attribute
|
||||||
set, specifying where to make the sources available, as well as where to run
|
set, specifying where to make the sources available, as well as where to run
|
||||||
|
@ -84,9 +86,42 @@ pkgs.krops.writeDeploy "deploy" {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
For more details about the `target` attribute, please check the `mkTarget`
|
For more details about the `target` attribute, please check the `mkTarget`
|
||||||
function in lib/default.nix.
|
function in [lib/default.nix](lib/defaults.nix).
|
||||||
|
|
||||||
|
### `backup` (optional, defaults to false)
|
||||||
|
|
||||||
|
Backup all paths specified in source before syncing new sources.
|
||||||
|
|
||||||
|
### `buildTarget` (optional)
|
||||||
|
|
||||||
|
If set the evaluation and build of the system will be executed on this host.
|
||||||
|
`buildTarget` takes the same arguments as target.
|
||||||
|
Sources will be synced to both `buildTarget` and `target`.
|
||||||
|
Built packages will be uploaded from the `buildTarget` to `target` directly
|
||||||
|
This requires the building machine to have ssh access to the target.
|
||||||
|
To build the system on the same machine, that runs the krops command,
|
||||||
|
set up a local ssh service and set the build host to localhost.
|
||||||
|
|
||||||
|
### `crossDeploy` (optional, defaults to false)
|
||||||
|
|
||||||
|
Use this option if target host architecture is not the same as the build host
|
||||||
|
architecture as set by `buildHost` i.e. deploying to aarch64 from a x86_64
|
||||||
|
machine. Setting this option will disable building & running nix in the wrong
|
||||||
|
architecture when running `nixos-rebuild` on the deploying machine. It is
|
||||||
|
required to set `nixpkgs.localSystem.system` in the NixOS configuration to the
|
||||||
|
architecture of the target host. This option is only useful if the build host
|
||||||
|
also has remote builders that are capable of producing artifacts for the deploy
|
||||||
|
architecture.
|
||||||
|
|
||||||
|
### `fast` (optional, defaults to false)
|
||||||
|
|
||||||
|
Run `nixos-rebuild switch` immediately without building the system
|
||||||
|
in a dedicated `nix build` step.
|
||||||
|
|
||||||
|
### `force` (optional, defaults to false)
|
||||||
|
|
||||||
|
Create the sentinel file (`/var/src/.populate`) before syncing the new source.
|
||||||
|
|
||||||
## Source Types
|
## Source Types
|
||||||
|
|
||||||
|
|
|
@ -47,21 +47,36 @@ in
|
||||||
|
|
||||||
writeDeploy = name: {
|
writeDeploy = name: {
|
||||||
backup ? false,
|
backup ? false,
|
||||||
|
buildTarget ? null,
|
||||||
|
crossDeploy ? false,
|
||||||
fast ? false,
|
fast ? false,
|
||||||
force ? false,
|
force ? false,
|
||||||
source,
|
source,
|
||||||
target
|
target
|
||||||
}: let
|
}: let
|
||||||
|
buildTarget' =
|
||||||
|
if buildTarget == null
|
||||||
|
then target'
|
||||||
|
else lib.mkTarget buildTarget;
|
||||||
target' = lib.mkTarget target;
|
target' = lib.mkTarget target;
|
||||||
in
|
in
|
||||||
writeDash name ''
|
writeDash name ''
|
||||||
set -efu
|
set -efu
|
||||||
|
${lib.optionalString (buildTarget' != target')
|
||||||
|
(populate { inherit backup force source; target = buildTarget'; })}
|
||||||
${populate { inherit backup force source; target = target'; }}
|
${populate { inherit backup force source; target = target'; }}
|
||||||
${lib.optionalString (! fast) ''
|
${lib.optionalString (! fast) ''
|
||||||
${rebuild ["dry-build"] target'}
|
${rebuild ["dry-build"] buildTarget'}
|
||||||
${build target'}
|
${build buildTarget'}
|
||||||
''}
|
''}
|
||||||
${rebuild ["switch"] target'}
|
${rebuild ([
|
||||||
|
"switch"
|
||||||
|
] ++ lib.optionals crossDeploy [
|
||||||
|
"--no-build-nix"
|
||||||
|
] ++ lib.optionals (buildTarget' != target') [
|
||||||
|
"--build-host" "${buildTarget'.user}@${buildTarget'.host}"
|
||||||
|
"--target-host" "${target'.user}@${target'.host}"
|
||||||
|
]) buildTarget'}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
writeTest = name: {
|
writeTest = name: {
|
||||||
|
|
Loading…
Reference in a new issue