From 4162ba5277abe395d2a1088f463d3fabfaf39689 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Wed, 4 Aug 2021 01:19:02 -0700 Subject: [PATCH 1/4] Mass yeet-ification --- .reuse/dep5 | 4 ++-- Cargo.lock | 46 +++++++++++++++++++------------------- Cargo.toml | 4 ++-- README.md | 42 +++++++++++++++++----------------- examples/simple/flake.lock | 8 +++---- examples/simple/flake.nix | 8 +++---- examples/system/README.md | 2 +- examples/system/flake.lock | 8 +++---- examples/system/flake.nix | 10 ++++----- flake.nix | 28 +++++++++++------------ src/bin/activate.rs | 6 ++--- src/lib.rs | 2 +- src/push.rs | 8 +++---- 13 files changed, 88 insertions(+), 88 deletions(-) diff --git a/.reuse/dep5 b/.reuse/dep5 index d5d62567..f81eda8a 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -1,7 +1,7 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: deploy-rs +Upstream-Name: yeet Upstream-Contact: Serokell -Source: https://github.com/serokell/deploy-rs +Source: https://github.com/serokell/yeet # Sample paragraph, commented out: # diff --git a/Cargo.lock b/Cargo.lock index 08ac3bfc..9561ebbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -131,29 +131,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "deploy-rs" -version = "0.1.0" -dependencies = [ - "clap", - "flexi_logger", - "fork", - "futures-util", - "log", - "merge", - "notify", - "rnix", - "serde", - "serde_json", - "signal-hook", - "smol_str", - "thiserror", - "tokio", - "toml", - "whoami", - "yn", -] - [[package]] name = "filetime" version = "0.2.13" @@ -1083,6 +1060,29 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71" +[[package]] +name = "yeet" +version = "0.1.0" +dependencies = [ + "clap", + "flexi_logger", + "fork", + "futures-util", + "log", + "merge", + "notify", + "rnix", + "serde", + "serde_json", + "signal-hook", + "smol_str", + "thiserror", + "tokio", + "toml", + "whoami", + "yn", +] + [[package]] name = "yn" version = "0.1.1" diff --git a/Cargo.toml b/Cargo.toml index 0ded1259..efc028aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MPL-2.0 [package] -name = "deploy-rs" +name = "yeet" version = "0.1.0" authors = ["notgne2 ", "Serokell "] edition = "2018" @@ -30,7 +30,7 @@ yn = "0.1" # smol_str is required by rnix, but 0.1.17 doesn't build on rustc # 1.45.2 (shipped in nixos-20.09); it requires rustc 1.46.0. See -# : +# : smol_str = "=0.1.16" diff --git a/README.md b/README.md index acd2b7f3..7e472b3e 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,13 @@ SPDX-FileCopyrightText: 2021 Yannik Sander SPDX-License-Identifier: MPL-2.0 --> -![deploy-rs logo](./docs/logo.svg "deploy-rs") +![yeet logo](./docs/logo.svg "yeet") --- A Simple, multi-profile Nix-flake deploy tool. -Questions? Need help? Join us on Matrix: [`#deploy-rs:matrix.org`](https://matrix.to/#/#deploy-rs:matrix.org) +Questions? Need help? Join us on Matrix: [`#yeet:matrix.org`](https://matrix.to/#/#yeet:matrix.org) ## Usage @@ -26,7 +26,7 @@ If your profile or node name has a . in it, simply wrap it in quotes, and the fl Any "extra" arguments will be passed into the Nix calls, so for instance to deploy an impure profile, you may use `deploy . -- --impure` (note the explicit flake path is necessary for doing this). You can try out this tool easily with `nix run`: -- `nix run github:serokell/deploy-rs your-flake` +- `nix run github:serokell/yeet your-flake` In you want to deploy multiple flakes or a subset of profiles with one invocation, instead of calling `deploy ` you can issue `deploy --targets [ ...]` where `` is supposed to take the same format as discussed before. @@ -40,7 +40,7 @@ There is also an `activate` binary though this should be ignored, it is only use ## Ideas -`deploy-rs` is a simple Rust program that will take a Nix flake and use it to deploy any of your defined profiles to your nodes. This is _strongly_ based off of [serokell/deploy](https://github.com/serokell/deploy), designed to replace it and expand upon it. +`yeet` is a simple Rust program that will take a Nix flake and use it to deploy any of your defined profiles to your nodes. This is _strongly_ based off of [serokell/deploy](https://github.com/serokell/deploy), designed to replace it and expand upon it. ### Multi-profile @@ -54,22 +54,22 @@ There is a built-in feature to prevent you making changes that might render your ### Overall usage -`deploy-rs` is designed to be used with Nix flakes (this currently requires an unstable version of Nix to work with). There is a Flake-less mode of operation which will automatically be used if your available Nix version does not support flakes, however you will likely want to use a flake anyway, just with `flake-compat` (see [this wiki page](https://nixos.wiki/wiki/Flakes) for usage). +`yeet` is designed to be used with Nix flakes (this currently requires an unstable version of Nix to work with). There is a Flake-less mode of operation which will automatically be used if your available Nix version does not support flakes, however you will likely want to use a flake anyway, just with `flake-compat` (see [this wiki page](https://nixos.wiki/wiki/Flakes) for usage). -`deploy-rs` also outputs a `lib` attribute, with tools used to make your definitions simpler and safer, including `deploy-rs.lib.${system}.activate` (see later section "Profile"), and `deploy-rs.lib.${system}.deployChecks` which will let `nix flake check` ensure your deployment is defined correctly. +`yeet` also outputs a `lib` attribute, with tools used to make your definitions simpler and safer, including `yeet.lib.${system}.activate` (see later section "Profile"), and `yeet.lib.${system}.deployChecks` which will let `nix flake check` ensure your deployment is defined correctly. -There are full working deploy-rs Nix expressions in the [examples folder](./examples), and there is a JSON schema [here](./interface.json) which is used internally by the `deployChecks` mentioned above to validate your expressions. +There are full working yeet Nix expressions in the [examples folder](./examples), and there is a JSON schema [here](./interface.json) which is used internally by the `deployChecks` mentioned above to validate your expressions. -A basic example of a flake that works with `deploy-rs` and deploys a simple NixOS configuration could look like this +A basic example of a flake that works with `yeet` and deploys a simple NixOS configuration could look like this ```nix { description = "Deployment for my server cluster"; - # For accessing `deploy-rs`'s utility Nix functions - inputs.deploy-rs.url = "github:serokell/deploy-rs"; + # For accessing `yeet`'s utility Nix functions + inputs.yeet.url = "github:serokell/yeet"; - outputs = { self, nixpkgs, deploy-rs }: { + outputs = { self, nixpkgs, yeet }: { nixosConfigurations.some-random-system = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ./some-random-system/configuration.nix ]; @@ -77,25 +77,25 @@ A basic example of a flake that works with `deploy-rs` and deploys a simple NixO deploy.nodes.some-random-system.profiles.system = { user = "root"; - path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.some-random-system; + path = yeet.lib.x86_64-linux.activate.nixos self.nixosConfigurations.some-random-system; }; # This is highly advised, and will prevent many possible mistakes - checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; + checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) yeet.lib; }; } ``` ### Profile -This is the core of how `deploy-rs` was designed, any number of these can run on a node, as any user (see further down for specifying user information). If you want to mimic the behaviour of traditional tools like NixOps or Morph, try just defining one `profile` called `system`, as root, containing a nixosSystem, and you can even similarly use [home-manager](https://github.com/nix-community/home-manager) on any non-privileged user. +This is the core of how `yeet` was designed, any number of these can run on a node, as any user (see further down for specifying user information). If you want to mimic the behaviour of traditional tools like NixOps or Morph, try just defining one `profile` called `system`, as root, containing a nixosSystem, and you can even similarly use [home-manager](https://github.com/nix-community/home-manager) on any non-privileged user. ```nix { - # A derivation containing your required software, and a script to activate it in `${path}/deploy-rs-activate` - # For ease of use, `deploy-rs` provides a function to easily add the required activation script to any derivation + # A derivation containing your required software, and a script to activate it in `${path}/yeet-activate` + # For ease of use, `yeet` provides a function to easily add the required activation script to any derivation # Both the working directory and `$PROFILE` will point to `profilePath` - path = deploy-rs.lib.x86_64-linux.activate.custom pkgs.hello "./bin/hello"; + path = yeet.lib.x86_64-linux.activate.custom pkgs.hello "./bin/hello"; # An optional path to where your profile should be installed to, this is useful if you want to use a common profile name across multiple users, but would have conflicts in your node's profile list. # This will default to `"/nix/var/nix/profiles/$PROFILE_NAME` if `user` is root (see: generic options), and `/nix/var/nix/profiles/per-user/$USER/$PROFILE_NAME` if it is not. @@ -151,7 +151,7 @@ This is a set of options that can be put in any of the above definitions, with t ```nix { - # This is the user that deploy-rs will use when connecting. + # This is the user that yeet will use when connecting. # This will default to your own username if not specified anywhere sshUser = "admin"; @@ -174,16 +174,16 @@ This is a set of options that can be put in any of the above definitions, with t # This defaults to `true` magicRollback = true; - # The path which deploy-rs will use for temporary files, this is currently only used by `magicRollback` to create an inotify watcher in for confirmations + # The path which yeet will use for temporary files, this is currently only used by `magicRollback` to create an inotify watcher in for confirmations # If not specified, this will default to `/tmp` # (if `magicRollback` is in use, this _must_ be writable by `user`) - tempPath = "/home/someuser/.deploy-rs"; + tempPath = "/home/someuser/.yeet"; } ``` ## About Serokell -deploy-rs is maintained and funded with ❤️ by [Serokell](https://serokell.io/). +yeet is maintained and funded with ❤️ by [Serokell](https://serokell.io/). The names and logo for Serokell are trademark of Serokell OÜ. We love open source software! See [our other projects](https://serokell.io/community?utm_source=github) or [hire us](https://serokell.io/hire-us?utm_source=github) to design, develop and grow your idea! diff --git a/examples/simple/flake.lock b/examples/simple/flake.lock index fc92f40c..f9515552 100644 --- a/examples/simple/flake.lock +++ b/examples/simple/flake.lock @@ -1,6 +1,6 @@ { "nodes": { - "deploy-rs": { + "yeet": { "inputs": { "flake-compat": "flake-compat", "naersk": "naersk", @@ -11,13 +11,13 @@ "lastModified": 1603740297, "narHash": "sha256-yeTrA8AaLzDFICApX725gQhKoHNI2TCqWAeOl9axVZE=", "owner": "serokell", - "repo": "deploy-rs", + "repo": "yeet", "rev": "426fb3c489dcbb4ccbf98a3ab6a7fe25e71b95ca", "type": "github" }, "original": { "owner": "serokell", - "repo": "deploy-rs", + "repo": "yeet", "type": "github" } }, @@ -90,7 +90,7 @@ }, "root": { "inputs": { - "deploy-rs": "deploy-rs", + "yeet": "yeet", "nixpkgs": "nixpkgs_2" } }, diff --git a/examples/simple/flake.nix b/examples/simple/flake.nix index e5003c79..5073f39a 100644 --- a/examples/simple/flake.nix +++ b/examples/simple/flake.nix @@ -5,17 +5,17 @@ { description = "Deploy GNU hello to localhost"; - inputs.deploy-rs.url = "github:serokell/deploy-rs"; + inputs.yeet.url = "github:serokell/yeet"; - outputs = { self, nixpkgs, deploy-rs }: { + outputs = { self, nixpkgs, yeet }: { deploy.nodes.example = { hostname = "localhost"; profiles.hello = { user = "balsoft"; - path = deploy-rs.lib.x86_64-linux.setActivate nixpkgs.legacyPackages.x86_64-linux.hello "./bin/hello"; + path = yeet.lib.x86_64-linux.setActivate nixpkgs.legacyPackages.x86_64-linux.hello "./bin/hello"; }; }; - checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; + checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) yeet.lib; }; } diff --git a/examples/system/README.md b/examples/system/README.md index 07033e39..4bf5d5c0 100644 --- a/examples/system/README.md +++ b/examples/system/README.md @@ -11,6 +11,6 @@ This is an example of how to deploy a full nixos system with a separate user uni 1. Run bare system from `.#nixosConfigurations.bare` - `nix build .#nixosConfigurations.bare.config.system.build.vm` - `QEMU_NET_OPTS=hostfwd=tcp::2221-:22 ./result/bin/run-bare-system-vm` -2. `nix run github:serokell/deploy-rs` +2. `nix run github:serokell/yeet` 3. ??? 4. PROFIT!!! diff --git a/examples/system/flake.lock b/examples/system/flake.lock index fc92f40c..f9515552 100644 --- a/examples/system/flake.lock +++ b/examples/system/flake.lock @@ -1,6 +1,6 @@ { "nodes": { - "deploy-rs": { + "yeet": { "inputs": { "flake-compat": "flake-compat", "naersk": "naersk", @@ -11,13 +11,13 @@ "lastModified": 1603740297, "narHash": "sha256-yeTrA8AaLzDFICApX725gQhKoHNI2TCqWAeOl9axVZE=", "owner": "serokell", - "repo": "deploy-rs", + "repo": "yeet", "rev": "426fb3c489dcbb4ccbf98a3ab6a7fe25e71b95ca", "type": "github" }, "original": { "owner": "serokell", - "repo": "deploy-rs", + "repo": "yeet", "type": "github" } }, @@ -90,7 +90,7 @@ }, "root": { "inputs": { - "deploy-rs": "deploy-rs", + "yeet": "yeet", "nixpkgs": "nixpkgs_2" } }, diff --git a/examples/system/flake.nix b/examples/system/flake.nix index bcc841c7..4c08d514 100644 --- a/examples/system/flake.nix +++ b/examples/system/flake.nix @@ -5,9 +5,9 @@ { description = "Deploy a full system with hello service as a separate profile"; - inputs.deploy-rs.url = "github:serokell/deploy-rs"; + inputs.yeet.url = "github:serokell/yeet"; - outputs = { self, nixpkgs, deploy-rs }: { + outputs = { self, nixpkgs, yeet }: { nixosConfigurations.example-nixos-system = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ./configuration.nix ]; @@ -30,17 +30,17 @@ system = { sshUser = "admin"; path = - deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.example-nixos-system; + yeet.lib.x86_64-linux.activate.nixos self.nixosConfigurations.example-nixos-system; user = "root"; }; hello = { sshUser = "hello"; - path = deploy-rs.lib.x86_64-linux.activate.custom self.defaultPackage.x86_64-linux "./bin/activate"; + path = yeet.lib.x86_64-linux.activate.custom self.defaultPackage.x86_64-linux "./bin/activate"; user = "hello"; }; }; }; - checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; + checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) yeet.lib; }; } diff --git a/flake.nix b/flake.nix index 03f4a253..2f3540f8 100644 --- a/flake.nix +++ b/flake.nix @@ -33,16 +33,16 @@ }; in { - deploy-rs = { + yeet = { - deploy-rs = naersk-lib.buildPackage (darwinOptions // { + yeet = naersk-lib.buildPackage (darwinOptions // { root = ./.; }) // { meta.description = "A Simple multi-profile Nix-flake deploy tool"; }; lib = rec { setActivate = builtins.trace - "deploy-rs#lib.setActivate is deprecated, use activate.noop, activate.nixos or activate.custom instead" + "yeet#lib.setActivate is deprecated, use activate.noop, activate.nixos or activate.custom instead" activate.custom; activate = rec { @@ -68,7 +68,7 @@ fi ''; executable = true; - destination = "/deploy-rs-activate"; + destination = "/yeet-activate"; }) (final.writeTextFile { name = base.name + "-activate-rs"; @@ -89,7 +89,7 @@ $PROFILE/bin/switch-to-configuration switch - # https://github.com/serokell/deploy-rs/issues/31 + # https://github.com/serokell/yeet/issues/31 ${with base.config.boot.loader; final.lib.optionalString systemd-boot.enable "sed -i '/^default /d' ${efi.efiSysMountPoint}/loader/loader.conf"} @@ -109,13 +109,13 @@ let profiles = builtins.concatLists (final.lib.mapAttrsToList (nodeName: node: final.lib.mapAttrsToList (profileName: profile: [ (toString profile.path) nodeName profileName ]) node.profiles) deploy.nodes); in - final.runCommandNoCC "deploy-rs-check-activate" { } '' + final.runCommandNoCC "yeet-check-activate" { } '' for x in ${builtins.concatStringsSep " " (map (p: builtins.concatStringsSep ":" p) profiles)}; do profile_path=$(echo $x | cut -f1 -d:) node_name=$(echo $x | cut -f2 -d:) profile_name=$(echo $x | cut -f3 -d:) - test -f "$profile_path/deploy-rs-activate" || (echo "#$node_name.$profile_name is missing the deploy-rs-activate activation script" && exit 1); + test -f "$profile_path/yeet-activate" || (echo "#$node_name.$profile_name is missing the yeet-activate activation script" && exit 1); test -f "$profile_path/activate-rs" || (echo "#$node_name.$profile_name is missing the activate-rs activation script" && exit 1); done @@ -132,17 +132,17 @@ pkgs = import nixpkgs { inherit system; overlays = [ self.overlay ]; }; in { - defaultPackage = self.packages."${system}".deploy-rs; - packages.deploy-rs = pkgs.deploy-rs.deploy-rs; + defaultPackage = self.packages."${system}".yeet; + packages.yeet = pkgs.yeet.yeet; - defaultApp = self.apps."${system}".deploy-rs; - apps.deploy-rs = { + defaultApp = self.apps."${system}".yeet; + apps.yeet = { type = "app"; program = "${self.defaultPackage."${system}"}/bin/deploy"; }; devShell = pkgs.mkShell { - inputsFrom = [ self.packages.${system}.deploy-rs ]; + inputsFrom = [ self.packages.${system}.yeet ]; RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; buildInputs = with pkgs; [ nixUnstable @@ -157,9 +157,9 @@ }; checks = { - deploy-rs = self.defaultPackage.${system}.overrideAttrs (super: { doCheck = true; }); + yeet = self.defaultPackage.${system}.overrideAttrs (super: { doCheck = true; }); }; - lib = pkgs.deploy-rs.lib; + lib = pkgs.yeet.lib; }); } diff --git a/src/bin/activate.rs b/src/bin/activate.rs index d0cfbe17..7f2c34d7 100644 --- a/src/bin/activate.rs +++ b/src/bin/activate.rs @@ -23,7 +23,7 @@ use thiserror::Error; use log::{debug, error, info, warn}; -/// Remote activation utility for deploy-rs +/// Remote activation utility for yeet #[derive(Clap, Debug)] #[clap(version = "1.0", author = "Serokell ")] struct Opts { @@ -177,7 +177,7 @@ pub async fn deactivate(profile_path: &str) -> Result<(), DeactivateError> { info!("Attempting to re-activate the last generation"); - let re_activate_exit_status = Command::new(format!("{}/deploy-rs-activate", profile_path)) + let re_activate_exit_status = Command::new(format!("{}/yeet-activate", profile_path)) .env("PROFILE", &profile_path) .current_dir(&profile_path) .status() @@ -393,7 +393,7 @@ pub async fn activate( &profile_path }; - let activate_status = match Command::new(format!("{}/deploy-rs-activate", activation_location)) + let activate_status = match Command::new(format!("{}/yeet-activate", activation_location)) .env("PROFILE", activation_location) .env("DRY_ACTIVATE", if dry_activate { "1" } else { "0" }) .current_dir(activation_location) diff --git a/src/lib.rs b/src/lib.rs index 981ec1ed..64bbf7e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,7 +15,7 @@ use flexi_logger::*; pub fn make_lock_path(temp_path: &str, closure: &str) -> String { let lock_hash = &closure["/nix/store/".len()..closure.find('-').unwrap_or_else(|| closure.len())]; - format!("{}/deploy-rs-canary-{}", temp_path, lock_hash) + format!("{}/yeet-canary-{}", temp_path, lock_hash) } const fn make_emoji(level: log::Level) -> &'static str { diff --git a/src/push.rs b/src/push.rs index 69eba0db..e88adf62 100644 --- a/src/push.rs +++ b/src/push.rs @@ -26,12 +26,12 @@ pub enum PushProfileError { #[error("Nix build command resulted in a bad exit code: {0:?}")] BuildExit(Option), #[error( - "Activation script deploy-rs-activate does not exist in profile.\n\ - Did you forget to use deploy-rs#lib.<...>.activate.<...> on your profile path?" + "Activation script yeet-activate does not exist in profile.\n\ + Did you forget to use yeet#lib.<...>.activate.<...> on your profile path?" )] DeployRsActivateDoesntExist, #[error("Activation script activate-rs does not exist in profile.\n\ - Is there a mismatch in deploy-rs used in the flake you're deploying and deploy-rs command you're running?")] + Is there a mismatch in yeet used in the flake you're deploying and yeet command you're running?")] ActivateRsDoesntExist, #[error("Failed to run Nix sign command: {0}")] Sign(std::io::Error), @@ -136,7 +136,7 @@ pub async fn push_profile(data: PushProfileData<'_>) -> Result<(), PushProfileEr if !Path::new( format!( - "{}/deploy-rs-activate", + "{}/yeet-activate", data.deploy_data.profile.profile_settings.path ) .as_str(), From b3e0c6388aa4162cc6413a8bcb07e0b7c41f63ab Mon Sep 17 00:00:00 2001 From: notgne2 Date: Wed, 4 Aug 2021 01:25:43 -0700 Subject: [PATCH 2/4] Update binary name to yeet --- README.md | 12 +++--- src/bin/{deploy.rs => yeet.rs} | 0 src/cli.rs | 79 ++++++++++++++-------------------- 3 files changed, 39 insertions(+), 52 deletions(-) rename src/bin/{deploy.rs => yeet.rs} (100%) diff --git a/README.md b/README.md index 7e472b3e..911995e1 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ SPDX-License-Identifier: MPL-2.0 A Simple, multi-profile Nix-flake deploy tool. -Questions? Need help? Join us on Matrix: [`#yeet:matrix.org`](https://matrix.to/#/#yeet:matrix.org) +Questions? Need help? Join us on Matrix: [`#yeet:nixos.org`](https://matrix.to/#/#yeet:nixos.org) ## Usage -Basic usage: `deploy [options] `. +Basic usage: `yeet [options] `. Using this method all profiles specified in the given `` will be deployed (taking into account the [`profilesOrder`](#node)). @@ -23,18 +23,18 @@ Using this method all profiles specified in the given `` will be deployed If your profile or node name has a . in it, simply wrap it in quotes, and the flake path in quotes (to avoid shell escaping), for example 'my-flake."myserver.com".system'. -Any "extra" arguments will be passed into the Nix calls, so for instance to deploy an impure profile, you may use `deploy . -- --impure` (note the explicit flake path is necessary for doing this). +Any "extra" arguments will be passed into the Nix calls, so for instance to deploy an impure profile, you may use `yeet . -- --impure` (note the explicit flake path is necessary for doing this). You can try out this tool easily with `nix run`: - `nix run github:serokell/yeet your-flake` -In you want to deploy multiple flakes or a subset of profiles with one invocation, instead of calling `deploy ` you can issue `deploy --targets [ ...]` where `` is supposed to take the same format as discussed before. +In you want to deploy multiple flakes or a subset of profiles with one invocation, instead of calling `yeet ` you can issue `yeet --targets [ ...]` where `` is supposed to take the same format as discussed before. Running in this mode, if any of the deploys fails, the deploy will be aborted and all successful deploys rolled back. `--rollback-succeeded false` can be used to override this behavior, otherwise the `auto-rollback` argument takes precedent. If you require a signing key to push closures to your server, specify the path to it in the `LOCAL_KEY` environment variable. -Check out `deploy --help` for CLI flags! Remember to check there before making one-time changes to things like hostnames. +Check out `yeet --help` for CLI flags! Remember to check there before making one-time changes to things like hostnames. There is also an `activate` binary though this should be ignored, it is only used internally (on the deployed system) and for testing/hacking purposes. @@ -115,7 +115,7 @@ This defines a single node/server, and the profiles you intend it to run. hostname = "my.server.gov"; # An optional list containing the order you want profiles to be deployed. - # This will take effect whenever you run `deploy` without specifying a profile, causing it to deploy every profile automatically. + # This will take effect whenever you run `yeet` without specifying a profile, causing it to deploy every profile automatically. # Any profiles not in this list will still be deployed (in an arbitrary order) after those which are listed profilesOrder = [ "something" "system" ]; diff --git a/src/bin/deploy.rs b/src/bin/yeet.rs similarity index 100% rename from src/bin/deploy.rs rename to src/bin/yeet.rs diff --git a/src/cli.rs b/src/cli.rs index 61890e43..a64c4127 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -8,9 +8,9 @@ use std::io::{stdin, stdout, Write}; use clap::{ArgMatches, Clap, FromArgMatches}; -use crate as deploy; +use crate as yeet; -use self::deploy::{DeployFlake, ParseFlakeError}; +use self::yeet::{DeployFlake, ParseFlakeError}; use futures_util::stream::{StreamExt, TryStreamExt}; use log::{debug, error, info, warn}; use serde::Serialize; @@ -18,7 +18,7 @@ use std::process::Stdio; use thiserror::Error; use tokio::process::Command; -/// Simple Rust rewrite of a simple Nix Flake deployment tool +/// A simple multi-profile Nix-flake deploy tool. #[derive(Clap, Debug, Clone)] #[clap(version = "1.0", author = "Serokell ")] pub struct Opts { @@ -168,9 +168,9 @@ pub enum GetDeploymentDataError { /// Evaluates the Nix in the given `repo` and return the processed Data from it async fn get_deployment_data( supports_flakes: bool, - flakes: &[deploy::DeployFlake<'_>], + flakes: &[yeet::DeployFlake<'_>], extra_build_args: &[String], -) -> Result, GetDeploymentDataError> { +) -> Result, GetDeploymentDataError> { futures_util::stream::iter(flakes).then(|flake| async move { info!("Evaluating flake in {}", flake.repo); @@ -271,11 +271,7 @@ struct PromptPart<'a> { } fn print_deployment( - parts: &[( - &deploy::DeployFlake<'_>, - deploy::DeployData, - deploy::DeployDefs, - )], + parts: &[(&yeet::DeployFlake<'_>, yeet::DeployData, yeet::DeployDefs)], ) -> Result<(), toml::ser::Error> { let mut part_map: HashMap> = HashMap::new(); @@ -314,11 +310,7 @@ pub enum PromptDeploymentError { } fn prompt_deployment( - parts: &[( - &deploy::DeployFlake<'_>, - deploy::DeployData, - deploy::DeployDefs, - )], + parts: &[(&yeet::DeployFlake<'_>, yeet::DeployData, yeet::DeployDefs)], ) -> Result<(), PromptDeploymentError> { print_deployment(parts)?; @@ -368,9 +360,9 @@ fn prompt_deployment( #[derive(Error, Debug)] pub enum RunDeployError { #[error("Failed to deploy profile: {0}")] - DeployProfile(#[from] deploy::deploy::DeployProfileError), + DeployProfile(#[from] yeet::deploy::DeployProfileError), #[error("Failed to push profile: {0}")] - PushProfile(#[from] deploy::push::PushProfileError), + PushProfile(#[from] yeet::push::PushProfileError), #[error("No profile named `{0}` was found")] ProfileNotFound(String), #[error("No node named `{0}` was found")] @@ -378,29 +370,29 @@ pub enum RunDeployError { #[error("Profile was provided without a node name")] ProfileWithoutNode, #[error("Error processing deployment definitions: {0}")] - DeployDataDefs(#[from] deploy::DeployDataDefsError), + DeployDataDefs(#[from] yeet::DeployDataDefsError), #[error("Failed to make printable TOML of deployment: {0}")] TomlFormat(#[from] toml::ser::Error), #[error("{0}")] PromptDeployment(#[from] PromptDeploymentError), #[error("Failed to revoke profile: {0}")] - RevokeProfile(#[from] deploy::deploy::RevokeProfileError), + RevokeProfile(#[from] yeet::deploy::RevokeProfileError), } type ToDeploy<'a> = Vec<( - &'a deploy::DeployFlake<'a>, - &'a deploy::data::Data, - (&'a str, &'a deploy::data::Node), - (&'a str, &'a deploy::data::Profile), + &'a yeet::DeployFlake<'a>, + &'a yeet::data::Data, + (&'a str, &'a yeet::data::Node), + (&'a str, &'a yeet::data::Profile), )>; async fn run_deploy( - deploy_flakes: Vec>, - data: Vec, + deploy_flakes: Vec>, + data: Vec, supports_flakes: bool, check_sigs: bool, interactive: bool, - cmd_overrides: &deploy::CmdOverrides, + cmd_overrides: &yeet::CmdOverrides, keep_result: bool, result_path: Option<&str>, extra_build_args: &[String], @@ -437,7 +429,7 @@ async fn run_deploy( None => return Err(RunDeployError::NodeNotFound(node_name.clone())), }; - let mut profiles_list: Vec<(&str, &deploy::data::Profile)> = Vec::new(); + let mut profiles_list: Vec<(&str, &yeet::data::Profile)> = Vec::new(); for profile_name in [ node.node_settings.profiles_order.iter().collect(), @@ -466,7 +458,7 @@ async fn run_deploy( let mut l = Vec::new(); for (node_name, node) in &data.nodes { - let mut profiles_list: Vec<(&str, &deploy::data::Profile)> = Vec::new(); + let mut profiles_list: Vec<(&str, &yeet::data::Profile)> = Vec::new(); for profile_name in [ node.node_settings.profiles_order.iter().collect(), @@ -507,14 +499,10 @@ async fn run_deploy( .flatten() .collect(); - let mut parts: Vec<( - &deploy::DeployFlake<'_>, - deploy::DeployData, - deploy::DeployDefs, - )> = Vec::new(); + let mut parts: Vec<(&yeet::DeployFlake<'_>, yeet::DeployData, yeet::DeployDefs)> = Vec::new(); for (deploy_flake, data, (node_name, node), (profile_name, profile)) in to_deploy { - let deploy_data = deploy::make_deploy_data( + let deploy_data = yeet::make_deploy_data( &data.generic_settings, node, node_name, @@ -537,7 +525,7 @@ async fn run_deploy( } for (deploy_flake, deploy_data, deploy_defs) in &parts { - deploy::push::push_profile(deploy::push::PushProfileData { + yeet::push::push_profile(yeet::push::PushProfileData { supports_flakes, check_sigs, repo: deploy_flake.repo, @@ -550,15 +538,14 @@ async fn run_deploy( .await?; } - let mut succeeded: Vec<(&deploy::DeployData, &deploy::DeployDefs)> = vec![]; + let mut succeeded: Vec<(&yeet::DeployData, &yeet::DeployDefs)> = vec![]; // Run all deployments // In case of an error rollback any previoulsy made deployment. // Rollbacks adhere to the global seeting to auto_rollback and secondary // the profile's configuration for (_, deploy_data, deploy_defs) in &parts { - if let Err(e) = deploy::deploy::deploy_profile(deploy_data, deploy_defs, dry_activate).await - { + if let Err(e) = yeet::deploy::deploy_profile(deploy_data, deploy_defs, dry_activate).await { error!("{}", e); if dry_activate { info!("dry run, not rolling back"); @@ -570,7 +557,7 @@ async fn run_deploy( // the command line) for (deploy_data, deploy_defs) in &succeeded { if deploy_data.merged_settings.auto_rollback.unwrap_or(true) { - deploy::deploy::revoke(*deploy_data, *deploy_defs).await?; + yeet::deploy::revoke(*deploy_data, *deploy_defs).await?; } } } @@ -585,9 +572,9 @@ async fn run_deploy( #[derive(Error, Debug)] pub enum RunError { #[error("Failed to deploy profile: {0}")] - DeployProfile(#[from] deploy::deploy::DeployProfileError), + DeployProfile(#[from] yeet::deploy::DeployProfileError), #[error("Failed to push profile: {0}")] - PushProfile(#[from] deploy::push::PushProfileError), + PushProfile(#[from] yeet::push::PushProfileError), #[error("Failed to test for flake support: {0}")] FlakeTest(std::io::Error), #[error("Failed to check deployment: {0}")] @@ -595,7 +582,7 @@ pub enum RunError { #[error("Failed to evaluate deployment data: {0}")] GetDeploymentData(#[from] GetDeploymentDataError), #[error("Error parsing flake: {0}")] - ParseFlake(#[from] deploy::ParseFlakeError), + ParseFlake(#[from] yeet::ParseFlakeError), #[error("Error initiating logger: {0}")] Logger(#[from] flexi_logger::FlexiLoggerError), #[error("{0}")] @@ -608,10 +595,10 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> { None => Opts::parse(), }; - deploy::init_logger( + yeet::init_logger( opts.debug_logs, opts.log_dir.as_deref(), - &deploy::LoggerType::Deploy, + &yeet::LoggerType::Deploy, )?; let deploys = opts @@ -621,10 +608,10 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> { let deploy_flakes: Vec = deploys .iter() - .map(|f| deploy::parse_flake(f.as_str())) + .map(|f| yeet::parse_flake(f.as_str())) .collect::, ParseFlakeError>>()?; - let cmd_overrides = deploy::CmdOverrides { + let cmd_overrides = yeet::CmdOverrides { ssh_user: opts.ssh_user, profile_user: opts.profile_user, ssh_opts: opts.ssh_opts, From d7b336d041a33d86fa2c797a69740e150ec9d830 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Wed, 4 Aug 2021 01:28:59 -0700 Subject: [PATCH 3/4] Update library name to yeet --- Cargo.toml | 2 +- src/bin/activate.rs | 12 ++++++------ src/bin/yeet.rs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index efc028aa..8e24d8b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,5 +35,5 @@ smol_str = "=0.1.16" [lib] -name = "deploy" +name = "yeet" path = "src/lib.rs" diff --git a/src/bin/activate.rs b/src/bin/activate.rs index 7f2c34d7..06e61a7b 100644 --- a/src/bin/activate.rs +++ b/src/bin/activate.rs @@ -232,7 +232,7 @@ pub async fn activation_confirmation( confirm_timeout: u16, closure: String, ) -> Result<(), ActivationConfirmationError> { - let lock_path = deploy::make_lock_path(&temp_path, &closure); + let lock_path = yeet::make_lock_path(&temp_path, &closure); debug!("Ensuring parent directory exists for canary file"); @@ -295,7 +295,7 @@ pub enum WaitError { Waiting(#[from] DangerZoneError), } pub async fn wait(temp_path: String, closure: String) -> Result<(), WaitError> { - let lock_path = deploy::make_lock_path(&temp_path, &closure); + let lock_path = yeet::make_lock_path(&temp_path, &closure); let (created, done) = mpsc::channel(1); @@ -460,13 +460,13 @@ async fn main() -> Result<(), Box> { let opts: Opts = Opts::parse(); - deploy::init_logger( + yeet::init_logger( opts.debug_logs, opts.log_dir.as_deref(), &match opts.subcmd { - SubCommand::Activate(_) => deploy::LoggerType::Activate, - SubCommand::Wait(_) => deploy::LoggerType::Wait, - SubCommand::Revoke(_) => deploy::LoggerType::Revoke, + SubCommand::Activate(_) => yeet::LoggerType::Activate, + SubCommand::Wait(_) => yeet::LoggerType::Wait, + SubCommand::Revoke(_) => yeet::LoggerType::Revoke, }, )?; diff --git a/src/bin/yeet.rs b/src/bin/yeet.rs index e924dc94..86371f84 100644 --- a/src/bin/yeet.rs +++ b/src/bin/yeet.rs @@ -3,8 +3,8 @@ // // SPDX-License-Identifier: MPL-2.0 -use deploy::cli; use log::error; +use yeet::cli; #[tokio::main] async fn main() -> Result<(), Box> { From 7690e5a46e00166b096387c98dadfd1a1e443309 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Wed, 4 Aug 2021 01:46:37 -0700 Subject: [PATCH 4/4] Alias old attributes and binary --- flake.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 2f3540f8..5c70e8f7 100644 --- a/flake.nix +++ b/flake.nix @@ -37,6 +37,7 @@ yeet = naersk-lib.buildPackage (darwinOptions // { root = ./.; + overrideMain = super: super // { postInstall = "ln -s $out/bin/yeet $out/bin/deploy"; }; }) // { meta.description = "A Simple multi-profile Nix-flake deploy tool"; }; lib = rec { @@ -135,12 +136,16 @@ defaultPackage = self.packages."${system}".yeet; packages.yeet = pkgs.yeet.yeet; + packages.deploy-rs = builtins.trace "`packages.deploy-rs` has been renamed, please use `packages.yeet` instead" self.packages."${system}".yeet; + defaultApp = self.apps."${system}".yeet; apps.yeet = { type = "app"; - program = "${self.defaultPackage."${system}"}/bin/deploy"; + program = "${self.defaultPackage."${system}"}/bin/yeet"; }; + apps.deploy-rs = builtins.trace "`apps.deploy-rs` has been renamed, please use `apps.yeet` instead" self.packages."${system}".yeet; + devShell = pkgs.mkShell { inputsFrom = [ self.packages.${system}.yeet ]; RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";