Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
Pipeline #44035 failed
...@@ -26,7 +26,7 @@ self: super: ...@@ -26,7 +26,7 @@ self: super:
ghcHEAD = super.haskell.packages.ghcHEAD.override ghcHEAD = super.haskell.packages.ghcHEAD.override
{ overrides = sel: sup: { overrides = sel: sup:
# The patches from the directory # 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. # Any more local overrides you want.
// { mkDerivation = drv: sup.mkDerivation // { mkDerivation = drv: sup.mkDerivation
( drv // { jailbreak = true; doHaddock = false; }); ( drv // { jailbreak = true; doHaddock = false; });
......
...@@ -45,7 +45,7 @@ mkOverride (display -> pName, patches) = ...@@ -45,7 +45,7 @@ mkOverride (display -> pName, patches) =
override :: FilePath -> FilePath -> FilePath -> String -> PatchType -> String override :: FilePath -> FilePath -> FilePath -> String -> PatchType -> String
override prefix patchDir extlessPath nixexpr ptype = 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 :: FilePath -> FilePath -> (FilePath, [PatchType]) -> IO (PackageName, ([Int], String))
generateOverride prefix patchDir (patchExtless, patchTypes) = do generateOverride prefix patchDir (patchExtless, patchTypes) = do
...@@ -54,13 +54,13 @@ generateOverride prefix patchDir (patchExtless, patchTypes) = do ...@@ -54,13 +54,13 @@ generateOverride prefix patchDir (patchExtless, patchTypes) = do
let pname = display (packageName pid) let pname = display (packageName pid)
version = versionNumbers (packageVersion pid) version = versionNumbers (packageVersion pid)
return . (packageName pid,) . (version,) $ return . (packageName pid,) . (version,) $
"haskell.lib.doJailbreak (dontRevise " "haskellLib.doJailbreak (dontRevise "
++ foldl' (override prefix patchDir patchExtless) ("super."++pname) patchTypes ++ ")" ++ foldl' (override prefix patchDir patchExtless) ("super."++pname) patchTypes ++ ")"
patchFunction :: PatchType -> String patchFunction :: PatchType -> String
patchFunction = \case patchFunction = \case
CabalPatch -> "setCabalFile" CabalPatch -> "setCabalFile"
NormalPatch -> "haskell.lib.appendPatch" NormalPatch -> "haskellLib.appendPatch"
patchTypeExt :: PatchType -> String patchTypeExt :: PatchType -> String
patchTypeExt = \case patchTypeExt = \case
...@@ -85,9 +85,9 @@ main = do ...@@ -85,9 +85,9 @@ main = do
[prefix, dir] -> return (prefix, dir) [prefix, dir] -> return (prefix, dir)
_ -> fail "Usage: generate-nix-overrides [<prefix>, patchdir]" _ -> fail "Usage: generate-nix-overrides [<prefix>, patchdir]"
overrides <- generateOverrides prefix patchDir overrides <- generateOverrides prefix patchDir
putStrLn "{haskell}:" putStrLn "{haskellLib}:"
putStrLn "let dontRevise = pkg: haskell.lib.overrideCabal pkg (old: { editedCabalFile = null; }); in" putStrLn "let dontRevise = haskellLib.overrideCabal (old: { editedCabalFile = null; }); in"
putStrLn "let setCabalFile = pkg: file: haskell.lib.overrideCabal pkg (old: { postPatch = ''cp ${file} ${old.pname}.cabal''; }); in" putStrLn "let setCabalFile = file: haskellLib.overrideCabal (old: { postPatch = ''cp ${file} ${old.pname}.cabal''; }); in"
putStrLn "self: super: {\n" putStrLn "self: super: {\n"
putStrLn overrides putStrLn overrides
putStrLn "}" putStrLn "}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment