Compare commits

..

No commits in common. "464ed92b00cf4bab860d92d3787abdfe54543e52" and "5413bf7fbb8d9392be4b685296ae19908c993350" have entirely different histories.

2 changed files with 17 additions and 48 deletions

View file

@ -1,7 +1,7 @@
{ lib, coreutils, git, gnused, makeWrapper, stdenvNoCC }: { lib, coreutils, git, gnused, makeWrapper, stdenvNoCC }:
stdenvNoCC.mkDerivation rec { stdenvNoCC.mkDerivation rec {
pname = "diff-flake"; pname = "diff-flake";
version = "0.4.0"; version = "0.2.0";
src = ./diff-flake; src = ./diff-flake;

View file

@ -20,21 +20,19 @@ sanitize_output() {
fi fi
} }
current_system() { add_shell() {
nix eval --raw --impure --expr 'builtins.currentSystem' local SYSTEM
} if [ $# -gt 0 ] && [ -n "$1" ]; then
SYSTEM="$1"
add_home() { else
FLAKE_OUTPUTS+=("homeConfigurations.\"$1\".activationPackage") SYSTEM="$(nix eval --raw --impure --expr 'builtins.currentSystem')"
fi
# Use 'inputDerivation' attribute to make sure that it is build-able
FLAKE_OUTPUTS+=("devShells.$SYSTEM.default.inputDerivation")
} }
add_host() { add_host() {
FLAKE_OUTPUTS+=("nixosConfigurations.\"$1\".config.system.build.toplevel") FLAKE_OUTPUTS+=("nixosConfigurations.$1.config.system.build.toplevel")
}
add_shell() {
# Use 'inputDerivation' attribute to make sure that it is build-able
FLAKE_OUTPUTS+=("devShells.\"$(current_system)\".\"$1\".inputDerivation")
} }
usage() { usage() {
@ -54,21 +52,17 @@ usage() {
print_err " -p, --previous-rev" print_err " -p, --previous-rev"
print_err " which git revision should be considered the 'previous' state," print_err " which git revision should be considered the 'previous' state,"
print_err " defaults to HEAD~" 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 " --host [name]"
print_err " specify the name of a NixOS output configuration whose" print_err " specify the name of a NixOS output configuration whose"
print_err " closure should be diffed, can be used multiple times" print_err " closure should be diffed, can be used multiple times"
print_err " if no host name is given, defaults to current hostname" print_err " if no host name is given, defaults to current hostname"
print_err " --shell [name]" print_err " --shell [system]"
print_err " specify a specific devShell configuration name whose closure" print_err " specify a specific system's devShell output whose closure"
print_err " should be diffed, can be used multiple times" print_err " should be diffed, can be used multiple times"
print_err " if no name is given, defaults to 'default'" print_err " if no system is given, defaults to current system"
print_err "" print_err ""
print_err "when no flake outputs are specified, automatically queries for" print_err "when no flake outputs are specified, automatically queries for"
print_err "all NixOS configurations, and devShells for current system" print_err "all NixOS configurations, and devShell for current system"
} }
is_option() { is_option() {
@ -101,14 +95,6 @@ parse_args() {
PREVIOUS_REV="$(git rev-parse "$1")" PREVIOUS_REV="$(git rev-parse "$1")"
shift shift
;; ;;
--home)
if [ $# -gt 0 ] && ! is_option "$1"; then
add_home "$1"
shift
else
add_home "$USER"
fi
;;
--host) --host)
if [ $# -gt 0 ] && ! is_option "$1"; then if [ $# -gt 0 ] && ! is_option "$1"; then
add_host "$1" add_host "$1"
@ -122,7 +108,7 @@ parse_args() {
add_shell "$1" add_shell "$1"
shift shift
else else
add_shell "default" add_shell
fi fi
;; ;;
--) --)
@ -138,24 +124,12 @@ parse_args() {
done done
} }
list_home_configurations() {
nix eval '.#homeConfigurations' \
--apply 'attrs: with builtins; concatStringsSep "\n" (attrNames attrs)' \
--raw
}
list_nixos_configurations() { list_nixos_configurations() {
nix eval '.#nixosConfigurations' \ nix eval '.#nixosConfigurations' \
--apply 'attrs: with builtins; concatStringsSep "\n" (attrNames attrs)' \ --apply 'attrs: with builtins; concatStringsSep "\n" (attrNames attrs)' \
--raw --raw
} }
list_dev_shells() {
nix eval ".#devShells.\"$(current_system)\"" \
--apply 'attrs: with builtins; concatStringsSep "\n" (attrNames attrs)' \
--raw
}
diff_output() { diff_output() {
local PREV NEW; local PREV NEW;
PREV="$(mktemp --dry-run)" PREV="$(mktemp --dry-run)"
@ -175,15 +149,10 @@ diff_output() {
parse_args "$@" parse_args "$@"
if [ "${#FLAKE_OUTPUTS[@]}" -eq 0 ]; then if [ "${#FLAKE_OUTPUTS[@]}" -eq 0 ]; then
for home in $(list_home_configurations); do
add_home "$home"
done
for host in $(list_nixos_configurations); do for host in $(list_nixos_configurations); do
add_host "$host" add_host "$host"
done done
for shell in $(list_dev_shells); do add_shell
add_shell "$shell"
done
fi fi
for out in "${FLAKE_OUTPUTS[@]}"; do for out in "${FLAKE_OUTPUTS[@]}"; do