|
| 1 | +{ |
| 2 | + lib, |
| 3 | + haskell, |
| 4 | + fetchFromGitHub, |
| 5 | +}: |
| 6 | +let |
| 7 | + hpkgs = haskell.packages.ghc9103; |
| 8 | + |
| 9 | + src = fetchFromGitHub { |
| 10 | + owner = "entropia"; |
| 11 | + repo = "tip-toi-reveng"; |
| 12 | + rev = "1.11"; |
| 13 | + hash = "sha256-4IsSghGX8Pc3S2DamOFuDkd+twMBwpE1C3tGS6pBJNM="; |
| 14 | + }; |
| 15 | + |
| 16 | + tttool = haskell.lib.compose.doJailbreak ( |
| 17 | + haskell.lib.overrideCabal (hpkgs.callCabal2nix "tttool" src { }) (_: { |
| 18 | + postPatch = '' |
| 19 | + # mtl >= 2.3: MonadFix no longer re-exported from Control.Monad.Writer.Lazy |
| 20 | + sed -i 's/import Control.Monad.Writer.Lazy/import Control.Monad.Fix\nimport Control.Monad.Writer.Lazy/' src/GMEWriter.hs |
| 21 | +
|
| 22 | + # HPDF >= 1.5: PDFFont takes AnyFont (not FontName); author field is Text. |
| 23 | + # Load the embedded Helvetica font once via unsafePerformIO (safe: constant data). |
| 24 | + sed -i 's/import Graphics.PDF$/import Graphics.PDF\nimport Graphics.PDF.Fonts.StandardFont (mkStdFont, FontName(..))\nimport Data.Text (pack)\nimport System.IO.Unsafe (unsafePerformIO)/' src/OidTable.hs |
| 25 | + sed -i 's/author=toPDFString \$/author=pack $/' src/OidTable.hs |
| 26 | + sed -i '/^import Types$/a \\n{-# NOINLINE helveticaFont #-}\nhelveticaFont :: AnyFont\nhelveticaFont = unsafePerformIO $ mkStdFont Helvetica >>= either (error . show) return' src/OidTable.hs |
| 27 | + sed -i 's/PDFFont Helvetica/PDFFont helveticaFont/g' src/OidTable.hs |
| 28 | + # HPDF >= 1.7: txt now takes Data.Text.Text instead of String |
| 29 | + sed -i 's/paragraph \$ txt title/paragraph $ txt (pack title)/' src/OidTable.hs |
| 30 | + sed -i 's/paragraph \$ txt \$ "Created by tttool-"/paragraph $ txt $ pack $ "Created by tttool-"/' src/OidTable.hs |
| 31 | + sed -i 's/paragraph \$ txt e$/paragraph $ txt (pack e)/' src/OidTable.hs |
| 32 | + sed -i 's/paragraph \$ txt \$ printf/paragraph $ txt $ pack $ printf/' src/OidTable.hs |
| 33 | + ''; |
| 34 | + }) |
| 35 | + ); |
| 36 | +in |
| 37 | +(haskell.lib.compose.justStaticExecutables tttool).overrideAttrs (_: { |
| 38 | + meta = { |
| 39 | + description = "Tool to work with files for the Ravensburger TipToi pen"; |
| 40 | + homepage = "https://github.com/entropia/tip-toi-reveng"; |
| 41 | + license = lib.licenses.mit; |
| 42 | + mainProgram = "tttool"; |
| 43 | + platforms = lib.platforms.unix; |
| 44 | + }; |
| 45 | +}) |
0 commit comments