From 66fc43f7ca62159ac5faf8ce34e2cd0eb0edba15 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 16 Mar 2023 11:45:04 +0000 Subject: [PATCH] pkgs: diff-flake: 0.3.1 -> 0.4.0 Add home-manager configurations. --- pkgs/diff-flake/default.nix | 2 +- pkgs/diff-flake/diff-flake | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pkgs/diff-flake/default.nix b/pkgs/diff-flake/default.nix index ce38934..429b09a 100644 --- a/pkgs/diff-flake/default.nix +++ b/pkgs/diff-flake/default.nix @@ -1,7 +1,7 @@ { lib, coreutils, git, gnused, makeWrapper, stdenvNoCC }: stdenvNoCC.mkDerivation rec { pname = "diff-flake"; - version = "0.3.1"; + version = "0.4.0"; src = ./diff-flake; diff --git a/pkgs/diff-flake/diff-flake b/pkgs/diff-flake/diff-flake index fa4a88f..2dfc67d 100755 --- a/pkgs/diff-flake/diff-flake +++ b/pkgs/diff-flake/diff-flake @@ -29,6 +29,10 @@ add_shell() { FLAKE_OUTPUTS+=("devShells.$(current_system).\"$1\".inputDerivation") } +add_home() { + FLAKE_OUTPUTS+=("homeConfigurations.$1.activationPackage") +} + add_host() { FLAKE_OUTPUTS+=("nixosConfigurations.$1.config.system.build.toplevel") } @@ -50,6 +54,10 @@ usage() { print_err " -p, --previous-rev" print_err " which git revision should be considered the 'previous' state," print_err " defaults to HEAD~" + print_err " --home [name]" + print_err " specify the name of a home-manager output configuration whose" + print_err " closure should be diffed, can be used multiple times" + print_err " if no configuration name is given, defaults to current username" print_err " --host [name]" print_err " specify the name of a NixOS output configuration whose" print_err " closure should be diffed, can be used multiple times" @@ -93,6 +101,14 @@ parse_args() { PREVIOUS_REV="$(git rev-parse "$1")" shift ;; + --home) + if [ $# -gt 0 ] && ! is_option "$1"; then + add_home "$1" + shift + else + add_home "$USER" + fi + ;; --host) if [ $# -gt 0 ] && ! is_option "$1"; then add_host "$1" @@ -122,6 +138,12 @@ parse_args() { done } +list_home_configurations() { + nix eval '.#homeConfigurations' \ + --apply 'attrs: with builtins; concatStringsSep "\n" (attrNames attrs)' \ + --raw +} + list_nixos_configurations() { nix eval '.#nixosConfigurations' \ --apply 'attrs: with builtins; concatStringsSep "\n" (attrNames attrs)' \ @@ -153,6 +175,9 @@ diff_output() { parse_args "$@" if [ "${#FLAKE_OUTPUTS[@]}" -eq 0 ]; then + for home in $(list_home_configurations); do + add_home "$home" + done for host in $(list_nixos_configurations); do add_host "$host" done