Skip to content

Commit 9a2c675

Browse files
authored
Merge pull request #1352 from haskell/master
master2central december 2024
2 parents ec45aab + 5252a9c commit 9a2c675

File tree

8 files changed

+48
-22
lines changed

8 files changed

+48
-22
lines changed
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# https://github.com/DeterminateSystems/update-flake-lock
2+
name: update-flake-lock
3+
on:
4+
workflow_dispatch: # allows manual triggering
5+
schedule:
6+
- cron: '0 0 1 * *' # runs on first day of the month
7+
8+
jobs:
9+
lockfile:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
- name: Install Nix
15+
uses: DeterminateSystems/nix-installer-action@main
16+
- name: Update flake.lock
17+
uses: DeterminateSystems/update-flake-lock@main
18+
with:
19+
pr-title: "Update flake.lock" # Title of PR to be created
20+
pr-labels: | # Labels to be set on the PR
21+
dependencies
22+
automated

datafiles/static/hackage.css

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ table {
147147
font:100%;
148148
}
149149

150+
pre {
151+
border-radius: 3px;
152+
}
153+
150154
pre, code, kbd, samp, .src {
151155
font-family: monospace;
152156
}

datafiles/templates/Html/package-page.html.st

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<link href="$doc.baseUrl$/quick-jump.css" rel="stylesheet" type="text/css" title="QuickJump" />
66
$endif$
77
$hackageCssTheme()$
8+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/themes/prism-solarizedlight.min.css" media="(prefers-color-scheme: light)" />
9+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/themes/prism-tomorrow.min.css" media="(prefers-color-scheme: dark)" />
810
<title>
911
$package.name$$if(package.optional.hasSynopsis)$: $package.optional.synopsis$$endif$
1012
</title>
@@ -292,6 +294,8 @@
292294
[<a href="#description">back to package description</a>]
293295
$package.optional.readme$
294296
</div>
297+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-core.min.js"></script>
298+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/plugins/autoloader/prism-autoloader.min.js"></script>
295299
$endif$
296300
</div> <!-- /content -->
297301

flake.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
echo 'Copying packages from real Hackage Server into local Hackage Server.'
3838
echo 'This assumes the local Hackage Server uses default credentials;'
3939
echo 'otherwise, override in nix-default-servers.cfg'
40-
hackage-mirror nix-default-servers.cfg
40+
hackage-mirror nix-default-servers.cfg "$@"
4141
'';
4242
};
4343
packages.default = config.packages.hackage-server;

src/Distribution/Server/Features/Documentation.hs

+10-8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Distribution.Server.Framework.BlobStorage (BlobId)
2323
import qualified Distribution.Server.Framework.BlobStorage as BlobStorage
2424
import qualified Distribution.Server.Util.ServeTarball as ServerTarball
2525
import qualified Distribution.Server.Util.DocMeta as DocMeta
26+
import qualified Distribution.Server.Util.GZip as Gzip
2627
import Distribution.Server.Features.BuildReports.BuildReport (PkgDetails(..), BuildStatus(..))
2728
import Data.TarIndex (TarIndex)
2829
import qualified Codec.Archive.Tar as Tar
@@ -46,7 +47,6 @@ import Data.Time.Clock (NominalDiffTime, diffUTCTime, getCurrentTime)
4647
import System.Directory (getModificationTime)
4748
import Control.Applicative
4849
import Distribution.Server.Features.PreferredVersions
49-
import Distribution.Server.Features.PreferredVersions.State (getVersionStatus)
5050
import Distribution.Server.Packages.Types
5151
-- TODO:
5252
-- 1. Write an HTML view for organizing uploads
@@ -327,8 +327,10 @@ documentationFeature name
327327
-- \* Generate the new index
328328
-- \* Drop the index for the old tar-file
329329
-- \* Link the new documentation to the package
330-
fileContents <- expectUncompressedTarball
331-
mres <- liftIO $ BlobStorage.addWith store fileContents
330+
fileContents <- expectCompressedTarball
331+
let filename = display pkgid ++ "-docs" <.> "tar.gz"
332+
unpacked = Gzip.decompressNamed filename fileContents
333+
mres <- liftIO $ BlobStorage.addWith store unpacked
332334
(\content -> return (checkDocTarball pkgid content))
333335
case mres of
334336
Left err -> errBadRequest "Invalid documentation tarball" [MText err]
@@ -377,15 +379,15 @@ documentationFeature name
377379
helper (pkg:pkgs) = do
378380
hasDoc <- queryHasDocumentation (pkgInfoId pkg)
379381
let status = getVersionStatus prefInfo (packageVersion pkg)
380-
if hasDoc && status == NormalVersion
381-
then pure (Just (packageId pkg))
382+
if hasDoc && status == NormalVersion
383+
then pure (Just (packageId pkg))
382384
else helper pkgs
383385

384386
helper2 [] = pure Nothing
385387
helper2 (pkg:pkgs) = do
386388
hasDoc <- queryHasDocumentation (pkgInfoId pkg)
387389
if hasDoc
388-
then pure (Just (packageId pkg))
390+
then pure (Just (packageId pkg))
389391
else helper2 pkgs
390392

391393
withDocumentation :: Resource -> DynamicPath
@@ -400,7 +402,7 @@ documentationFeature name
400402
then (var, unPackageName $ pkgName pkgid)
401403
else e
402404
| e@(var, _) <- dpath ]
403-
basePkgPath = (renderResource' self basedpath)
405+
basePkgPath = renderResource' self basedpath
404406
canonicalLink = show serverBaseURI ++ basePkgPath
405407
canonicalHeader = "<" ++ canonicalLink ++ ">; rel=\"canonical\""
406408

@@ -484,7 +486,7 @@ checkDocTarball pkgid =
484486
------------------------------------------------------------------------------}
485487

486488
mapParaM :: Monad m => (a -> m b) -> [a] -> m [(a, b)]
487-
mapParaM f = mapM (\x -> (,) x `liftM` f x)
489+
mapParaM f = mapM (\x -> (,) x <$> f x)
488490

489491
getFileAge :: FilePath -> IO NominalDiffTime
490492
getFileAge file = diffUTCTime <$> getCurrentTime <*> getModificationTime file

src/Distribution/Server/Features/PackageInfoJSON.hs

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ initPackageInfoJSONFeature env = do
8585
return $ \core preferred -> do
8686

8787
let coreR = coreResource core
88-
info = "Get basic package information"
88+
info = "Get basic package information: \
89+
\The response contains a JSON object where the keys are version numbers as strings, \
90+
\and the values are whether the version is preferred or not"
8991
vInfo = "Get basic package information at a specific metadata revision"
9092

9193
jsonResources = [

src/Distribution/Server/Framework/RequestContentTypes.hs

+1-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module Distribution.Server.Framework.RequestContentTypes (
1919

2020
-- * various specific content types
2121
expectTextPlain,
22-
expectUncompressedTarball,
2322
expectCompressedTarball,
2423
expectAesonContent,
2524
expectCSV,
@@ -102,15 +101,6 @@ gzipDecompress content = go content decompressor
102101
expectTextPlain :: ServerPartE LBS.ByteString
103102
expectTextPlain = expectContentType "text/plain"
104103

105-
-- | Expect an uncompressed @.tar@ file.
106-
--
107-
-- The tar file is not validated.
108-
--
109-
-- A content-encoding of \"gzip\" is handled transparently.
110-
--
111-
expectUncompressedTarball :: ServerPartE LBS.ByteString
112-
expectUncompressedTarball = expectContentType "application/x-tar"
113-
114104
-- | Expect a compressed @.tar.gz@ file.
115105
--
116106
-- Neither the gzip encoding nor the tar format are validated.
@@ -128,7 +118,7 @@ expectCompressedTarball = do
128118
Just actual
129119
| actual == "application/x-tar"
130120
, contentEncoding == Just "gzip" -> consumeRequestBody
131-
| actual == "application/x-gzip"
121+
| actual == "application/gzip" || actual == "application/x-gzip"
132122
, contentEncoding == Nothing -> consumeRequestBody
133123
_ -> errExpectedTarball
134124
where

src/Distribution/Server/Packages/Unpack.hs

+3-1
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,11 @@ specVersionChecks specVerOk specVer = do
219219
when (specVer < CabalSpecV1_10) $
220220
throwError "'cabal-version' must be at least 1.10"
221221

222-
-- To keep people from uploading packages most users cannot use.
222+
-- To keep people from uploading packages most users cannot use. Disabled for now.
223+
{-
223224
unless (specVer <= CabalSpecV3_6) $
224225
throwError "'cabal-version' must be at most 3.6"
226+
-}
225227

226228
-- | The issue is that browsers can upload the file name using either unix
227229
-- or windows convention, so we need to take the basename using either

0 commit comments

Comments
 (0)