From 3eebbd99ab37aa0bc0e97accc2e511050e8d4c96 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 15 Apr 2026 14:25:20 -0400 Subject: [PATCH 1/5] test: add regression test for removeReferencesTo with buildFromSdist Verifies that the removeReferencesTo setting correctly sets disallowedReferences on the final package even when buildFromSdist is enabled (the default). This catches ordering regressions like the one fixed in PR #287. Closes #288 --- test/simple/flake.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/simple/flake.nix b/test/simple/flake.nix index 526f4fba..f7f7b53f 100644 --- a/test/simple/flake.nix +++ b/test/simple/flake.nix @@ -62,6 +62,9 @@ # # This jailbreak ignores the unsatisfiable version constraints on the library `foo`. jailbreak = true; + # Test removeReferencesTo setting (cf. https://github.com/srid/haskell-flake/issues/288) + # This must work even with buildFromSdist enabled (which is the default). + removeReferencesTo = [ pkgs.hello ]; }; }; devShell = { @@ -101,6 +104,12 @@ TEST_RAW_ATTR = lib.assertMsg (config.haskellProjects.default.outputs.finalPackages.foo.TEST_RAW_ATTR == "test-value") "drvAttrs option should apply TEST_RAW_ATTR attribute"; + + # Test removeReferencesTo: verify disallowedReferences is set on the final package + # even with buildFromSdist enabled (regression test for https://github.com/srid/haskell-flake/pull/287) + REMOVE_REFS = + lib.assertMsg (config.haskellProjects.default.outputs.finalPackages.haskell-flake-test.disallowedReferences == [ pkgs.hello ]) + "removeReferencesTo should set disallowedReferences on the final package"; } '' ( From 1e581f4373db5cc3f73705b0adcdbc935929c5ed Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 15 Apr 2026 14:27:46 -0400 Subject: [PATCH 2/5] fix: use postInstall check for removeReferencesTo test Check that `remove-references-to` appears in the package's postInstall hook rather than comparing disallowedReferences directly, which isn't reliably accessible as a derivation attribute. --- test/simple/flake.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/simple/flake.nix b/test/simple/flake.nix index f7f7b53f..f21d0d54 100644 --- a/test/simple/flake.nix +++ b/test/simple/flake.nix @@ -105,11 +105,14 @@ lib.assertMsg (config.haskellProjects.default.outputs.finalPackages.foo.TEST_RAW_ATTR == "test-value") "drvAttrs option should apply TEST_RAW_ATTR attribute"; - # Test removeReferencesTo: verify disallowedReferences is set on the final package + # Test removeReferencesTo: verify the setting is applied on the final package # even with buildFromSdist enabled (regression test for https://github.com/srid/haskell-flake/pull/287) REMOVE_REFS = - lib.assertMsg (config.haskellProjects.default.outputs.finalPackages.haskell-flake-test.disallowedReferences == [ pkgs.hello ]) - "removeReferencesTo should set disallowedReferences on the final package"; + let + pkg = config.haskellProjects.default.outputs.finalPackages.haskell-flake-test; + in + lib.assertMsg (lib.hasInfix "remove-references-to" (pkg.postInstall or "")) + "removeReferencesTo should add remove-references-to to postInstall"; } '' ( From b9bd7b1d756aa0d65d2cee7608da14e2cbf88f54 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 15 Apr 2026 14:34:45 -0400 Subject: [PATCH 3/5] fix: test removeReferencesTo with real gmp reference check Replace the weak eval-time postInstall string check with a proper build-time test: configure removeReferencesTo to strip pkgs.gmp (a real runtime reference from integer-gmp), then grep the built binary to verify the store path is actually gone. --- test/simple/flake.nix | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test/simple/flake.nix b/test/simple/flake.nix index f21d0d54..97ff78da 100644 --- a/test/simple/flake.nix +++ b/test/simple/flake.nix @@ -63,8 +63,9 @@ # This jailbreak ignores the unsatisfiable version constraints on the library `foo`. jailbreak = true; # Test removeReferencesTo setting (cf. https://github.com/srid/haskell-flake/issues/288) - # This must work even with buildFromSdist enabled (which is the default). - removeReferencesTo = [ pkgs.hello ]; + # gmp is a real runtime reference from integer-gmp; this verifies the + # reference is actually stripped even with buildFromSdist enabled. + removeReferencesTo = [ pkgs.gmp ]; }; }; devShell = { @@ -105,14 +106,8 @@ lib.assertMsg (config.haskellProjects.default.outputs.finalPackages.foo.TEST_RAW_ATTR == "test-value") "drvAttrs option should apply TEST_RAW_ATTR attribute"; - # Test removeReferencesTo: verify the setting is applied on the final package - # even with buildFromSdist enabled (regression test for https://github.com/srid/haskell-flake/pull/287) - REMOVE_REFS = - let - pkg = config.haskellProjects.default.outputs.finalPackages.haskell-flake-test; - in - lib.assertMsg (lib.hasInfix "remove-references-to" (pkg.postInstall or "")) - "removeReferencesTo should add remove-references-to to postInstall"; + # For removeReferencesTo test: the store path to verify is gone + GMP_PATH = "${pkgs.gmp}"; } '' ( @@ -143,6 +138,13 @@ # extraLibraries works runghc ${./script} | grep -F 'TOML-flavored boolean: Bool True' + # removeReferencesTo: verify gmp reference was actually stripped from the binary + # (regression test for https://github.com/srid/haskell-flake/pull/287) + if grep -rq "$GMP_PATH" ${self'.packages.haskell-flake-test}/; then + echo "FAIL: removeReferencesTo didn't remove gmp reference from binary" + exit 2 + fi + touch $out ) ''; From 38896b13cead3af8cf58cbb026595aa6d0712eaf Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 15 Apr 2026 14:35:05 -0400 Subject: [PATCH 4/5] chore: gitignore .do-results.json --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1e0cb32c..ad2711aa 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ dist-newstyle # APM dependencies apm_modules/ +.do-results.json From 3bb1b5e7e25378dac949cba595dee32af6e10d38 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 15 Apr 2026 14:39:13 -0400 Subject: [PATCH 5/5] fix: check disallowedReferences in drvAttrs for removeReferencesTo test Use drvAttrs.disallowedReferences presence check instead of grepping the binary. This directly tests the PR #287 regression: if buildFromSdist (overrideCabal) runs after removeReferencesTo (overrideAttrs), it creates a new derivation that loses disallowedReferences. The current ordering (removeReferencesTo after buildFromSdist) preserves it. --- test/simple/flake.nix | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/test/simple/flake.nix b/test/simple/flake.nix index 97ff78da..b5b0ea1a 100644 --- a/test/simple/flake.nix +++ b/test/simple/flake.nix @@ -62,10 +62,12 @@ # # This jailbreak ignores the unsatisfiable version constraints on the library `foo`. jailbreak = true; - # Test removeReferencesTo setting (cf. https://github.com/srid/haskell-flake/issues/288) - # gmp is a real runtime reference from integer-gmp; this verifies the - # reference is actually stripped even with buildFromSdist enabled. - removeReferencesTo = [ pkgs.gmp ]; + # Test removeReferencesTo (cf. https://github.com/srid/haskell-flake/issues/288) + # Uses `hello` as the target. The assertion below verifies that + # disallowedReferences survives the buildFromSdist pipeline — the + # exact regression from PR #287 where overrideCabal in buildFromSdist + # would clobber the overrideAttrs from removeReferencesTo. + removeReferencesTo = [ pkgs.hello ]; }; }; devShell = { @@ -106,8 +108,16 @@ lib.assertMsg (config.haskellProjects.default.outputs.finalPackages.foo.TEST_RAW_ATTR == "test-value") "drvAttrs option should apply TEST_RAW_ATTR attribute"; - # For removeReferencesTo test: the store path to verify is gone - GMP_PATH = "${pkgs.gmp}"; + # Test removeReferencesTo: disallowedReferences must survive buildFromSdist. + # If the PR #287 ordering regression returns, overrideCabal in buildFromSdist + # will clobber the overrideAttrs from removeReferencesTo, and this assertion + # will fail because drvAttrs won't have disallowedReferences. + REMOVE_REFS = + let + finalPkg = config.haskellProjects.default.outputs.finalPackages.haskell-flake-test; + in + lib.assertMsg (finalPkg.drvAttrs ? disallowedReferences) + "removeReferencesTo: disallowedReferences missing from final package drvAttrs"; } '' ( @@ -138,13 +148,6 @@ # extraLibraries works runghc ${./script} | grep -F 'TOML-flavored boolean: Bool True' - # removeReferencesTo: verify gmp reference was actually stripped from the binary - # (regression test for https://github.com/srid/haskell-flake/pull/287) - if grep -rq "$GMP_PATH" ${self'.packages.haskell-flake-test}/; then - echo "FAIL: removeReferencesTo didn't remove gmp reference from binary" - exit 2 - fi - touch $out ) '';