From b3bc1e31d0fc920cc11a79ed4f4bd202961addfb Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Mon, 14 Jul 2025 13:23:16 +0200 Subject: [PATCH 1/4] nixfmt[-rfc-style]: unstable -> 1.0.0 Also: - Updates the update script to use stable versions going forward - Make pkgs.nixfmt the -rfc-style version and remove the warning - Create a (delayed) warning for the -rfc-style version to encourage switching to pkgs.nixfmt in a couple releases - Add a release note for the above --- doc/release-notes/rl-2511.section.md | 1 + pkgs/by-name/ni/nixfmt-rfc-style/date.txt | 1 - pkgs/by-name/ni/nixfmt-rfc-style/update.sh | 33 ------------------- .../generated-package.nix | 6 ++-- .../{nixfmt-rfc-style => nixfmt}/package.nix | 20 ++++------- pkgs/by-name/ni/nixfmt/update.sh | 27 +++++++++++++++ pkgs/top-level/aliases.nix | 8 ++++- 7 files changed, 44 insertions(+), 52 deletions(-) delete mode 100644 pkgs/by-name/ni/nixfmt-rfc-style/date.txt delete mode 100755 pkgs/by-name/ni/nixfmt-rfc-style/update.sh rename pkgs/by-name/ni/{nixfmt-rfc-style => nixfmt}/generated-package.nix (82%) rename pkgs/by-name/ni/{nixfmt-rfc-style => nixfmt}/package.nix (53%) create mode 100755 pkgs/by-name/ni/nixfmt/update.sh diff --git a/doc/release-notes/rl-2511.section.md b/doc/release-notes/rl-2511.section.md index 1f28d5222632..cff56cf7cc7d 100644 --- a/doc/release-notes/rl-2511.section.md +++ b/doc/release-notes/rl-2511.section.md @@ -8,6 +8,7 @@ this release sets the default march level to `la64v1.0`, covering the desktop and server processors of 3X5000 and newer series. However, embedded chips without LSX (Loongson SIMD eXtension), such as 2K0300 SoC, are not supported. `pkgsCross.loongarch64-linux-embedded` can be used to build software and systems for these platforms. +- The official Nix formatter `nixfmt` is now stable and available as `pkgs.nixfmt`, deprecating the temporary `pkgs.nixfmt-rfc-style` attribute. The classic `nixfmt` will stay available for some more time as `pkgs.nixfmt-classic`. ## Backward Incompatibilities {#sec-nixpkgs-release-25.11-incompatibilities} diff --git a/pkgs/by-name/ni/nixfmt-rfc-style/date.txt b/pkgs/by-name/ni/nixfmt-rfc-style/date.txt deleted file mode 100644 index 24a34eca600b..000000000000 --- a/pkgs/by-name/ni/nixfmt-rfc-style/date.txt +++ /dev/null @@ -1 +0,0 @@ -2025-04-04 diff --git a/pkgs/by-name/ni/nixfmt-rfc-style/update.sh b/pkgs/by-name/ni/nixfmt-rfc-style/update.sh deleted file mode 100755 index 9213c7396452..000000000000 --- a/pkgs/by-name/ni/nixfmt-rfc-style/update.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i bash -p cabal2nix curl jq -# -# This script will update the nixfmt-rfc-style derivation to the latest version using -# cabal2nix. - -set -eo pipefail - -# This is the directory of this update.sh script. -script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -derivation_file="${script_dir}/generated-package.nix" -date_file="${script_dir}/date.txt" - -# This is the latest version of nixfmt-rfc-style branch on GitHub. -new_version=$(curl --silent https://api.github.com/repos/nixos/nixfmt/git/refs/heads/master | jq '.object.sha' --raw-output) -new_date=$(curl --silent https://api.github.com/repos/nixos/nixfmt/git/commits/"$new_version" | jq '.committer.date' --raw-output) - -echo "Updating nixfmt-rfc-style to version $new_date." -echo "Running cabal2nix and outputting to ${derivation_file}..." - -cat > "$derivation_file" << EOF -# This file has been autogenerate with cabal2nix. -# Update via ./update.sh -EOF - -cabal2nix --jailbreak \ - "https://github.com/nixos/nixfmt/archive/${new_version}.tar.gz" \ - >> "$derivation_file" - -date --date="$new_date" -I > "$date_file" - -echo "Finished." diff --git a/pkgs/by-name/ni/nixfmt-rfc-style/generated-package.nix b/pkgs/by-name/ni/nixfmt/generated-package.nix similarity index 82% rename from pkgs/by-name/ni/nixfmt-rfc-style/generated-package.nix rename to pkgs/by-name/ni/nixfmt/generated-package.nix index 1da633e8999d..03e7998038e4 100644 --- a/pkgs/by-name/ni/nixfmt-rfc-style/generated-package.nix +++ b/pkgs/by-name/ni/nixfmt/generated-package.nix @@ -23,10 +23,10 @@ }: mkDerivation { pname = "nixfmt"; - version = "0.6.0"; + version = "1.0.0"; src = fetchzip { - url = "https://github.com/nixos/nixfmt/archive/65af4b69133d19f534d97746c97c2d5b464f43b4.tar.gz"; - sha256 = "0l0w3janvss1n1j7qkcml97zndm2jm2gbrzzs9d8l0ixnrw0cd5r"; + url = "https://github.com/nixos/nixfmt/archive/v1.0.0.tar.gz"; + sha256 = "0iy2p893b2b5y4mvhy0d62675a7nd8fc6jm9mr32v9h2baj9ii3p"; }; isLibrary = true; isExecutable = true; diff --git a/pkgs/by-name/ni/nixfmt-rfc-style/package.nix b/pkgs/by-name/ni/nixfmt/package.nix similarity index 53% rename from pkgs/by-name/ni/nixfmt-rfc-style/package.nix rename to pkgs/by-name/ni/nixfmt/package.nix index 90e659765b68..93a198f73f2a 100644 --- a/pkgs/by-name/ni/nixfmt-rfc-style/package.nix +++ b/pkgs/by-name/ni/nixfmt/package.nix @@ -3,30 +3,22 @@ haskellPackages, lib, runCommand, - nixfmt-rfc-style, + nixfmt, }: let inherit (haskell.lib.compose) overrideCabal justStaticExecutables; - overrides = rec { - version = "unstable-${lib.fileContents ./date.txt}"; - + overrides = { passthru.updateScript = ./update.sh; teams = [ lib.teams.formatter ]; - preBuild = '' - echo -n 'nixpkgs-${version}' > .version - ''; - # These tests can be run with the following command. # - # $ nix-build -A nixfmt-rfc-style.tests - passthru.tests = - runCommand "nixfmt-rfc-style-tests" { nativeBuildInputs = [ nixfmt-rfc-style ]; } - '' - nixfmt --version > $out - ''; + # $ nix-build -A nixfmt.tests + passthru.tests = runCommand "nixfmt-tests" { nativeBuildInputs = [ nixfmt ]; } '' + nixfmt --version > $out + ''; }; raw-pkg = haskellPackages.callPackage ./generated-package.nix { }; in diff --git a/pkgs/by-name/ni/nixfmt/update.sh b/pkgs/by-name/ni/nixfmt/update.sh new file mode 100755 index 000000000000..3a44a0c6279a --- /dev/null +++ b/pkgs/by-name/ni/nixfmt/update.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p cabal2nix curl jq +# +# This script will update the nixfmt derivation to the latest version using +# cabal2nix. + +set -eo pipefail + +# This is the directory of this update.sh script. +script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +derivation_file="${script_dir}/generated-package.nix" + +release_tag=$(curl --silent https://api.github.com/repos/NixOS/nixfmt/releases/latest | jq '.tag_name' --raw-output) + +echo "Updating nixfmt to version $release_tag." +echo "Running cabal2nix and outputting to ${derivation_file}..." + +cat > "$derivation_file" << EOF +# This file has been autogenerate with cabal2nix. +# Update via ./update.sh +EOF + +cabal2nix --jailbreak \ + "https://github.com/nixos/nixfmt/archive/${release_tag}.tar.gz" \ + >> "$derivation_file" + +echo "Finished." diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 9789bd3c3de6..d2cbe7fd7b27 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -1412,7 +1412,13 @@ mapAliases { nixStable = nixVersions.stable; # Added 2022-01-24 nixUnstable = throw "nixUnstable has been removed. For bleeding edge (Nix master, roughly weekly updated) use nixVersions.git, otherwise use nixVersions.latest."; # Converted to throw 2024-04-22 nix_2_3 = nixVersions.nix_2_3; - nixfmt = lib.warnOnInstantiate "nixfmt was renamed to nixfmt-classic. The nixfmt attribute may be used for the new RFC 166-style formatter in the future, which is currently available as nixfmt-rfc-style" nixfmt-classic; # Added 2024-03-31 + nixfmt-rfc-style = + if lib.oldestSupportedReleaseIsAtLeast 2511 then + lib.warnOnInstantiate + "nixfmt-rfc-style is now the same as pkgs.nixfmt which should be used instead." + nixfmt # Added 2025-07-14 + else + nixfmt; # When the nixops_unstable alias is removed, nixops_unstable_minimal can be renamed to nixops_unstable. From d1a4769b38bad1538d8b7aab3d337809f5bb5bd3 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Mon, 14 Jul 2025 16:24:06 +0200 Subject: [PATCH 2/4] treewide: nixfmt-rfc-style -> nixfmt Except: - Instances in documentation, because people in older versions can't switch to nixfmt yet due to it having pointed to nixfmt-classic before - In code that runs based on a CI Nixpkgs version, which is also a bit older still - In update script shebangs, because many of them don't pin Nixpkgs, and run with whatever is in NIX_PATH (and it's not easy to fix this, see https://github.com/NixOS/nixpkgs/issues/425551) --- ci/default.nix | 2 +- maintainers/scripts/auto-rebase/test/default.nix | 4 ++-- pkgs/applications/editors/emacs/elisp-packages/emacs2nix.nix | 2 +- pkgs/build-support/dotnet/add-nuget-deps/default.nix | 4 ++-- pkgs/build-support/vm/default.nix | 2 +- pkgs/by-name/el/elm-land/package.nix | 4 ++-- pkgs/by-name/li/livekit-libwebrtc/gclient2nix.nix | 4 ++-- pkgs/by-name/ni/nil/package.nix | 4 ++-- pkgs/by-name/ni/nixfmt-tree/package.nix | 4 ++-- pkgs/by-name/tr/treefmt/tests.nix | 4 ++-- .../ruby-modules/bundler-update-script/default.nix | 4 ++-- pkgs/development/tools/build-managers/rebar3/default.nix | 4 ++-- pkgs/servers/mobilizon/default.nix | 4 ++-- pkgs/tools/typesetting/tex/texlive/default.nix | 4 ++-- pkgs/top-level/release-haskell.nix | 2 +- 15 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ci/default.nix b/ci/default.nix index 42eeadc67def..68fce29901a0 100644 --- a/ci/default.nix +++ b/ci/default.nix @@ -49,7 +49,7 @@ let programs.keep-sorted.enable = true; - # This uses nixfmt-rfc-style underneath, + # This uses nixfmt underneath, # the default formatter for Nix code. # See https://github.com/NixOS/nixfmt programs.nixfmt.enable = true; diff --git a/maintainers/scripts/auto-rebase/test/default.nix b/maintainers/scripts/auto-rebase/test/default.nix index fd6ce30d24ac..d57a3dabde60 100644 --- a/maintainers/scripts/auto-rebase/test/default.nix +++ b/maintainers/scripts/auto-rebase/test/default.nix @@ -9,7 +9,7 @@ let stdenvNoCC gitMinimal treefmt - nixfmt-rfc-style + nixfmt ; in @@ -27,7 +27,7 @@ stdenvNoCC.mkDerivation { nativeBuildInputs = [ gitMinimal treefmt - nixfmt-rfc-style + nixfmt ]; patchPhase = '' patchShebangs . diff --git a/pkgs/applications/editors/emacs/elisp-packages/emacs2nix.nix b/pkgs/applications/editors/emacs/elisp-packages/emacs2nix.nix index 3838271d4924..bf685185c764 100644 --- a/pkgs/applications/editors/emacs/elisp-packages/emacs2nix.nix +++ b/pkgs/applications/editors/emacs/elisp-packages/emacs2nix.nix @@ -13,7 +13,7 @@ pkgs.mkShell { packages = [ pkgs.bash - pkgs.nixfmt-rfc-style + pkgs.nixfmt ]; EMACS2NIX = src; diff --git a/pkgs/build-support/dotnet/add-nuget-deps/default.nix b/pkgs/build-support/dotnet/add-nuget-deps/default.nix index 7ddd7a556d40..29359fc01a87 100644 --- a/pkgs/build-support/dotnet/add-nuget-deps/default.nix +++ b/pkgs/build-support/dotnet/add-nuget-deps/default.nix @@ -5,7 +5,7 @@ lib, replaceVarsWith, nuget-to-nix, - nixfmt-rfc-style, + nixfmt, nuget-to-json, cacert, fetchNupkg, @@ -90,7 +90,7 @@ attrs replacements = { binPath = lib.makeBinPath [ nuget-to-nix - nixfmt-rfc-style + nixfmt nuget-to-json ]; }; diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index 73db05beaa39..ec9782e04b51 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -909,7 +909,7 @@ rec { nativeBuildInputs = [ buildPackages.perl buildPackages.dpkg - buildPackages.nixfmt-rfc-style + buildPackages.nixfmt ]; } '' diff --git a/pkgs/by-name/el/elm-land/package.nix b/pkgs/by-name/el/elm-land/package.nix index 92c09252b378..07b4c59f6a9b 100644 --- a/pkgs/by-name/el/elm-land/package.nix +++ b/pkgs/by-name/el/elm-land/package.nix @@ -7,7 +7,7 @@ writeShellScript, nix-update, elm2nix, - nixfmt-rfc-style, + nixfmt, }: buildNpmPackage rec { @@ -53,7 +53,7 @@ buildNpmPackage rec { cp "$(nix-build -A "$UPDATE_NIX_ATTR_PATH".src)/projects/cli/src/codegen/elm.json" elm.json trap 'rm -rf elm.json registry.dat &> /dev/null' EXIT ${lib.getExe elm2nix} convert > pkgs/by-name/el/elm-land/elm-srcs.nix - ${lib.getExe nixfmt-rfc-style} pkgs/by-name/el/elm-land/elm-srcs.nix + ${lib.getExe nixfmt} pkgs/by-name/el/elm-land/elm-srcs.nix ${lib.getExe elm2nix} snapshot cp registry.dat pkgs/by-name/el/elm-land/registry.dat ''; diff --git a/pkgs/by-name/li/livekit-libwebrtc/gclient2nix.nix b/pkgs/by-name/li/livekit-libwebrtc/gclient2nix.nix index 0b81afcdbd28..fe2fb3cfebc5 100644 --- a/pkgs/by-name/li/livekit-libwebrtc/gclient2nix.nix +++ b/pkgs/by-name/li/livekit-libwebrtc/gclient2nix.nix @@ -8,7 +8,7 @@ nix-prefetch-git, nix, coreutils, - nixfmt-rfc-style, + nixfmt, makeWrapper, }: # Based on https://github.com/milahu/gclient2nix @@ -19,7 +19,7 @@ let nix-prefetch-git nix coreutils - nixfmt-rfc-style + nixfmt ]; in buildPythonPackage { diff --git a/pkgs/by-name/ni/nil/package.nix b/pkgs/by-name/ni/nil/package.nix index 23b85a6dd50e..4a534b06b729 100644 --- a/pkgs/by-name/ni/nil/package.nix +++ b/pkgs/by-name/ni/nil/package.nix @@ -3,7 +3,7 @@ rustPlatform, fetchFromGitHub, nix, - nixfmt-rfc-style, + nixfmt, nix-update-script, }: @@ -25,7 +25,7 @@ rustPlatform.buildRustPackage rec { env = { CFG_RELEASE = version; - CFG_DEFAULT_FORMATTER = lib.getExe nixfmt-rfc-style; + CFG_DEFAULT_FORMATTER = lib.getExe nixfmt; }; # might be related to https://github.com/NixOS/nix/issues/5884 diff --git a/pkgs/by-name/ni/nixfmt-tree/package.nix b/pkgs/by-name/ni/nixfmt-tree/package.nix index a36a449b3449..d66d23ef3d2e 100644 --- a/pkgs/by-name/ni/nixfmt-tree/package.nix +++ b/pkgs/by-name/ni/nixfmt-tree/package.nix @@ -2,14 +2,14 @@ lib, runCommand, treefmt, - nixfmt-rfc-style, + nixfmt, nixfmt-tree, git, writableTmpDirAsHomeHook, settings ? { }, runtimeInputs ? [ ], - nixfmtPackage ? nixfmt-rfc-style, + nixfmtPackage ? nixfmt, # NOTE: `runtimePackages` is deprecated. Use `nixfmtPackage` and/or `runtimeInputs`. runtimePackages ? [ nixfmtPackage ], diff --git a/pkgs/by-name/tr/treefmt/tests.nix b/pkgs/by-name/tr/treefmt/tests.nix index 763bb14e5656..fd84f398012b 100644 --- a/pkgs/by-name/tr/treefmt/tests.nix +++ b/pkgs/by-name/tr/treefmt/tests.nix @@ -3,7 +3,7 @@ runCommand, testers, treefmt, - nixfmt-rfc-style, + nixfmt, }: let inherit (treefmt) buildConfig withConfig; @@ -29,7 +29,7 @@ let nixfmtExamplePackage = withConfig { settings = nixfmtExampleConfig; - runtimeInputs = [ nixfmt-rfc-style ]; + runtimeInputs = [ nixfmt ]; }; in { diff --git a/pkgs/development/ruby-modules/bundler-update-script/default.nix b/pkgs/development/ruby-modules/bundler-update-script/default.nix index 2135e42a2279..e248851bf7d8 100644 --- a/pkgs/development/ruby-modules/bundler-update-script/default.nix +++ b/pkgs/development/ruby-modules/bundler-update-script/default.nix @@ -7,7 +7,7 @@ coreutils, git, nix, - nixfmt-rfc-style, + nixfmt, }: attrPath: @@ -22,7 +22,7 @@ let coreutils git nix - nixfmt-rfc-style + nixfmt ] } set -o errexit diff --git a/pkgs/development/tools/build-managers/rebar3/default.nix b/pkgs/development/tools/build-managers/rebar3/default.nix index e40040332bd1..db9a1b5986e7 100644 --- a/pkgs/development/tools/build-managers/rebar3/default.nix +++ b/pkgs/development/tools/build-managers/rebar3/default.nix @@ -12,7 +12,7 @@ git, gnused, nix, - nixfmt-rfc-style, + nixfmt, rebar3-nix, }: @@ -95,7 +95,7 @@ let git gnused nix - nixfmt-rfc-style + nixfmt (rebar3WithPlugins { globalPlugins = [ rebar3-nix ]; }) ] } diff --git a/pkgs/servers/mobilizon/default.nix b/pkgs/servers/mobilizon/default.nix index 61dd5c7f8dfa..c62fe672acfc 100644 --- a/pkgs/servers/mobilizon/default.nix +++ b/pkgs/servers/mobilizon/default.nix @@ -8,7 +8,7 @@ git, cmake, nixosTests, - nixfmt-rfc-style, + nixfmt, mobilizon-frontend, ... }: @@ -145,7 +145,7 @@ mixRelease rec { set -eou pipefail ${lib.getExe mix2nix} '${src}/mix.lock' > pkgs/servers/mobilizon/mix.nix - ${lib.getExe nixfmt-rfc-style} pkgs/servers/mobilizon/mix.nix + ${lib.getExe nixfmt} pkgs/servers/mobilizon/mix.nix ''; elixirPackage = beamPackages.elixir; }; diff --git a/pkgs/tools/typesetting/tex/texlive/default.nix b/pkgs/tools/typesetting/tex/texlive/default.nix index b836687b7d9c..36435d58ff42 100644 --- a/pkgs/tools/typesetting/tex/texlive/default.nix +++ b/pkgs/tools/typesetting/tex/texlive/default.nix @@ -43,7 +43,7 @@ makeFontsConf, useFixedHashes ? true, recurseIntoAttrs, - nixfmt-rfc-style, + nixfmt, }: let stdenv = gcc12Stdenv; @@ -151,7 +151,7 @@ let tl2nix = ./tl2nix.sed; } '' - xzcat "$tlpdbxz" | sed -rn -f "$tl2nix" | uniq | ${lib.getExe nixfmt-rfc-style} > "$out" + xzcat "$tlpdbxz" | sed -rn -f "$tl2nix" | uniq | ${lib.getExe nixfmt} > "$out" ''; # map: name -> fixed-output hash diff --git a/pkgs/top-level/release-haskell.nix b/pkgs/top-level/release-haskell.nix index 9350d267e323..124e77761ad8 100644 --- a/pkgs/top-level/release-haskell.nix +++ b/pkgs/top-level/release-haskell.nix @@ -346,7 +346,7 @@ let nix-script nix-tree nixfmt-classic - nixfmt-rfc-style + nixfmt nota nvfetcher oama From b68cc636d3d150925699486e3122a1d8da4e4984 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Tue, 15 Jul 2025 22:14:56 +0200 Subject: [PATCH 3/4] treewide: Remove nixfmt-rfc-style from update script shebangs Based on the Nixpkgs used and the version of nixfmt-rfc-style in that version, it's likely that not the correct version is used. Update scripts should instead run within a Nixpkgs development shell (`nix-shell`/`nix develop`/`direnv`), where the correct version of `nixfmt` (although `treefmt` should be preferred) is always available. --- maintainers/scripts/haskell/regenerate-hackage-packages.sh | 2 +- maintainers/scripts/haskell/update-cabal2nix-unstable.sh | 2 +- pkgs/by-name/br/bruijn/update.sh | 2 +- pkgs/by-name/cr/creek/update.sh | 2 +- pkgs/by-name/dp/dprint/plugins/update-plugins.py | 2 +- pkgs/by-name/ej/ejabberd/update.sh | 2 +- pkgs/by-name/fl/flow-control/update.sh | 2 +- pkgs/by-name/gr/gren/update.sh | 2 +- pkgs/by-name/ms/msgraph-cli/update.sh | 2 +- pkgs/by-name/mu/music-assistant/update-providers.py | 2 +- pkgs/by-name/oa/oama/update.sh | 2 +- pkgs/by-name/ri/river-bedload/update-build-zig-zon.sh | 2 +- pkgs/by-name/ri/river/update.sh | 2 +- pkgs/by-name/wa/waylock/update.sh | 2 +- pkgs/development/beam-modules/elvis-erlang/default.nix | 2 +- pkgs/development/beam-modules/erlang-ls/default.nix | 2 +- pkgs/development/compilers/dotnet/update.sh | 2 +- pkgs/servers/home-assistant/update-component-packages.py | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/maintainers/scripts/haskell/regenerate-hackage-packages.sh b/maintainers/scripts/haskell/regenerate-hackage-packages.sh index 3b7c0a8297e1..58bb433f010e 100755 --- a/maintainers/scripts/haskell/regenerate-hackage-packages.sh +++ b/maintainers/scripts/haskell/regenerate-hackage-packages.sh @@ -1,5 +1,5 @@ #! /usr/bin/env nix-shell -#! nix-shell -i bash -p coreutils haskellPackages.cabal2nix-unstable git nixfmt-rfc-style -I nixpkgs=. +#! nix-shell -i bash -p coreutils haskellPackages.cabal2nix-unstable git -I nixpkgs=. set -euo pipefail diff --git a/maintainers/scripts/haskell/update-cabal2nix-unstable.sh b/maintainers/scripts/haskell/update-cabal2nix-unstable.sh index 21c3686ad296..866e7d2a6639 100755 --- a/maintainers/scripts/haskell/update-cabal2nix-unstable.sh +++ b/maintainers/scripts/haskell/update-cabal2nix-unstable.sh @@ -1,5 +1,5 @@ #! /usr/bin/env nix-shell -#! nix-shell -i bash -p coreutils curl jq gnused haskellPackages.cabal2nix-unstable nixfmt-rfc-style -I nixpkgs=. +#! nix-shell -i bash -p coreutils curl jq gnused haskellPackages.cabal2nix-unstable -I nixpkgs=. # Updates cabal2nix-unstable to the latest master of the nixos/cabal2nix repository. # See regenerate-hackage-packages.sh for details on the purpose of this script. diff --git a/pkgs/by-name/br/bruijn/update.sh b/pkgs/by-name/br/bruijn/update.sh index 40454a4d226c..837a3a680170 100755 --- a/pkgs/by-name/br/bruijn/update.sh +++ b/pkgs/by-name/br/bruijn/update.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p coreutils cabal2nix curl jq nixfmt-rfc-style +#!nix-shell -i bash -p coreutils cabal2nix curl jq set -euo pipefail diff --git a/pkgs/by-name/cr/creek/update.sh b/pkgs/by-name/cr/creek/update.sh index a346ab54c950..566de58e738f 100755 --- a/pkgs/by-name/cr/creek/update.sh +++ b/pkgs/by-name/cr/creek/update.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p bash common-updater-scripts gnused nixfmt-rfc-style +#!nix-shell -i bash -p bash common-updater-scripts gnused latest_tag=$(list-git-tags --url=https://github.com/nmeum/creek | sed 's/^v//' | tail -n 1) diff --git a/pkgs/by-name/dp/dprint/plugins/update-plugins.py b/pkgs/by-name/dp/dprint/plugins/update-plugins.py index f065d673152b..54eab2a67355 100755 --- a/pkgs/by-name/dp/dprint/plugins/update-plugins.py +++ b/pkgs/by-name/dp/dprint/plugins/update-plugins.py @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i python -p nix nixfmt-rfc-style 'python3.withPackages (pp: [ pp.requests ])' +#!nix-shell -i python -p nix 'python3.withPackages (pp: [ pp.requests ])' import json import os diff --git a/pkgs/by-name/ej/ejabberd/update.sh b/pkgs/by-name/ej/ejabberd/update.sh index af29359a58b3..0db339651212 100755 --- a/pkgs/by-name/ej/ejabberd/update.sh +++ b/pkgs/by-name/ej/ejabberd/update.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -I nixpkgs=./. -i bash -p curl jq common-updater-scripts "rebar3WithPlugins {globalPlugins = [beamPackages.rebar3-nix];}" erlang autoconf automake nixfmt-rfc-style +#!nix-shell -I nixpkgs=./. -i bash -p curl jq common-updater-scripts "rebar3WithPlugins {globalPlugins = [beamPackages.rebar3-nix];}" erlang autoconf automake #shellcheck shell=bash set -eu -o pipefail diff --git a/pkgs/by-name/fl/flow-control/update.sh b/pkgs/by-name/fl/flow-control/update.sh index c48ce524f3ce..4016cee25a7d 100755 --- a/pkgs/by-name/fl/flow-control/update.sh +++ b/pkgs/by-name/fl/flow-control/update.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p bash common-updater-scripts gnused nixfmt-rfc-style +#!nix-shell -i bash -p bash common-updater-scripts gnused latest_tag=$(list-git-tags --url=https://github.com/neurocyte/flow | sed 's/^v//' | tail -n 1) diff --git a/pkgs/by-name/gr/gren/update.sh b/pkgs/by-name/gr/gren/update.sh index 1b697ecb88dd..96133b395b25 100755 --- a/pkgs/by-name/gr/gren/update.sh +++ b/pkgs/by-name/gr/gren/update.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p cabal2nix curl jq nixfmt-rfc-style +#!nix-shell -i bash -p cabal2nix curl jq set -euo pipefail diff --git a/pkgs/by-name/ms/msgraph-cli/update.sh b/pkgs/by-name/ms/msgraph-cli/update.sh index d1bc45f25dac..66ed99778a18 100755 --- a/pkgs/by-name/ms/msgraph-cli/update.sh +++ b/pkgs/by-name/ms/msgraph-cli/update.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p curl gnused nixfmt-rfc-style common-updater-scripts +#!nix-shell -i bash -p curl gnused common-updater-scripts set -eEuo pipefail [ -z "${DEBUG:-}" ] || set -x cd "${BASH_SOURCE[0]%/*}" diff --git a/pkgs/by-name/mu/music-assistant/update-providers.py b/pkgs/by-name/mu/music-assistant/update-providers.py index 1bbb14572e2a..393dbca9500a 100755 --- a/pkgs/by-name/mu/music-assistant/update-providers.py +++ b/pkgs/by-name/mu/music-assistant/update-providers.py @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -I nixpkgs=./. -i python3 -p "music-assistant.python.withPackages (ps: music-assistant.dependencies ++ (with ps; [ jinja2 packaging ]))" -p pyright ruff isort nixfmt-rfc-style +#!nix-shell -I nixpkgs=./. -i python3 -p "music-assistant.python.withPackages (ps: music-assistant.dependencies ++ (with ps; [ jinja2 packaging ]))" -p pyright ruff isort import asyncio import json import os.path diff --git a/pkgs/by-name/oa/oama/update.sh b/pkgs/by-name/oa/oama/update.sh index 45af4b99fe59..6d4f581b99ee 100755 --- a/pkgs/by-name/oa/oama/update.sh +++ b/pkgs/by-name/oa/oama/update.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p haskell.packages.ghc910.cabal2nix nix-prefetch-git curl jq nixfmt-rfc-style +#!nix-shell -i bash -p haskell.packages.ghc910.cabal2nix nix-prefetch-git curl jq set -euo pipefail diff --git a/pkgs/by-name/ri/river-bedload/update-build-zig-zon.sh b/pkgs/by-name/ri/river-bedload/update-build-zig-zon.sh index ed3e7f9fe855..f28f3ada43bb 100755 --- a/pkgs/by-name/ri/river-bedload/update-build-zig-zon.sh +++ b/pkgs/by-name/ri/river-bedload/update-build-zig-zon.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p bash jq nixfmt-rfc-style zon2nix +#!nix-shell -i bash -p bash jq zon2nix commit=$(nix-instantiate --eval -A river-bedload.src.rev | jq --raw-output) diff --git a/pkgs/by-name/ri/river/update.sh b/pkgs/by-name/ri/river/update.sh index 41bbe048223c..7d7875e5c8c6 100755 --- a/pkgs/by-name/ri/river/update.sh +++ b/pkgs/by-name/ri/river/update.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p bash common-updater-scripts gnused nixfmt-rfc-style zon2nix +#!nix-shell -i bash -p bash common-updater-scripts gnused zon2nix latest_tag=$(list-git-tags --url=https://codeberg.org/river/river | sed 's/^v//' | sort --version-sort | tail --lines=1) diff --git a/pkgs/by-name/wa/waylock/update.sh b/pkgs/by-name/wa/waylock/update.sh index 5caa604fce9f..8ee3e33ad250 100755 --- a/pkgs/by-name/wa/waylock/update.sh +++ b/pkgs/by-name/wa/waylock/update.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p bash common-updater-scripts gnused nixfmt-rfc-style zon2nix +#!nix-shell -i bash -p bash common-updater-scripts gnused zon2nix latest_tag=$(list-git-tags --url=https://codeberg.org/ifreund/waylock | sed 's/^v//' | tail -n 1) diff --git a/pkgs/development/beam-modules/elvis-erlang/default.nix b/pkgs/development/beam-modules/elvis-erlang/default.nix index 9599f9f335a3..114df9b06b50 100644 --- a/pkgs/development/beam-modules/elvis-erlang/default.nix +++ b/pkgs/development/beam-modules/elvis-erlang/default.nix @@ -29,7 +29,7 @@ rebar3Relx rec { passthru.updateScript = writeScript "update.sh" '' #!/usr/bin/env nix-shell - #!nix-shell -i bash -p bash common-updater-scripts git nix-prefetch-git gnutar gzip "rebar3WithPlugins {globalPlugins = [beamPackages.rebar3-nix];}" nixfmt-rfc-style + #!nix-shell -i bash -p bash common-updater-scripts git nix-prefetch-git gnutar gzip "rebar3WithPlugins {globalPlugins = [beamPackages.rebar3-nix];}" set -euo pipefail diff --git a/pkgs/development/beam-modules/erlang-ls/default.nix b/pkgs/development/beam-modules/erlang-ls/default.nix index 548cb2ee4d06..8372aaccbafb 100644 --- a/pkgs/development/beam-modules/erlang-ls/default.nix +++ b/pkgs/development/beam-modules/erlang-ls/default.nix @@ -74,7 +74,7 @@ rebar3Relx { passthru.updateScript = writeScript "update.sh" '' #!/usr/bin/env nix-shell - #! nix-shell -i bash -p common-updater-scripts coreutils git gnused gnutar gzip nixfmt-rfc-style "rebar3WithPlugins { globalPlugins = [ beamPackages.rebar3-nix ]; }" + #! nix-shell -i bash -p common-updater-scripts coreutils git gnused gnutar gzip "rebar3WithPlugins { globalPlugins = [ beamPackages.rebar3-nix ]; }" set -ox errexit latest=$(list-git-tags | sed -n '/[\d\.]\+/p' | sort -V | tail -1) diff --git a/pkgs/development/compilers/dotnet/update.sh b/pkgs/development/compilers/dotnet/update.sh index 2e4b41244d70..8dd35a3bc0bb 100755 --- a/pkgs/development/compilers/dotnet/update.sh +++ b/pkgs/development/compilers/dotnet/update.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -I nixpkgs=./. -i bash -p curl jq nix gnused nixfmt-rfc-style +#!nix-shell -I nixpkgs=./. -i bash -p curl jq nix gnused # shellcheck shell=bash set -Eeuo pipefail diff --git a/pkgs/servers/home-assistant/update-component-packages.py b/pkgs/servers/home-assistant/update-component-packages.py index a6433c9b96b4..c7ff548bd427 100755 --- a/pkgs/servers/home-assistant/update-component-packages.py +++ b/pkgs/servers/home-assistant/update-component-packages.py @@ -1,5 +1,5 @@ #! /usr/bin/env nix-shell -#! nix-shell -i python3 -p "python3.withPackages (ps: with ps; [ packaging rich ])" -p pyright ruff isort nixfmt-rfc-style +#! nix-shell -i python3 -p "python3.withPackages (ps: with ps; [ packaging rich ])" -p pyright ruff isort # # This script downloads Home Assistant's source tarball. # Inside the homeassistant/components directory, each integration has an associated manifest.json, From 98169225ad745c2b3c6e37129963b0e93dcde9b8 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Tue, 15 Jul 2025 23:12:25 +0200 Subject: [PATCH 4/4] maintainers/scripts/update.nix: Run updateScript in development shell Update scripts aren't always run in the development shell by default, especially not in the regular automated updates. The parent commit makes the update scripts depend on running in the development shell, so let's make sure it's always done. --- maintainers/scripts/update.py | 7 ++++++- pkgs/README.md | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/maintainers/scripts/update.py b/maintainers/scripts/update.py index 576332b76607..10d197d5fe78 100644 --- a/maintainers/scripts/update.py +++ b/maintainers/scripts/update.py @@ -7,6 +7,7 @@ import contextlib import json import os import re +import shlex import subprocess import sys import tempfile @@ -235,7 +236,11 @@ async def run_update_script( f"UPDATE_NIX_PNAME={package['pname']}", f"UPDATE_NIX_OLD_VERSION={package['oldVersion']}", f"UPDATE_NIX_ATTR_PATH={package['attrPath']}", - *update_script_command, + # Run all update scripts in the Nixpkgs development shell to get access to formatters and co. + "nix-shell", + nixpkgs_root + "/shell.nix", + "--run", + " ".join([ shlex.quote(s) for s in update_script_command ]), stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, cwd=worktree, diff --git a/pkgs/README.md b/pkgs/README.md index 83d264d95085..eff9421efbfb 100644 --- a/pkgs/README.md +++ b/pkgs/README.md @@ -940,7 +940,8 @@ Update scripts are to be invoked by the [automatic package update script](../mai You can run `nix-shell maintainers/scripts/update.nix` in the root of Nixpkgs repository for information on how to use it. `update.nix` offers several modes for selecting packages to update, and it will execute update scripts for all matched packages that have an `updateScript` attribute. -Each update script will be passed the following environment variables: +Update scripts will be run inside the [Nixpkgs development shell](../shell.nix), providing access to some useful tools for CI. +Furthermore each update script will be passed the following environment variables: - [`UPDATE_NIX_NAME`] – content of the `name` attribute of the updated package - [`UPDATE_NIX_PNAME`] – content of the `pname` attribute of the updated package