Skip to content

Commit

Permalink
nixfmt-classic: Stop using the hackage package
Browse files Browse the repository at this point in the history
Removes dependency on the hackage package so we can finally fix
NixOS/nixfmt#161 and also moves the entire
package to pkgs/by-name.
  • Loading branch information
dasJ committed Nov 26, 2024
1 parent 470e6e6 commit d94e1a6
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 3 deletions.
50 changes: 50 additions & 0 deletions pkgs/by-name/ni/nixfmt-classic/generated-package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This file has been autogenerate with cabal2nix.
# Update via ./update.sh
{
mkDerivation,
base,
cmdargs,
directory,
fetchgit,
filepath,
lib,
megaparsec,
parser-combinators,
safe-exceptions,
scientific,
text,
unix,
}:
mkDerivation {
pname = "nixfmt";
version = "0.6.0";
src = fetchgit {
url = "https://github.com/NixOS/nixfmt.git";
sha256 = "0yh1baanifnv5fl3d7ixkgaki7ka1big0kxkiv4h5rik6zkqfyqz";
rev = "7e9e06eefed52d6d698b828ee83b83ea5c163f3b";
fetchSubmodules = true;
};
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [
base
megaparsec
parser-combinators
scientific
text
];
executableHaskellDepends = [
base
cmdargs
directory
filepath
safe-exceptions
text
unix
];
jailbreak = true;
homepage = "https://github.com/serokell/nixfmt";
description = "An opinionated formatter for Nix";
license = lib.licenses.mpl20;
mainProgram = "nixfmt";
}
15 changes: 15 additions & 0 deletions pkgs/by-name/ni/nixfmt-classic/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
haskell,
haskellPackages,
lib,
}:
let
inherit (haskell.lib.compose) overrideCabal justStaticExecutables;

overrides.passthru.updateScript = ./update.sh;
raw-pkg = haskellPackages.callPackage ./generated-package.nix { };
in
lib.pipe raw-pkg [
(overrideCabal overrides)
justStaticExecutables
]
25 changes: 25 additions & 0 deletions pkgs/by-name/ni/nixfmt-classic/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p cabal2nix curl jq
#
# This script will update the nixfmt-classic 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"
latest_version="$(curl --silent 'https://api.github.com/repos/NixOS/nixfmt/releases/latest' | jq --raw-output '.tag_name')"

echo "Updating nixfmt-classic 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 'https://github.com/NixOS/nixfmt.git' --revision "${latest_version}" --jailbreak >> "${derivation_file}"
nixfmt "${derivation_file}"

echo "Finished."
2 changes: 1 addition & 1 deletion pkgs/development/haskell-modules/configuration-common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ self: super: {
postPatch = "sed -i s/home/tmp/ test/Spec.hs";
}) super.shell-conduit;

# https://github.com/serokell/nixfmt/issues/130
# https://github.com/NixOS/nixfmt/issues/130
nixfmt = doJailbreak super.nixfmt;

# Too strict upper bounds on turtle and text
Expand Down
2 changes: 0 additions & 2 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18497,8 +18497,6 @@ with pkgs;
inherit (darwin.apple_sdk.frameworks) Security SystemConfiguration IOKit;
};

nixfmt-classic = haskellPackages.nixfmt.bin;

nixpkgs-manual = callPackage ../../doc/doc-support/package.nix { };

nixos-artwork = callPackage ../data/misc/nixos-artwork { };
Expand Down

0 comments on commit d94e1a6

Please sign in to comment.