From f14121f9bb88ae90b89cda2018613d404ab72c3a Mon Sep 17 00:00:00 2001 From: Solene Rapenne Date: Thu, 29 Sep 2022 18:12:53 +0200 Subject: [PATCH] bento: add command diff --- bento | 43 ++++++++++++++++++++++++++++++++++++++++++- doc/how-to.md | 28 ++++++++++++++++++++++++++++ doc/reference.md | 7 +++++-- 3 files changed, 75 insertions(+), 3 deletions(-) diff --git a/bento b/bento index ed1785d..608c965 100755 --- a/bento +++ b/bento @@ -5,7 +5,7 @@ TIMEOUT=20 # FUNCTION LIBRARIES usage() { cat < max) { max = length($1) }} END { print max }') @@ -731,4 +763,13 @@ then exit 0 fi +# show a diff of closures +if [ "$1" = "diff" ] +then + . ./config.sh + version_diff "$NAME" + + exit 0 +fi + usage diff --git a/doc/how-to.md b/doc/how-to.md index 96ee19d..be9a411 100644 --- a/doc/how-to.md +++ b/doc/how-to.md @@ -87,3 +87,31 @@ Using `bento status` you can track the current state of each hosts (time since l With `bento flake-update` you can easily update your flakes recursively to the latest version. A parameter can be added to only update a given source with, i.e to update all nixpkgs in the flakes `bento flake-update nixpkgs`. + +# Show differences between a running system version and its new version + +With `env NAME=my-laptop bento diff` you can display the differences of packages between what `my-laptop` is running and its new version. + +The output should look like this: + +``` +Changes in x1 between p50qql7f42rl0fccdwxw45k21pnqb9ii-nixos-system-x1-22.11.20220921.d6490a0 and 7zfxxddmg8l6qc6bksar5gm62ylwsdv5-nixos-system-x1-22.11.20220927.7e52b35 +bind: 9.18.6 → 9.18.7 +cpupower: 5.19.9, 5.19.9_fish → 5.19.11, 5.19.11_fish +gh: 2.15.0, 2.15.0_fish → 2.16.1, 2.16.1_fish +imagemagick: 7.1.0-48 → 7.1.0-49, +18.0 KiB +initrd-linux: 5.19.9 → 5.19.11 +libblockdev: 2.26 → 2.28 +libbytesize: 2.6 → 2.7 +libdmtx: 0.7.5 → 0.7.7 +linux: 5.19.9, 5.19.9-modules → 5.19.11, 5.19.11-modules, +126.6 KiB +man: -11.8 KiB +nixos: +12.5 KiB +nixos-system-x1: 22.11.20220921.d6490a0 → 22.11.20220927.7e52b35 +opencv: 4.5.4 → 4.6.0, +1901.6 KiB +plasma-workspace: +62.4 KiB +root-authorized_keys: ∅ → ε +source: +701.9 KiB +systemsettings: +62.6 KiB +------------- +``` diff --git a/doc/reference.md b/doc/reference.md index 8eb561b..70e76ab 100644 --- a/doc/reference.md +++ b/doc/reference.md @@ -4,7 +4,10 @@ - create the layout for bento in the current directory (only work from flakes) - `bento deploy` - - build configurations and deploy configuration files, requires to be root + - build configurations and deploy configuration files, requires to be root. + +- `bento diff` + - display the difference between each remote system version and their new version. Supports `NAME` environment variable. - `bento build [dry-run|build|test|switch]` - dry-build or build configurations. Using `test` or `switch`, can be used to apply a configuration locally. Default is `build`. @@ -31,7 +34,7 @@ A local file `config.sh` is required for Bento, it contains variable used to gen `bento` is using the following environment variables as configuration: - `BENTO_DIR`: contains the path of a bento directory, so you can run `bento` commands from anywhere -- `NAME`: contains machine names (flake config or directory in `hosts/`) to restrict commands `deploy` and `build` to this machine only +- `NAME`: contains machine names (flake config or directory in `hosts/`) to restrict commands `deploy`, `diff` and `build` to this machine only - `VERBOSE`: if defined to anything, display `nixos-rebuild` output for local builds done with `bento build` or `bento deploy` # Self update mode