From b3bc1e31d0fc920cc11a79ed4f4bd202961addfb Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Mon, 14 Jul 2025 13:23:16 +0200 Subject: [PATCH] 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.