Skip to content

Commit eabf54a

Browse files
jessicahandreasabel
authored andcommitted
haiku: add as known platform
This combines via CPP two PRs by @jessicah: - #1217 (for Cabal >= 3.11) - #1221 (for Cabal <= 3.10)
1 parent 2a7d751 commit eabf54a

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

hackage-server.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ common defaults
130130
-- other dependencies shared by most components
131131
build-depends:
132132
, aeson ^>= 2.0.3.0 || ^>= 2.1.0.0
133-
, Cabal ^>= 3.10.1.0
134-
, Cabal-syntax ^>= 3.10.1.0
133+
, Cabal >= 3.10.1.0 && < 3.12
134+
, Cabal-syntax >= 3.10.1.0 && < 3.12
135135
-- Cabal-syntax needs to be bound to constrain hackage-security
136136
-- see https://github.com/haskell/hackage-server/issues/1130
137137
, fail ^>= 4.9.0

src/Distribution/Server/Framework/Instances.hs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE FlexibleContexts, BangPatterns, TypeFamilies #-}
23

34
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -119,6 +120,9 @@ instance SafeCopy VersionRange where
119120
instance SafeCopy OS where
120121
errorTypeName _ = "OS"
121122

123+
#if !MIN_VERSION_Cabal_syntax(3,11,0)
124+
putCopy (OtherOS "haiku") = contain $ putWord8 18
125+
#endif
122126
putCopy (OtherOS s) = contain $ putWord8 0 >> safePut s
123127
putCopy Linux = contain $ putWord8 1
124128
putCopy Windows = contain $ putWord8 2
@@ -137,6 +141,9 @@ instance SafeCopy OS where
137141
putCopy Hurd = contain $ putWord8 15
138142
putCopy Android = contain $ putWord8 16
139143
putCopy Wasi = contain $ putWord8 17
144+
#if MIN_VERSION_Cabal_syntax(3,11,0)
145+
putCopy Haiku = contain $ putWord8 18
146+
#endif
140147

141148
getCopy = contain $ do
142149
tag <- getWord8
@@ -159,6 +166,11 @@ instance SafeCopy OS where
159166
15 -> return Hurd
160167
16 -> return Android
161168
17 -> return Wasi
169+
#if MIN_VERSION_Cabal_syntax(3,11,0)
170+
18 -> return Haiku
171+
#else
172+
18 -> return $ OtherOS "haiku"
173+
#endif
162174
_ -> fail "SafeCopy OS getCopy: unexpected tag"
163175

164176
instance SafeCopy Arch where
@@ -382,7 +394,13 @@ instance Arbitrary OS where
382394
arbitrary = oneof [ pure OtherOS <*> vectorOf 3 (choose ('A', 'Z'))
383395
, pure Linux, pure Windows, pure OSX, pure FreeBSD
384396
, pure OpenBSD, pure NetBSD, pure Solaris, pure AIX
385-
, pure HPUX, pure IRIX, pure HaLVM, pure IOS ]
397+
, pure HPUX, pure IRIX, pure HaLVM, pure IOS
398+
#if MIN_VERSION_Cabal_syntax(3,11,0)
399+
, pure Haiku
400+
#else
401+
, pure $ OtherOS "haiku"
402+
#endif
403+
]
386404

387405
instance Arbitrary FlagName where
388406
arbitrary = mkFlagName <$> vectorOf 4 (choose ('a', 'z'))

0 commit comments

Comments
 (0)