nixfmt[-rfc-style]: unstable -> 1.0.0 (#425068)

This commit is contained in:
Wolfgang Walther
2025-07-18 17:40:43 +00:00
committed by GitHub
42 changed files with 96 additions and 98 deletions

View File

@@ -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;

View File

@@ -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}

View File

@@ -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 .

View File

@@ -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

View File

@@ -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.

View File

@@ -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,

View File

@@ -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

View File

@@ -13,7 +13,7 @@ pkgs.mkShell {
packages = [
pkgs.bash
pkgs.nixfmt-rfc-style
pkgs.nixfmt
];
EMACS2NIX = src;

View File

@@ -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
];
};

View File

@@ -909,7 +909,7 @@ rec {
nativeBuildInputs = [
buildPackages.perl
buildPackages.dpkg
buildPackages.nixfmt-rfc-style
buildPackages.nixfmt
];
}
''

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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
'';

View File

@@ -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)

View File

@@ -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

View File

@@ -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 {

View File

@@ -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]%/*}"

View File

@@ -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

View File

@@ -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

View File

@@ -1 +0,0 @@
2025-04-04

View File

@@ -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."

View File

@@ -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 ],

View File

@@ -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;

View File

@@ -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

View File

@@ -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."

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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
{

View File

@@ -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)

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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 ]; })
]
}

View File

@@ -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,

View File

@@ -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;
};

View File

@@ -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

View File

@@ -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.

View File

@@ -346,7 +346,7 @@ let
nix-script
nix-tree
nixfmt-classic
nixfmt-rfc-style
nixfmt
nota
nvfetcher
oama