diff --git a/pkgs/by-name/ni/nixfmt/package.nix b/pkgs/by-name/ni/nixfmt/package.nix index 93a198f73f2a..ebd16230063c 100644 --- a/pkgs/by-name/ni/nixfmt/package.nix +++ b/pkgs/by-name/ni/nixfmt/package.nix @@ -2,27 +2,31 @@ haskell, haskellPackages, lib, - runCommand, - nixfmt, + stdenv, + versionCheckHook, }: let inherit (haskell.lib.compose) overrideCabal justStaticExecutables; - overrides = { + cabalOverrides = { passthru.updateScript = ./update.sh; - teams = [ lib.teams.formatter ]; - - # These tests can be run with the following command. - # - # $ nix-build -A nixfmt.tests - passthru.tests = runCommand "nixfmt-tests" { nativeBuildInputs = [ nixfmt ]; } '' - nixfmt --version > $out - ''; }; + + # haskellPackages.mkDerivation and haskell.lib.compose.overrideCabal + # do not allow access to `doInstallCheck` or `nativeInstallCheckInputs`, + # so we override directly with `.overrideAttrs`. + lateOverrides = finalAttrs: prevAttrs: { + doInstallCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; + nativeInstallCheckInputs = prevAttrs.nativeInstallCheckInputs or [ ] ++ [ + versionCheckHook + ]; + }; + raw-pkg = haskellPackages.callPackage ./generated-package.nix { }; in lib.pipe raw-pkg [ - (overrideCabal overrides) + (overrideCabal cabalOverrides) justStaticExecutables + (drv: drv.overrideAttrs lateOverrides) ]