Skip to content

Commit d94e1a6

Browse files
committed
nixfmt-classic: Stop using the hackage package
Removes dependency on the hackage package so we can finally fix NixOS/nixfmt#161 and also moves the entire package to pkgs/by-name.
1 parent 470e6e6 commit d94e1a6

File tree

5 files changed

+91
-3
lines changed

5 files changed

+91
-3
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This file has been autogenerate with cabal2nix.
2+
# Update via ./update.sh
3+
{
4+
mkDerivation,
5+
base,
6+
cmdargs,
7+
directory,
8+
fetchgit,
9+
filepath,
10+
lib,
11+
megaparsec,
12+
parser-combinators,
13+
safe-exceptions,
14+
scientific,
15+
text,
16+
unix,
17+
}:
18+
mkDerivation {
19+
pname = "nixfmt";
20+
version = "0.6.0";
21+
src = fetchgit {
22+
url = "https://github.com/NixOS/nixfmt.git";
23+
sha256 = "0yh1baanifnv5fl3d7ixkgaki7ka1big0kxkiv4h5rik6zkqfyqz";
24+
rev = "7e9e06eefed52d6d698b828ee83b83ea5c163f3b";
25+
fetchSubmodules = true;
26+
};
27+
isLibrary = true;
28+
isExecutable = true;
29+
libraryHaskellDepends = [
30+
base
31+
megaparsec
32+
parser-combinators
33+
scientific
34+
text
35+
];
36+
executableHaskellDepends = [
37+
base
38+
cmdargs
39+
directory
40+
filepath
41+
safe-exceptions
42+
text
43+
unix
44+
];
45+
jailbreak = true;
46+
homepage = "https://github.com/serokell/nixfmt";
47+
description = "An opinionated formatter for Nix";
48+
license = lib.licenses.mpl20;
49+
mainProgram = "nixfmt";
50+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
haskell,
3+
haskellPackages,
4+
lib,
5+
}:
6+
let
7+
inherit (haskell.lib.compose) overrideCabal justStaticExecutables;
8+
9+
overrides.passthru.updateScript = ./update.sh;
10+
raw-pkg = haskellPackages.callPackage ./generated-package.nix { };
11+
in
12+
lib.pipe raw-pkg [
13+
(overrideCabal overrides)
14+
justStaticExecutables
15+
]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -i bash -p cabal2nix curl jq
3+
#
4+
# This script will update the nixfmt-classic derivation to the latest version using
5+
# cabal2nix.
6+
7+
set -eo pipefail
8+
9+
# This is the directory of this update.sh script.
10+
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
11+
derivation_file="${script_dir}/generated-package.nix"
12+
latest_version="$(curl --silent 'https://api.github.com/repos/NixOS/nixfmt/releases/latest' | jq --raw-output '.tag_name')"
13+
14+
echo "Updating nixfmt-classic to version $new_date."
15+
echo "Running cabal2nix and outputting to ${derivation_file}..."
16+
17+
cat > "$derivation_file" << EOF
18+
# This file has been autogenerate with cabal2nix.
19+
# Update via ./update.sh
20+
EOF
21+
22+
cabal2nix 'https://github.com/NixOS/nixfmt.git' --revision "${latest_version}" --jailbreak >> "${derivation_file}"
23+
nixfmt "${derivation_file}"
24+
25+
echo "Finished."

pkgs/development/haskell-modules/configuration-common.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ self: super: {
435435
postPatch = "sed -i s/home/tmp/ test/Spec.hs";
436436
}) super.shell-conduit;
437437

438-
# https://github.com/serokell/nixfmt/issues/130
438+
# https://github.com/NixOS/nixfmt/issues/130
439439
nixfmt = doJailbreak super.nixfmt;
440440

441441
# Too strict upper bounds on turtle and text

pkgs/top-level/all-packages.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18497,8 +18497,6 @@ with pkgs;
1849718497
inherit (darwin.apple_sdk.frameworks) Security SystemConfiguration IOKit;
1849818498
};
1849918499

18500-
nixfmt-classic = haskellPackages.nixfmt.bin;
18501-
1850218500
nixpkgs-manual = callPackage ../../doc/doc-support/package.nix { };
1850318501

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

0 commit comments

Comments
 (0)