git.iko.soy/typeable/stackage2nix
on master help sign in
Add: write build derivation to file
commit8d273a435d6ea2c29a97fb9d24a576b8b5cc9987 authorDmitry Bushev <bushevdv@gmail.com> dateSat 10 Jun 2017, 17:58 (9 years ago) parentba12e01
4 files changed+17−4
.gitignore+1 src/Runner.hs+2−1 src/Runner/Cli.hs+11−2 test.sh+3−1
.gitignore+1
@@ -1,2 +1,3 @@
11.stack-work
2+default.nix
23/nix
src/Runner.hs+2−1
@@ -19,7 +19,8 @@ run = do
1919 $ stackYaml ^. scPackages
2020 let
2121 out = PP.overrideHaskellPackages overrideConfig packages
22− print out
22+ writeFile (opts ^. optOutFile) (show out)
23+ putStrLn $ "\nDerivation was written to " ++ opts ^. optOutFile
2324
2425mkOverrideConfig :: Options -> OverrideConfig
2526mkOverrideConfig opts = OverrideConfig
src/Runner/Cli.hs+11−2
@@ -26,7 +26,8 @@ newtype StackageConfig = StackageConfig { unStackageConfig :: FilePath }
2626makePrisms ''StackageConfig
2727
2828data Options = Options
29− { _optHackageDb :: !(Maybe HackageDb)
29+ { _optOutFile :: !FilePath
30+ , _optHackageDb :: !(Maybe HackageDb)
3031 , _optStackagePackages :: !(Maybe StackagePackages)
3132 , _optStackageConfig :: !(Maybe StackageConfig)
3233 , _optCompilerId :: !CompilerId
@@ -38,7 +39,8 @@ makeLenses ''Options
3839
3940options :: Parser Options
4041options = Options
41− <$> optional hackageDb
42+ <$> outFile
43+ <*> optional hackageDb
4244 <*> optional stackagePackages
4345 <*> optional stackageConfig
4446 <*> compilerId
@@ -52,6 +54,13 @@ pinfo = info
5254 ( fullDesc
5355 <> header "stack2nix converts Stack files into build instructions for Nix." )
5456
57+outFile :: Parser FilePath
58+outFile = option str
59+ ( long "nix-out-file"
60+ <> metavar "NIX_OUT_FILE"
61+ <> help "path where to write output derivation"
62+ <> value "default.nix" )
63+
5564stackResolver :: Parser StackResolver
5665stackResolver = StackResolver <$>
5766 option text
test.sh+3−1
@@ -1,3 +1,5 @@
11#!/usr/bin/env sh
22
3−exec stack2nix --nix-stackage-config=nix/configuration-packages.nix --nix-stackage-packages=./nix/packages.nix
3+stack2nix --nix-stackage-config=nix/configuration-packages.nix --nix-stackage-packages=./nix/packages.nix
4+
5+nix-build -A stack2nix --dry-run