Commit 01507bb1 authored by Ben Gamari's avatar Ben Gamari 🐢

Another approach

parent 418a98dc
......@@ -44,8 +44,15 @@ let
bootstrapHaskellPackages = self.haskell.packages.ghc865;
haskellPackages =
let patchesOverrides = self.callPackage patches {};
patches = self.callPackage (import ./scripts/overrides.nix) { patches = ./patches; };
let patchesOverrides = self.callPackage patches {
extraDepends = import scripts/extra-depends.nix {
pkgs = self;
hsPkgs = haskellPackages;
};
};
patches = self.callPackage (import ./scripts/overrides.nix) {
patches = ./patches;
};
overrides =
self.lib.composeExtensions
haskellOverrides
......
{ pkgs, hsPkgs }:
{
zlib = { inherit (pkgs) zlib; };
}
......@@ -29,19 +29,14 @@ generateOverrides prefix patchDir = do
mkOverride :: (PackageName, [([Int], String)]) -> String
mkOverride (display -> pName, patches) =
unlines $
[unwords [pName, "= if", superPname, "== null then", superPname]]
++ packages ++
[ "else", superPname, ";"]
unlines [ unwords $ [ pName, "=" ] ++ packages ++ [";"] ]
where
superPname = "super." ++ pName
quotes s = "\"" ++ s ++ "\""
packages :: [String]
packages = map mkPackages (sortBy (comparing fst) patches)
mkPackages (version, patch) =
unwords ["else if", superPname ++ ".version == "
, quotes (intercalate "." (map show version))
," then (", patch, ")"]
unwords ["(", patch, ")"]
override :: FilePath -> FilePath -> FilePath -> String -> PatchType -> String
override prefix patchDir extlessPath nixexpr ptype =
......@@ -55,11 +50,7 @@ generateOverride prefix patchDir (patchExtless, patchTypes) = do
version = versionNumbers (packageVersion pid)
versionStr = intercalate "." (map show version)
str x = "\""++x++"\""
--baseDrv = "super."++pname
--baseDrv = "(super.callHackage "++str pname++" "++str versionStr++" {})"
baseDrv =
let src = "fetchHackageTarball "++str pname++" "++str versionStr++" {})"
in "(super."++pname++".overrideAttrs (oldAttrs: { src="++str src++"; version="++str versionStr++"; }))"
baseDrv = "(super.callHackage "++str pname++" "++str versionStr++" (extraDepends."++pname++" or {}))"
return . (packageName pid,) . (version,) $
"haskell.lib.doJailbreak (dontRevise "
++ foldl' (override prefix patchDir patchExtless) baseDrv patchTypes ++ ")"
......@@ -92,10 +83,9 @@ main = do
[prefix, dir] -> return (prefix, dir)
_ -> fail "Usage: generate-nix-overrides [<prefix>, patchdir]"
overrides <- generateOverrides prefix patchDir
putStrLn "{haskell}:"
putStrLn "{ haskell, extraDepends ? {} }:"
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 "let fetchHackageTarball = pname: version: let component = haskellPackages.all-cabal-hashes-component pname version; v
putStrLn "self: super: {\n"
putStrLn overrides
putStrLn "}"
Markdown is supported
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