Files
nixpkgs/pkgs/by-name/pg/pghero/update.nix
Silvan Mosberger 667d42c00d treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev 57b193d8dd
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:27:17 +01:00

63 lines
1.2 KiB
Nix

{
lib,
writeShellScript,
git,
nix,
bundler,
bundix,
coreutils,
common-updater-scripts,
}:
writeShellScript "update-script" ''
set -eu
PATH=${
lib.makeBinPath [
git
nix
bundler
bundix
coreutils
common-updater-scripts
]
}
nix() {
command nix --extra-experimental-features nix-command "$@"
}
bundle() {
BUNDLE_FORCE_RUBY_PLATFORM=1 command bundle "$@"
}
attrPath=''${UPDATE_NIX_ATTR_PATH:-pghero}
toplevel=$(git rev-parse --show-toplevel)
position=$(nix eval --file "$toplevel" --raw "$attrPath.meta.position")
gemdir=$(dirname "$position")
cd "$gemdir"
tempdir=$(mktemp -d)
cleanup() {
rc=$?
rm -r -- "$tempdir" || true
exit $rc
}
trap cleanup EXIT
cp gemset.nix "$tempdir"
bundle lock --update --lockfile="$tempdir"/Gemfile.lock
bundix --lockfile="$tempdir"/Gemfile.lock --gemset="$tempdir"/gemset.nix
oldVersion=''${UPDATE_NIX_OLD_VERSION-}
newVersion=$(nix eval --file "$tempdir"/gemset.nix --raw pghero.version)
if [ "$oldVersion" = "$newVersion" ]; then
exit
fi
cp "$tempdir"/{Gemfile.lock,gemset.nix} .
cd "$toplevel"
update-source-version "$attrPath" "$newVersion" --file="$gemdir"/package.nix --ignore-same-hash
''