# deploy-sh Simple NixOS remote deployment tool ## Flake Setup
1. Add a deploy-sh.hosts output to your flake.nix. This has to be an attribute set of NixOS systems. ```nix { outputs = {self, nixpkgs, ...}: { nixosConfigurations = { foo = nixpkgs.lib.nixosSystem { ... }; bar = nixpkgs.lib.nixosSystem { ... }; baz = nixpkgs.lib.nixosSystem { ... }; }; deploy-sh.hosts = self.nixosConfigurations; }; } ```
2. Import and configure the deploy-sh NixOS module. ```nix { inputs = { deploy-sh.url = "git+https://git.defelo.de/Defelo/deploy-sh"; }; outputs = {self, nixpkgs, deploy-sh, ...}: { nixosConfigurations.foo = nixpkgs.lib.nixosSystem { # ... modules = [ # ... deploy-sh.nixosModules.default { deploy-sh.targetHost = "root@10.13.37.2"; } ]; }; deploy-sh.hosts = self.nixosConfigurations; }; } ```
3. To be able to use the deploy command, add deploy-sh to your dev shell. ```nix { inputs = { deploy-sh = "git+https://git.defelo.de/Defelo/deploy-sh"; }; outputs = {self, nixpkgs, deploy-sh, ...}: let system = "x86_64-linux"; pkgs = import nixpkgs {inherit system;}; in { devShells.${system}.default = pkgs.mkShell { packages = [ deploy-sh.packages.${system}.default ]; }; }; } ```
## NixOS Module Options See [flake.nix](https://git.defelo.de/Defelo/deploy-sh/blob/develop/flake.nix#L48-L77) ## Usage ``` $ nix develop # if you are not using direnv $ deploy --help Simple NixOS remote deployment tool (https://git.defelo.de/Defelo/deploy-sh) Usage: deploy [OPTIONS] [HOSTS]... For each host, only the most recent options to its left are taken into account. For example, `deploy --local foo bar --remote baz` will build hosts foo and bar locally, and only baz on a remote build host. All hosts are deployed if no host is specified explicitly. Activation options: --switch Build and activate the new configuration, and make it the boot default. (default) --boot Build the new configuration and make it the boot default, but do not activate it. --test Build and activate the new configuration, but do not add it to the boot menu. --dry-activate Build the new configuration, but do not activate it. --reboot Build the new configuration, make it the boot default and reboot into the new system. --eval Evaluate the new configuration, but neither build nor activate it. Diff options: --diff Display differences between the current and new configuration --no-diff Don't display differences between the current and new configuration. --nvd Display package differences between the current and new configuration. (default) --no-nvd Don't display package differences between the current and new configuration. Host options: --local Build the configuration locally and copy the new system to the target host. --remote Build the configuration on the remote build host. --build-host Set the host to build the configuration on. --target-host Set the host to deploy the system on. Build options: --cache Set a path on the build host where to store a symlink to the new system to avoid garbage collection. --no-cache Don't store a symlink to the new system on the build host. --fetch Copy the current system of the target host to the build host before building. --no-fetch Don't copy the current system of the target host to the build host before building. (default) Options: -h --help Print help ```