horizon-gen-nix 0.4.0 → 0.5
raw patch · 4 files changed
+27/−10 lines, 4 filesdep ~horizon-spec
Dependency ranges changed: horizon-spec
Files
- ChangeLog.md +5/−0
- horizon-gen-nix.cabal +2/−2
- src/Horizon/Gen/Nix/Writers.hs +20/−6
- test/Spec.hs +0/−2
ChangeLog.md view
@@ -1,5 +1,10 @@ # Changelog for horizon-gen-nix +## v0.5++* Support horizon-spec 0.5+* Settings `includeBenchmarks` and `includeTests` to false will remove the dependencies from the inputs for that package expression.+ ## v0.4.0 * Support horizon-spec 0.4.1
horizon-gen-nix.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: horizon-gen-nix-version: 0.4.0+version: 0.5 synopsis: Generate nix expressions from horizon-spec definitions description: Generate nix expressions from horizon-spec definitions category: Package Management, Nix@@ -49,7 +49,7 @@ , directory , distribution-nixpkgs , either- , horizon-spec >=0.4 && <0.5+ , horizon-spec >=0.4 && <0.6 , language-nix , lens , optparse-applicative
src/Horizon/Gen/Nix/Writers.hs view
@@ -9,13 +9,17 @@ ) where import Cabal2nix (Options, cabal2nix')-import Control.Monad (forM_, unless, (>=>))+import Control.Lens ((%~), (&))+import Control.Monad (forM_, unless) import Data.Map (keys, toList) import qualified Data.Text as T-import Distribution.Nixpkgs.Haskell.Derivation (Derivation)+import Distribution.Nixpkgs.Haskell.Derivation (Derivation,+ benchmarkDepends,+ testDepends) import Horizon.Gen.Nix.Cabal2Nix.Options (haskellPackageToCabal2NixOptions) import Horizon.Gen.Nix.Pretty (prettyDerivation) import Horizon.Spec (HaskellPackage,+ Modifiers, Name (MkName), Overlay (MkOverlay), OverlayFile (MkOverlayFile),@@ -24,7 +28,10 @@ PackageSetFile (MkPackageSetFile), PackagesDir (MkPackagesDir), fromName,- fromPackageList)+ fromPackageList,+ includeBenchmarks,+ includeTests,+ modifiers) import Path (File, Path, parseRelFile, toFilePath, (</>))@@ -60,9 +67,16 @@ hPutStrLn h "" hPutStrLn h "}" -writeCabal2Nix :: Path b File -> Options -> IO ()-writeCabal2Nix f = hSilence [stdout, stderr] . cabal2nix' >=> either (print . render) (writeDerivation f)+applyModifiersToDerivation :: Modifiers -> Derivation -> Derivation+applyModifiersToDerivation ms drv = drv & testDepends %~ (\x -> if includeTests ms then x else mempty)+ & benchmarkDepends %~ (\x -> if includeBenchmarks ms then x else mempty) +writeCabal2Nix :: Path b File -> Modifiers -> Options -> IO ()+writeCabal2Nix f ms opts = do+ putStrLn $ "Fetching " <> toFilePath f+ x <- hSilence [stdout, stderr] . cabal2nix' $ opts+ either (print . render) (writeDerivation f . applyModifiersToDerivation ms) x+ writeDerivation :: Path b File -> Derivation -> IO () writeDerivation f = writeFile (toFilePath f) . show . prettyDerivation @@ -73,7 +87,7 @@ f' <- parseRelFile $ T.unpack (f <> ".nix") let j = d </> f' q <- doesFileExist $ toFilePath j- unless q $ writeCabal2Nix j o+ unless q $ writeCabal2Nix j (modifiers y) o writeHaskellPackages :: PackagesDir -> PackageList -> IO () writeHaskellPackages d = mapM_ (uncurry $ writeHaskellPackage d) . toList . fromPackageList
test/Spec.hs view
@@ -21,7 +21,6 @@ , $(mkRelFile "pkgs/lens.nix") , $(mkRelFile "pkgs/Cabal-syntax.nix") , $(mkRelFile "pkgs/network-mux.nix")- , $(mkRelFile "pkgs/myPackage.nix") ] outputFilesPackageSetRel :: [Path Rel File]@@ -30,7 +29,6 @@ , $(mkRelFile "pkgs/lens.nix") , $(mkRelFile "pkgs/Cabal-syntax.nix") , $(mkRelFile "pkgs/network-mux.nix")- , $(mkRelFile "pkgs/myPackage.nix") ] runHorizonGenNixFor :: FilePath -> IO ()