Skip to content

treewide: substitute pname for strings (by-name)#410679

Merged
philiptaron merged 1 commit intoNixOS:masterfrom
pbsds:migrate-pname-1748121663
May 29, 2025
Merged

treewide: substitute pname for strings (by-name)#410679
philiptaron merged 1 commit intoNixOS:masterfrom
pbsds:migrate-pname-1748121663

Conversation

@pbsds
Copy link
Member

@pbsds pbsds commented May 25, 2025

Repeat of #387769, this time also limited to pkgs/by-name, part of #346453
I removed the concurrency due to git-wait only detecting concurent access and error but not actually waiting for it to be resolved.

Should be zero rebuilds.

All candidates were made using:

#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=. --pure -i bash -p ripgrep sd jq git git-wait lix util-linux

export NIX_PATH= # no nixpkgs-overlays plz
export NIXPKGS_ALLOW_UNFREE=1
export NIXPKGS_ALLOW_INSECURE=1
export NIXPKGS_ALLOW_BROKEN=1

git-wait restore .

test -s packages.json || ( set -x;
  time nix-env --extra-experimental-features no-url-literals --option system x86_64-linux -f ./. -qaP --json --meta --drv-path --out-path --show-trace --no-allow-import-from-derivation --arg config '{ allowAliases = false; }' > packages.json
)

list_attrpath_fname_col() {
    jq <packages.json 'to_entries[] | select(.value.meta.position==null|not) | "\(.key)\t\(.value.meta.position)"' -r |
        sed -e "s#\t$(realpath .)/#\t#" |
        sed -e 's#:\([0-9]*\)$#\t\1#' |
        grep . |
        grep -iv haskell |
        grep -iv /top-level/ |
        grep -iv chicken |
        grep pkgs/by-name/ |
        grep -iv build |
        grep -E '/(package|default)\.nix'
}

while read attrpath fname col; do
    grep -qE 'repo *= *("\$\{pname\}"|pname);' "$fname" || continue

    echo | (

        echo "$attrpath"
        data="$(nix eval --log-format raw --impure --expr 'with import ./. {}; lib.attrsets.filterAttrsRecursive (n: v: !lib.isFunction v) { inherit ('"$attrpath"') pname drvPath passthru meta; drvPath2='"$attrpath"'.src.drvPath; }' --json)" || exit
        test -n "$data" || exit
        pname="$(jq <<<"$data" .pname -r)"
        test -n "$pname" || exit

        (set -x
            sd -F '${pname}'  "$pname"         "$fname"
            sd -F ' = pname;' " = \"$pname\";" "$fname"
        )

        data2="$(nix eval --log-format raw --impure --expr 'with import ./. {}; lib.attrsets.filterAttrsRecursive (n: v: !lib.isFunction v) { inherit ('"$attrpath"') pname drvPath passthru meta; drvPath2='"$attrpath"'.src.drvPath; }' --json)"
        if [[ "$data" = "$data2" ]]; then
            (set -x; git-wait add "$fname")
        else
            (set -x; git-wait restore "$fname")
            exit
        fi

        (set -x
            sd -F ' rec {' ' {' "$fname"
        )

        data3="$(nix eval --log-format raw --impure --expr 'with import ./. {}; lib.attrsets.filterAttrsRecursive (n: v: !lib.isFunction v) { inherit ('"$attrpath"') pname drvPath passthru meta; drvPath2='"$attrpath"'.src.drvPath; }' --json 2>/dev/null)"

        if [[ "$data" = "$data3" ]]; then
            (set -x; git-wait add "$fname")
        else
            (set -x; git-wait restore "$fname")
        fi

    )

done < <(list_attrpath_fname_col)

git restore .

time nix-env --extra-experimental-features no-url-literals --option system x86_64-linux -f ./. -qaP --json --meta --drv-path --out-path --show-trace --no-allow-import-from-derivation --arg config '{ allowAliases = false; }' > packages2.json

diff packages{,2}.json is empty, indicating that no package nor src derivation has changed, nor have i introduced any eval failures.
I checked and cherry-picked the changes using GIT_DIFF_OPTS='-u20' git -c interactive.singleKey=true add --patch along to some music. I then tested merging against master, staging and staging-next

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: cinnamon Desktop environment label May 25, 2025
@nix-owners nix-owners bot requested review from mkg20001 and mweinelt May 25, 2025 00:59
@pbsds pbsds requested a review from philiptaron May 25, 2025 01:03
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels May 25, 2025
@pbsds pbsds changed the title treewide: substitute pname for strings treewide: substitute pname for strings (by-name) May 25, 2025
@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one person. label May 27, 2025
@pbsds pbsds force-pushed the migrate-pname-1748121663 branch from 0993d19 to 8ad532e Compare May 27, 2025 21:33
@pbsds pbsds force-pushed the migrate-pname-1748121663 branch from 8ad532e to c4f02ff Compare May 29, 2025 15:04
@philiptaron philiptaron merged commit 7556c0e into NixOS:master May 29, 2025
14 of 17 checks passed
@FliegendeWurst FliegendeWurst mentioned this pull request May 30, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: cinnamon Desktop environment 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants