git.iko.soy/typeable/cabal2nix
on master help sign in
generate src/Cabal2Nix/Version.hs automatically with a proper "git describe" version
commit86547cf735171dc80b462139cb155c2eaa310554 authorPeter Simons <simons@cryp.to> dateSun 25 Jan 2015, 20:32 (12 years ago) parent575a282
3 files changed+11−7
.gitignore+1 generate-cabal-file.hs+10 src/Cabal2Nix/Version.hs−7
.gitignore+1
@@ -5,6 +5,7 @@
55/Setup.o
66/cabal2nix.cabal
77/dist/*
8+/src/Cabal2Nix/Version.hs
89
910# vim tmp files
1011
generate-cabal-file.hs+10
@@ -11,6 +11,11 @@ getVersion = do
1111 let y4:y3:y2:y1:'-':m2:m1:'-':d2:d1:[] = head (words v)
1212 return (read ('[':y4:y3:y2:y1:',':m2:m1:',':d2:d1:"]"))
1313
14+getGitVersion :: IO String
15+getGitVersion = do
16+ [v] <- fmap lines (readProcess "git" ["describe", "--dirty"] "")
17+ return v
18+
1419getAuthors :: IO [NonEmptyString]
1520getAuthors = do
1621 buf <- readProcess "sh" ["-c", "git log --pretty=short | git shortlog --numbered --summary"] ""
@@ -88,6 +93,11 @@ mkTest test opt = testSuite test $ exitcodeFields (test++".hs") ++ opt ++ hsSour
8893
8994main :: IO ()
9095main = defaultMain $ do
96+ liftIO $ do ('v':gv) <- getGitVersion
97+ writeFile "src/Cabal2Nix/Version.hs" $
98+ "module Cabal2Nix.Version where\n\
99+ \version :: String\n\
100+ \version = " ++ show gv ++ "\n"
91101 libraryModules <- modules "src"
92102 props <- properties
93103 return ( props
src/Cabal2Nix/Version.hsdeleted−7
@@ -1,7 +0,0 @@
1−module Cabal2Nix.Version where
2−
3−import Data.Version (showVersion)
4−import Paths_cabal2nix (version)
5−
6−version :: String
7−version = showVersion Paths_cabal2nix.version