Skip to content

Add Backpack support. #1806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
b68a8a1
Add Backpack support.
Sep 24, 2021
e50d1bd
Add test. Fix review comments.
Dec 16, 2022
43a9cb8
Add second test with two instantiations.
Dec 20, 2022
cfab953
Get buildable test back.
Dec 21, 2022
87b40ff
Add bkpcabal01 test from cabal testsuite.
Dec 26, 2022
9d1cf22
Add Includes2 test from cabal testsuite.
Feb 17, 2023
601f688
Add Includes3
Feb 17, 2023
c77fd3a
Update Hackage and Stackage
Feb 23, 2023
039d95c
Update Hackage and Stackage
Feb 24, 2023
4f0aeec
Update Hackage and Stackage
Feb 25, 2023
ce19872
Update Hackage and Stackage
Feb 26, 2023
6917d07
Update Hackage and Stackage
Feb 27, 2023
2dbb385
Update Hackage and Stackage
Feb 28, 2023
a465104
Update Hackage and Stackage
Mar 1, 2023
54ddb88
Update Hackage and Stackage
Mar 3, 2023
6be1284
Update Hackage and Stackage
Mar 4, 2023
c7ab0a4
Update Hackage and Stackage
Mar 5, 2023
230a799
Update Hackage and Stackage
Mar 6, 2023
79f901c
Update Hackage and Stackage
Mar 7, 2023
53e2e1a
Update Hackage and Stackage
Mar 8, 2023
d9e1eeb
Update Hackage and Stackage
Mar 9, 2023
36be40b
Update Hackage and Stackage
Mar 10, 2023
8845746
Update Hackage and Stackage
Mar 11, 2023
dabe365
Update Hackage and Stackage
Mar 12, 2023
1931916
Update Hackage and Stackage
Mar 13, 2023
6091b39
Update Hackage and Stackage
Mar 14, 2023
efbe2ed
Update Hackage and Stackage
Mar 15, 2023
8ee2dec
Update Hackage and Stackage
Mar 16, 2023
fca642a
Update Hackage and Stackage
Mar 17, 2023
f9b5a4f
Update Hackage and Stackage
Mar 18, 2023
1f1876f
Update Hackage and Stackage
Mar 19, 2023
0303d65
Update Hackage and Stackage
Mar 20, 2023
a53d27c
Update Hackage and Stackage
Mar 21, 2023
2badee2
Update Hackage and Stackage
Mar 22, 2023
29b8b5f
Update Hackage and Stackage
Mar 23, 2023
f4d349a
Update Hackage and Stackage
Mar 24, 2023
59a2d70
Update Hackage and Stackage
Mar 25, 2023
c728663
Update Hackage and Stackage
Mar 26, 2023
b933ec7
Update Hackage and Stackage
Mar 27, 2023
40abff8
Update Hackage and Stackage
Mar 28, 2023
a8eded8
Update Hackage and Stackage
Mar 29, 2023
80c52c6
Update Hackage and Stackage
Mar 30, 2023
00a2429
Update Hackage and Stackage
Mar 31, 2023
2ed4b72
Update Hackage and Stackage
Apr 1, 2023
4e4a900
Update Hackage and Stackage
Apr 2, 2023
55ef36e
Update Hackage and Stackage
Apr 3, 2023
7417b7f
Update Hackage and Stackage
Apr 4, 2023
2e2114f
Update Hackage and Stackage
Apr 5, 2023
2b1967b
Update Hackage and Stackage
Apr 6, 2023
164d22f
Update Hackage and Stackage
Apr 8, 2023
875b265
Update Hackage and Stackage
Apr 9, 2023
9aa2f10
Update Hackage and Stackage
Apr 10, 2023
a29642c
Update Hackage and Stackage
Apr 11, 2023
b038211
Update Hackage and Stackage
Apr 12, 2023
c1a2855
Update Hackage and Stackage
Apr 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions builder/comp-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,22 @@ let

disableFeature = disable: enableFeature (!disable);

# This function uses nested sed commands to
# 1. Uses sed to build a regex line for (2) command by replacing 'inplace' with a regex.
# 2. Extracts the packageId from the configure-flags file using the regex from (1).
# 3. Replaces the 'inplace' substring with the extracted packageId in 'instLine' configuration line.
replaceInplaceWithAbiHash = instLine:
if lib.strings.hasInfix "inplace" instLine then
let
# We print the 'instLine' and replace the 'inplace' substring with a regex which we will use later
instLineWithRegex = "<(echo ${instLine} | sed -n -e 's/.*=\\(.*\\)-inplace-\\(.*\\):.*/\\1-\\\\\\\\([^\"]*\\\\\\\\)-\\2/p')";
# We execute 'instLineWithRegex' into 'sedline' variable and use it again to extract the packageId from 'configure-flags'
packageIdLine = "<(read sedline < ${instLineWithRegex}; sed -n -e \"s/.*\$\{sedline\}/\\1/p\" ${configFiles}/configure-flags | head -1)";
in
# We read the packageId from the previous sed command and replace the 'inplace' substring with 'packageId'
"$(read packageId < ${packageIdLine}; echo ${instLine} | sed -n -e \"s/\\(.*\\)-inplace-\\(.*\\)/\\1-\$\{packageId\}-\\2/p\")"
else instLine;

finalConfigureFlags = lib.concatStringsSep " " (
[ "--prefix=$out"
] ++
Expand All @@ -161,8 +177,21 @@ let
if configureAllComponents
then ["--enable-tests" "--enable-benchmarks"]
else ["${haskellLib.componentTarget componentId}"]
) ++ [ "$(cat ${configFiles}/configure-flags)"
] ++ commonConfigureFlags);
) ++ [
# We have to use sed here to patch 'configure-flags' file to drop the abi hash suffix.
#
# plan2nix created packages for sublibs with instantiated signatures and they have
# names like 'domain+EwFBnH3u8XWEhAhZr7XmS1' where 'domain' is the original sublib's name.
#
# To build them we pass the folllowing configure flags:
# '--dependency=<package-name>:<sublib-name>=<package-name>-<version>-<abi-hash>-domain+EwFBnH3u8XWEhAhZr7XmS1'
# which is incorrect and the build fails. The build of the instantiated sublib should be called just like for
# the original sublib:
# '--dependency=<package-name>:<sublib-name>=<package-name>-<version>-<abi-hash>-domain'
"$(sed 's/--dependency=\\(.*\\)+\\(.*\\)/--dependency=\\1/' ${configFiles}/configure-flags)"
] ++ commonConfigureFlags ++
(map (arg: "--instantiate-with=" + replaceInplaceWithAbiHash arg) component.instantiatedWith)
);

# From nixpkgs 20.09, the pkg-config exe has a prefix matching the ghc one
pkgConfigHasPrefix = builtins.compareVersions lib.version "20.09pre" >= 0;
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ in {

# Format a componentId as it should appear as a target on the
# command line of the setup script.
componentTarget = componentId:"${componentId.ctype}:${componentId.cname}";
#
# We omit the suffix that starts with '+' because libraries with instantiated signatures are being built by their usual name.
componentTarget = componentId:"${componentId.ctype}:${builtins.head (builtins.split "\\+" componentId.cname)}";

# Remove null or empty values from an attrset.
optionalHooks = lib.filterAttrs (_: hook: hook != null && hook != "");
Expand Down
1 change: 1 addition & 0 deletions modules/configuration-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ in {
packages.cabal-install.patches = [
(fromUntil "3.4.0.0" "3.5" ../overlays/patches/Cabal/Cabal-3.4-defer-build-tool-depends-7532.patch)
(fromUntil "3.4.0.0" "3.5" ../overlays/patches/Cabal/Cabal-3.4-speedup-solver-when-tests-enabled-7490.patch)
(fromUntil "3.6.0.0" "3.9.0.0" ../overlays/patches/Cabal/Cabal-3.6.0.0-instantiated-with.diff)
];

# Avoid dependency on genprimopcode and deriveConstants (cabal does not put these in the plan,
Expand Down
4 changes: 4 additions & 0 deletions modules/plan.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ let
type = bool;
default = true;
};
instantiatedWith = mkOption {
type = listOfFilteringNulls str;
default = (def.instantiatedWith or []);
};
configureFlags = mkOption {
type = listOfFilteringNulls str;
default = (def.configureFlags or []);
Expand Down
Loading