git.iko.soy/typeable/cabal2nix
on master help sign in
hackage4nix.hs: add --force flag to force re-generation of expressions even if they contain patchPhase sections, etc.
commitf810f1662d21fd067ae677ef8c6fb9e2a3f31d1b authorPeter Simons <simons@cryp.to> dateMon 12 Aug 2013, 21:05 (13 years ago) parent4a591c8
1 file changed+8−2
src/hackage4nix.hs+8−2
src/hackage4nix.hs+8−2
@@ -29,6 +29,7 @@ data Configuration = Configuration
2929 { _msgDebug :: String -> IO ()
3030 , _msgInfo :: String -> IO ()
3131 , _hackageDb :: DB.Hackage
32+ , _force :: Bool
3233 }
3334
3435defaultConfiguration :: Configuration
@@ -36,6 +37,7 @@ defaultConfiguration = Configuration
3637 { _msgDebug = hPutStrLn stderr
3738 , _msgInfo = hPutStrLn stderr
3839 , _hackageDb = DB.empty
40+ , _force = False
3941 }
4042
4143type Hackage4Nix a = RWST Configuration () PkgSet IO a
@@ -79,7 +81,9 @@ parseNixFile path buf
7981 | any (`isSuffixOf`path) badPackagePaths
8082 = msgDebug ("ignore known bad package " ++ path) >> return Nothing
8183 | Just deriv <- parseDerivation buf
82− = return (Just (Pkg deriv path (regenerateDerivation deriv buf)))
84+ = do forceReGen <- asks _force
85+ let reGen = regenerateDerivation deriv buf
86+ return (Just (Pkg deriv path (forceReGen || reGen)))
8387 | otherwise = msgInfo ("failed to parse file " ++ path) >> return Nothing
8488
8589selectLatestVersions :: PkgSet -> PkgSet
@@ -163,7 +167,7 @@ normalizeMaintainer x
163167 | "self.stdenv.lib.maintainers." `isPrefixOf` x = drop 28 x
164168 | otherwise = x
165169
166−data CliOption = PrintHelp | Verbose
170+data CliOption = PrintHelp | Verbose | ForceRegen
167171 deriving (Eq)
168172
169173main :: IO ()
@@ -172,6 +176,7 @@ main = bracket (return ()) (\() -> hFlush stdout >> hFlush stderr) $ \() -> do
172176 options =
173177 [ Option "h" ["help"] (NoArg PrintHelp) "show this help text"
174178 , Option "v" ["verbose"] (NoArg Verbose) "enable noisy debug output"
179+ , Option "" ["force"] (NoArg ForceRegen) "re-generate all files in place"
175180 ]
176181
177182 usage :: String
@@ -198,6 +203,7 @@ main = bracket (return ()) (\() -> hFlush stdout >> hFlush stderr) $ \() -> do
198203 let cfg = defaultConfiguration
199204 { _msgDebug = if Verbose `elem` opts then _msgDebug defaultConfiguration else const (return ())
200205 , _hackageDb = hackage
206+ , _force = ForceRegen `elem` opts
201207 }
202208 ((),_,()) <- runRWST (updateNixPkgs args) cfg Set.empty
203209 return ()