From 37c68f322f1c124e85440461cba1c126db826540 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Wed, 1 Apr 2026 17:27:34 -0700 Subject: [PATCH] Add `--cabal-file-{sha256,revision}` arguments This lets `cabal2nix` generate derivations with `editedCabalFile` and `revision` fields. This functionality already exists in `hackage2nix` but wasn't exposed in `cabal2nix`. --- cabal2nix/src/Cabal2nix.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cabal2nix/src/Cabal2nix.hs b/cabal2nix/src/Cabal2nix.hs index ab853713..e687e82d 100644 --- a/cabal2nix/src/Cabal2nix.hs +++ b/cabal2nix/src/Cabal2nix.hs @@ -54,6 +54,8 @@ data Options = Options , optDoBenchmark :: Bool , optRevision :: Maybe String , optHyperlinkSource :: Bool + , optCabalFileSha256 :: Maybe String + , optCabalRevision :: Maybe Int , optEnableLibraryProfiling :: Bool , optEnableExecutableProfiling :: Bool , optEnableProfiling :: Maybe Bool @@ -99,6 +101,10 @@ options = do <- optional (strOption $ long "revision" <> help "revision to use when fetching from VCS") optHyperlinkSource <- flag True False (long "no-hyperlink-source" <> help "don't generate pretty-printed source code for the documentation") + optCabalFileSha256 + <- optional (strOption $ long "cabal-file-sha256" <> metavar "HASH" <> help "sha256 hash of the revised .cabal file (sets editedCabalFile in output)") + optCabalRevision + <- optional (option auto $ long "cabal-file-revision" <> metavar "N" <> help "revision number of the .cabal file (sets revision in output)") optEnableLibraryProfiling <- switch (long "enable-library-profiling" <> help "enable library profiling in the generated build") optEnableExecutableProfiling @@ -239,6 +245,8 @@ processPackage Options{..} pkg = do & doCheck &&~ optDoCheck & doBenchmark ||~ optDoBenchmark & extraFunctionArgs %~ Set.union (Set.fromList ("inherit lib":map (fromString . ("inherit " ++)) optExtraArgs)) + & maybe id (set editedCabalFile) optCabalFileSha256 + & maybe id (set revision) optCabalRevision shell :: Doc shell = vcat