feat: add support for homeConfigurations
This enables support for `homeConfigurations` (the Home Manager standalone configurations).
This commit is contained in:
parent
b7e76df813
commit
838f205020
2 changed files with 51 additions and 8 deletions
|
@ -64,7 +64,7 @@ markdown_from_report() {
|
||||||
|
|
||||||
<details><summary><b>Tips on reading this data</b></summary>
|
<details><summary><b>Tips on reading this data</b></summary>
|
||||||
|
|
||||||
- For NixOS configurations you generally care only about the `Size` (closure size/size on disk).
|
- For NixOS/Home-Manager configurations you generally care only about the `Size` (closure size/size on disk).
|
||||||
- Reduce the `Size` by disabling unneeded services/default packages.
|
- Reduce the `Size` by disabling unneeded services/default packages.
|
||||||
- For Packages you care about both the `Size` and the `NAR Size`.
|
- For Packages you care about both the `Size` and the `NAR Size`.
|
||||||
- Reduce the `NAR Size` by reducing the size of the build outputs, e.g. don't copy unnecessary data to the $out dir, optimize binaries for size, etc.
|
- Reduce the `NAR Size` by reducing the size of the build outputs, e.g. don't copy unnecessary data to the $out dir, optimize binaries for size, etc.
|
||||||
|
@ -87,6 +87,16 @@ markdown_from_report() {
|
||||||
echo "$compare" | json_to_md_rows_and_change "nixosConfigurations"
|
echo "$compare" | json_to_md_rows_and_change "nixosConfigurations"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
if echo "$compare" | has_elements 'homeConfigurations'; then
|
||||||
|
cat <<-"EOF"
|
||||||
|
## Home Manager Configurations
|
||||||
|
|
||||||
|
| Name | Size | Size Change | NAR Size | NAR Size Change |
|
||||||
|
|------|-----:|------------:|---------:|----------------:|
|
||||||
|
EOF
|
||||||
|
echo "$compare" | json_to_md_rows_and_change "homeConfigurations"
|
||||||
|
echo
|
||||||
|
fi
|
||||||
if echo "$compare" | has_elements 'packages'; then
|
if echo "$compare" | has_elements 'packages'; then
|
||||||
cat <<-"EOF"
|
cat <<-"EOF"
|
||||||
## Packages
|
## Packages
|
||||||
|
@ -108,6 +118,16 @@ markdown_from_report() {
|
||||||
json_to_md_rows "nixosConfigurations" "$1"
|
json_to_md_rows "nixosConfigurations" "$1"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
if has_elements 'homeConfigurations' "$1"; then
|
||||||
|
cat <<-"EOF"
|
||||||
|
## Home Manger Configurations
|
||||||
|
|
||||||
|
| Name | Size | NAR Size |
|
||||||
|
|------|-----:|---------:|
|
||||||
|
EOF
|
||||||
|
json_to_md_rows "homeConfigurations" "$1"
|
||||||
|
echo
|
||||||
|
fi
|
||||||
if has_elements 'packages' "$1"; then
|
if has_elements 'packages' "$1"; then
|
||||||
cat <<-"EOF"
|
cat <<-"EOF"
|
||||||
## Packages
|
## Packages
|
||||||
|
|
|
@ -20,13 +20,22 @@ packages=$(
|
||||||
log "$packages"
|
log "$packages"
|
||||||
endgroup
|
endgroup
|
||||||
|
|
||||||
|
group 'Show Home Manager Configurations'
|
||||||
|
hmConfigs=$(
|
||||||
|
jq --raw-output '.homeConfigurations | select(. != null) | keys[]' <<-EOF
|
||||||
|
$flake_info
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
log "$hmConfigs"
|
||||||
|
endgroup
|
||||||
|
|
||||||
group 'Show NixOS Configurations'
|
group 'Show NixOS Configurations'
|
||||||
configurations=$(
|
nixosConfigs=$(
|
||||||
jq --raw-output '.nixosConfigurations | select(. != null) | keys[]' <<-EOF
|
jq --raw-output '.nixosConfigurations | select(. != null) | keys[]' <<-EOF
|
||||||
$flake_info
|
$flake_info
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
log "$configurations"
|
log "$nixosConfigs"
|
||||||
endgroup
|
endgroup
|
||||||
|
|
||||||
pkgs_json() {
|
pkgs_json() {
|
||||||
|
@ -42,10 +51,22 @@ pkgs_json() {
|
||||||
endgroup
|
endgroup
|
||||||
}
|
}
|
||||||
|
|
||||||
configs_json() {
|
hm_configs_json() {
|
||||||
|
group 'Building Home Manager configurations'
|
||||||
|
trap endgroup RETURN
|
||||||
|
for config in $hmConfigs; do
|
||||||
|
log "Building $config"
|
||||||
|
path=$(nix build --print-out-paths ".#homeConfigurations.$config.activationPackages")
|
||||||
|
log "Calculating size of $config"
|
||||||
|
nix path-info --closure-size --json "$path" |
|
||||||
|
jq --compact-output --arg pkg "$config" '.[] | {"name": $pkg, "size": .closureSize, "narSize": .narSize}'
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
nixos_configs_json() {
|
||||||
group 'Building NixOS configurations'
|
group 'Building NixOS configurations'
|
||||||
trap endgroup RETURN
|
trap endgroup RETURN
|
||||||
for config in $configurations; do
|
for config in $nixosConfigs; do
|
||||||
log "Building $config"
|
log "Building $config"
|
||||||
path=$(nix build --print-out-paths ".#nixosConfigurations.$config.config.system.build.toplevel")
|
path=$(nix build --print-out-paths ".#nixosConfigurations.$config.config.system.build.toplevel")
|
||||||
log "Calculating size of $config"
|
log "Calculating size of $config"
|
||||||
|
@ -55,9 +76,11 @@ configs_json() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pkgs=$(pkgs_json | jq --slurp '.')
|
pkgs=$(pkgs_json | jq --slurp '.')
|
||||||
configs=$(configs_json | jq --slurp '.')
|
hmConfigs=$(hm_configs_json | jq --slurp '.')
|
||||||
|
nixosConfigs=$(nixos_configs_json | jq --slurp '.')
|
||||||
|
|
||||||
echo "{}" | jq \
|
echo "{}" | jq \
|
||||||
--argjson pkgs "$pkgs" \
|
--argjson pkgs "$pkgs" \
|
||||||
--argjson configs "$configs" \
|
--argjson nixosConfigs "$nixosConfigs" \
|
||||||
'{"packages": $pkgs, "nixosConfigurations": $configs}'
|
--argjson hmConfigs "$hmConfigs" \
|
||||||
|
'{"packages": $pkgs, "nixosConfigurations": $nixosConfigs, "homeConfigurations": $hmConfigs}'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue