|
24 | 24 | # you can pass the project in as a string. |
25 | 25 | rawCabalProject = if cabalProject != null |
26 | 26 | then cabalProject |
27 | | - else builtins.readFile (cabalFiles.origSrc + "/cabal.project"); |
| 27 | + else |
| 28 | + if ((builtins.readDir cabalFiles.origSrc)."cabal.project" or "") == "regular" |
| 29 | + then builtins.readFile (cabalFiles.origSrc + "/cabal.project") |
| 30 | + else null; |
28 | 31 |
|
29 | 32 | span = pred: list: |
30 | 33 | let n = pkgs.lib.lists.foldr (x: acc: if pred x then acc + 1 else 0) 0 list; |
|
69 | 72 | initialText = pkgs.lib.lists.take 1 blocks; |
70 | 73 | repoBlocks = builtins.map parseBlock (pkgs.lib.lists.drop 1 blocks); |
71 | 74 | sourceRepos = pkgs.lib.lists.concatMap (x: x.sourceRepo) repoBlocks; |
72 | | - in { |
73 | | - otherText = pkgs.lib.strings.concatStringsSep "\n" ( |
| 75 | + otherText = pkgs.writeText "cabal.project" (pkgs.lib.strings.concatStringsSep "\n" ( |
74 | 76 | initialText |
75 | | - ++ (builtins.map (x: x.otherText) repoBlocks)); |
| 77 | + ++ (builtins.map (x: x.otherText) repoBlocks))); |
| 78 | + in { |
76 | 79 | inherit sourceRepos; |
| 80 | + makeFixedProjectFile = '' |
| 81 | + cp -f ${otherText} ./cabal.project |
| 82 | + chmod +w -R ./cabal.project |
| 83 | + echo "packages:" >> ./cabal.project |
| 84 | + mkdir -p ./.source-repository-packages |
| 85 | + '' + |
| 86 | + ( pkgs.lib.strings.concatStrings ( |
| 87 | + pkgs.lib.lists.zipListsWith (n: f: '' |
| 88 | + mkdir -p ./.source-repository-packages/${builtins.toString n} |
| 89 | + rsync -a --prune-empty-dirs \ |
| 90 | + --include '*/' --include '*.cabal' --include 'package.yaml' \ |
| 91 | + --exclude '*' \ |
| 92 | + "${f}/" "./.source-repository-packages/${builtins.toString n}/" |
| 93 | + echo " ./.source-repository-packages/${builtins.toString n}" >> ./cabal.project |
| 94 | + '') |
| 95 | + (pkgs.lib.lists.range 0 ((builtins.length fixedProject.sourceRepos) - 1)) |
| 96 | + sourceRepos |
| 97 | + ) |
| 98 | + ); |
77 | 99 | }; |
78 | 100 |
|
79 | | - fixedProject = replaceSoureRepos rawCabalProject; |
| 101 | + fixedProject = |
| 102 | + if rawCabalProject == null |
| 103 | + then { |
| 104 | + sourceRepos = []; |
| 105 | + makeFixedProjectFile = ""; |
| 106 | + } |
| 107 | + else replaceSoureRepos rawCabalProject; |
80 | 108 |
|
81 | 109 | # Deal with source-repository-packages in a way that will work on |
82 | 110 | # hydra build agents (as long as a sha256 is included). |
|
89 | 117 | cd $tmp |
90 | 118 | cp -r ${cabalFiles}/* . |
91 | 119 | chmod +w -R . |
92 | | - cp -f ${fixedProjectFile} ./cabal.project |
93 | | - chmod +w -R ./cabal.project |
94 | | - echo "packages:" >> ./cabal.project |
95 | | - mkdir -p ./.source-repository-packages |
96 | | - '' + |
97 | | - ( pkgs.lib.strings.concatStrings ( |
98 | | - pkgs.lib.lists.zipListsWith (n: f: '' |
99 | | - mkdir -p ./.source-repository-packages/${builtins.toString n} |
100 | | - rsync -a --prune-empty-dirs \ |
101 | | - --include '*/' --include '*.cabal' --include 'package.yaml' \ |
102 | | - --exclude '*' \ |
103 | | - "${f}/" "./.source-repository-packages/${builtins.toString n}/" |
104 | | - echo " ./.source-repository-packages/${builtins.toString n}" >> ./cabal.project |
105 | | - '') |
106 | | - (pkgs.lib.lists.range 0 ((builtins.length fixedProject.sourceRepos) - 1)) |
107 | | - fixedProject.sourceRepos |
108 | | - ) |
109 | | - ) + '' |
| 120 | + ${fixedProject.makeFixedProjectFile} |
110 | 121 | # warning: this may not generate the proper cabal file. |
111 | 122 | # hpack allows globbing, and turns that into module lists |
112 | 123 | # without the source available (we cleaneSourceWith'd it), |
|
0 commit comments