Verified Commit bde37672 authored by Ellie Hermaszewska's avatar Ellie Hermaszewska
Browse files

generate-nix-overrides.hs: Use haskell.lib.compose

This is passed in as haskellLib, as in convention in nixpkgs, to allow easy of
calling the generated override file from
pkgs/development/haskell-modules/default.nix in nixpkgs.

haskell.lib.compose is a set of "more composable" haskell library functions,
they take the "pkg" argument last.

See https://github.com/NixOS/nixpkgs/pull/142940 for more info.
parent c50d7587
Pipeline #44035 failed with stages
in 174 minutes and 37 seconds
......@@ -26,7 +26,7 @@ self: super:
ghcHEAD = super.haskell.packages.ghcHEAD.override
{ overrides = sel: sup:
# The patches from the directory
((super.callPackage self.patches {} sel sup)
((super.callPackage self.patches { haskellLib = haskell.lib.compose; } sel sup)
# Any more local overrides you want.
// { mkDerivation = drv: sup.mkDerivation
( drv // { jailbreak = true; doHaddock = false; });
......
......@@ -45,7 +45,7 @@ mkOverride (display -> pName, patches) =
override :: FilePath -> FilePath -> FilePath -> String -> PatchType -> String
override prefix patchDir extlessPath nixexpr ptype =
unwords ["(", patchFunction ptype, nixexpr, prefix </> patchDir </> addExtension extlessPath (patchTypeExt ptype), ")"]
unwords ["(", patchFunction ptype, prefix </> patchDir </> addExtension extlessPath (patchTypeExt ptype), nixexpr, ")"]
generateOverride :: FilePath -> FilePath -> (FilePath, [PatchType]) -> IO (PackageName, ([Int], String))
generateOverride prefix patchDir (patchExtless, patchTypes) = do
......@@ -54,13 +54,13 @@ generateOverride prefix patchDir (patchExtless, patchTypes) = do
let pname = display (packageName pid)
version = versionNumbers (packageVersion pid)
return . (packageName pid,) . (version,) $
"haskell.lib.doJailbreak (dontRevise "
"haskellLib.doJailbreak (dontRevise "
++ foldl' (override prefix patchDir patchExtless) ("super."++pname) patchTypes ++ ")"
patchFunction :: PatchType -> String
patchFunction = \case
CabalPatch -> "setCabalFile"
NormalPatch -> "haskell.lib.appendPatch"
NormalPatch -> "haskellLib.appendPatch"
patchTypeExt :: PatchType -> String
patchTypeExt = \case
......@@ -85,9 +85,9 @@ main = do
[prefix, dir] -> return (prefix, dir)
_ -> fail "Usage: generate-nix-overrides [<prefix>, patchdir]"
overrides <- generateOverrides prefix patchDir
putStrLn "{haskell}:"
putStrLn "let dontRevise = pkg: haskell.lib.overrideCabal pkg (old: { editedCabalFile = null; }); in"
putStrLn "let setCabalFile = pkg: file: haskell.lib.overrideCabal pkg (old: { postPatch = ''cp ${file} ${old.pname}.cabal''; }); in"
putStrLn "{haskellLib}:"
putStrLn "let dontRevise = haskellLib.overrideCabal (old: { editedCabalFile = null; }); in"
putStrLn "let setCabalFile = file: haskellLib.overrideCabal (old: { postPatch = ''cp ${file} ${old.pname}.cabal''; }); in"
putStrLn "self: super: {\n"
putStrLn overrides
putStrLn "}"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment