diff --git a/maintainers/scripts/haskell/update-cabal2nix-unstable.sh b/maintainers/scripts/haskell/update-cabal2nix-unstable.sh index 367b67fd072d..b1061d17e230 100755 --- a/maintainers/scripts/haskell/update-cabal2nix-unstable.sh +++ b/maintainers/scripts/haskell/update-cabal2nix-unstable.sh @@ -12,8 +12,16 @@ head_info="$(curl -H "Accept: application/vnd.github.v3+json" https://api.github commit="$(jq -r .commit.sha <<< "$head_info")" # extract commit timestamp and convert to date date="$(date "--date=$(jq -r .commit.commit.committer.date <<< "$head_info")" +%F)" + # generate nix expression from cabal file, replacing the version with the commit date -output=pkgs/development/haskell-modules/cabal2nix-unstable.nix -echo '# This file defines cabal2nix-unstable, used by maintainers/scripts/haskell/regenerate-hackage-packages.sh.' > "$output" -cabal2nix --subpath cabal2nix "https://github.com/NixOS/cabal2nix/archive/$commit.tar.gz" | sed -Ee 's/version = "(.*)"/version = "\1-unstable-'"$date"'"/' >> "$output" -nixfmt "$output" +function mkPackage() { + output=pkgs/development/haskell-modules/cabal2nix-unstable/$1.nix + echo "# This file defines $1-unstable, used by maintainers/scripts/haskell/regenerate-hackage-packages.sh." > "$output" + cabal2nix --subpath "$1" "https://github.com/NixOS/cabal2nix/archive/$commit.tar.gz" | sed -Ee 's/version = "(.*)"/version = "\1-unstable-'"$date"'"/' >> "$output" + nixfmt "$output" +} + +mkPackage "cabal2nix" +mkPackage "distribution-nixpkgs" +mkPackage "hackage-db" +mkPackage "language-nix" diff --git a/pkgs/development/haskell-modules/cabal2nix-unstable.nix b/pkgs/development/haskell-modules/cabal2nix-unstable/cabal2nix.nix similarity index 100% rename from pkgs/development/haskell-modules/cabal2nix-unstable.nix rename to pkgs/development/haskell-modules/cabal2nix-unstable/cabal2nix.nix diff --git a/pkgs/development/haskell-modules/cabal2nix-unstable/distribution-nixpkgs.nix b/pkgs/development/haskell-modules/cabal2nix-unstable/distribution-nixpkgs.nix new file mode 100644 index 000000000000..96835e9a986c --- /dev/null +++ b/pkgs/development/haskell-modules/cabal2nix-unstable/distribution-nixpkgs.nix @@ -0,0 +1,53 @@ +# This file defines distribution-nixpkgs-unstable, used by maintainers/scripts/haskell/regenerate-hackage-packages.sh. +{ + mkDerivation, + aeson, + base, + bytestring, + Cabal, + containers, + deepseq, + directory, + fetchzip, + hspec, + language-nix, + lens, + lib, + pretty, + process, +}: +mkDerivation { + pname = "distribution-nixpkgs"; + version = "1.7.1.1-unstable-2025-09-09"; + src = fetchzip { + url = "https://github.com/NixOS/cabal2nix/archive/987474e0b0ed1c6b0e3fd0d07313f6996ec98b7e.tar.gz"; + sha256 = "0nixn8incqypsfyfclj40p8bdx2yn4783kzwpqfp19ql2sbc57dc"; + }; + postUnpack = "sourceRoot+=/distribution-nixpkgs; echo source root reset to $sourceRoot"; + enableSeparateDataOutput = true; + libraryHaskellDepends = [ + aeson + base + bytestring + Cabal + containers + deepseq + language-nix + lens + pretty + process + ]; + testHaskellDepends = [ + aeson + base + Cabal + deepseq + directory + hspec + language-nix + lens + ]; + homepage = "https://github.com/NixOS/cabal2nix/tree/master/distribution-nixpkgs#readme"; + description = "Types and functions to manipulate the Nixpkgs distribution"; + license = lib.licenses.bsd3; +} diff --git a/pkgs/development/haskell-modules/cabal2nix-unstable/hackage-db.nix b/pkgs/development/haskell-modules/cabal2nix-unstable/hackage-db.nix new file mode 100644 index 000000000000..c5aac1c14558 --- /dev/null +++ b/pkgs/development/haskell-modules/cabal2nix-unstable/hackage-db.nix @@ -0,0 +1,44 @@ +# This file defines hackage-db-unstable, used by maintainers/scripts/haskell/regenerate-hackage-packages.sh. +{ + mkDerivation, + aeson, + base, + bytestring, + Cabal, + containers, + directory, + exceptions, + fetchzip, + filepath, + lib, + tar, + time, + utf8-string, +}: +mkDerivation { + pname = "hackage-db"; + version = "2.1.3-unstable-2025-09-09"; + src = fetchzip { + url = "https://github.com/NixOS/cabal2nix/archive/987474e0b0ed1c6b0e3fd0d07313f6996ec98b7e.tar.gz"; + sha256 = "0nixn8incqypsfyfclj40p8bdx2yn4783kzwpqfp19ql2sbc57dc"; + }; + postUnpack = "sourceRoot+=/hackage-db; echo source root reset to $sourceRoot"; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + aeson + base + bytestring + Cabal + containers + directory + exceptions + filepath + tar + time + utf8-string + ]; + homepage = "https://github.com/NixOS/cabal2nix/tree/master/hackage-db#readme"; + description = "Access cabal-install's Hackage database via Data.Map"; + license = lib.licenses.bsd3; +} diff --git a/pkgs/development/haskell-modules/cabal2nix-unstable/language-nix.nix b/pkgs/development/haskell-modules/cabal2nix-unstable/language-nix.nix new file mode 100644 index 000000000000..4a024a209b86 --- /dev/null +++ b/pkgs/development/haskell-modules/cabal2nix-unstable/language-nix.nix @@ -0,0 +1,32 @@ +# This file defines language-nix-unstable, used by maintainers/scripts/haskell/regenerate-hackage-packages.sh. +{ + mkDerivation, + base, + deepseq, + fetchzip, + lens, + lib, + parsec-class, + pretty, + QuickCheck, +}: +mkDerivation { + pname = "language-nix"; + version = "2.2.0-unstable-2025-09-09"; + src = fetchzip { + url = "https://github.com/NixOS/cabal2nix/archive/987474e0b0ed1c6b0e3fd0d07313f6996ec98b7e.tar.gz"; + sha256 = "0nixn8incqypsfyfclj40p8bdx2yn4783kzwpqfp19ql2sbc57dc"; + }; + postUnpack = "sourceRoot+=/language-nix; echo source root reset to $sourceRoot"; + libraryHaskellDepends = [ + base + deepseq + lens + parsec-class + pretty + QuickCheck + ]; + homepage = "https://github.com/NixOS/cabal2nix/tree/master/language-nix#readme"; + description = "Data types and functions to represent the Nix language"; + license = lib.licenses.bsd3; +} diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index a485ab7196e7..f801088db9ec 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -171,12 +171,16 @@ with haskellLib; ]; cabal2nix-unstable = super.cabal2nix-unstable.overrideScope cabalInstallOverlay; + distribution-nixpkgs-unstable = super.distribution-nixpkgs-unstable.overrideScope cabalInstallOverlay; + hackage-db-unstable = super.hackage-db-unstable.overrideScope cabalInstallOverlay; } ) cabal-install cabal-install-solver guardian cabal2nix-unstable + distribution-nixpkgs-unstable + hackage-db-unstable ; # Expected test output for these accidentally checks the absolute location of the source directory diff --git a/pkgs/development/haskell-modules/configuration-darwin.nix b/pkgs/development/haskell-modules/configuration-darwin.nix index ffb6e6a8b08c..5967401419b1 100644 --- a/pkgs/development/haskell-modules/configuration-darwin.nix +++ b/pkgs/development/haskell-modules/configuration-darwin.nix @@ -354,22 +354,24 @@ self: super: # after verifying they are indeed erroneous (e.g. cabal2nix) or just disable # the check, sticking with the status quo. Ideally there'll be zero cases of # the latter in the future! - inherit - (lib.mapAttrs ( - _: - overrideCabal (old: { - postInstall = '' - remove-references-to -t ${self.hpack} "$out/bin/cabal2nix" - # Note: The `data` output is needed at runtime. - remove-references-to -t ${self.distribution-nixpkgs.out} "$out/bin/hackage2nix" + cabal2nix = overrideCabal (old: { + postInstall = '' + remove-references-to -t ${self.hpack} "$out/bin/cabal2nix" + # Note: The `data` output is needed at runtime. + remove-references-to -t ${self.distribution-nixpkgs.out} "$out/bin/hackage2nix" - ${old.postInstall or ""} - ''; - }) - ) super) - cabal2nix - cabal2nix-unstable - ; + ${old.postInstall or ""} + ''; + }) super.cabal2nix; + cabal2nix-unstable = overrideCabal (old: { + postInstall = '' + remove-references-to -t ${self.hpack} "$out/bin/cabal2nix" + # Note: The `data` output is needed at runtime. + remove-references-to -t ${self.distribution-nixpkgs-unstable.out} "$out/bin/hackage2nix" + + ${old.postInstall or ""} + ''; + }) super.cabal2nix-unstable; # https://github.com/fpco/unliftio/issues/87 unliftio = dontCheck super.unliftio; diff --git a/pkgs/development/haskell-modules/non-hackage-packages.nix b/pkgs/development/haskell-modules/non-hackage-packages.nix index a9269a9e8a08..87e656243589 100644 --- a/pkgs/development/haskell-modules/non-hackage-packages.nix +++ b/pkgs/development/haskell-modules/non-hackage-packages.nix @@ -28,7 +28,16 @@ self: super: # Used by maintainers/scripts/regenerate-hackage-packages.sh, and generated # from the latest master instead of the current version on Hackage. - cabal2nix-unstable = self.callPackage ./cabal2nix-unstable.nix { }; + cabal2nix-unstable = self.callPackage ./cabal2nix-unstable/cabal2nix.nix { + distribution-nixpkgs = self.distribution-nixpkgs-unstable; + hackage-db = self.hackage-db-unstable; + language-nix = self.language-nix-unstable; + }; + distribution-nixpkgs-unstable = self.callPackage ./cabal2nix-unstable/distribution-nixpkgs.nix { + language-nix = self.language-nix-unstable; + }; + hackage-db-unstable = self.callPackage ./cabal2nix-unstable/hackage-db.nix { }; + language-nix-unstable = self.callPackage ./cabal2nix-unstable/language-nix.nix { }; ghc-settings-edit = self.callPackage ../tools/haskell/ghc-settings-edit { };