git.iko.soy/typeable/cabal2nix
on master help sign in
nix-paths: fix dist target
47c9ce6Peter Simons
nix-paths/Setup.lhsmode 100755 → 100644+15−20
@@ -3,14 +3,12 @@
3> module Main ( main ) where
3> module Main ( main ) where
4>
4>
5> import Data.Char
5> import Data.Char
6+> import Data.Maybe
6> import Distribution.PackageDescription
7> import Distribution.PackageDescription
7> import Distribution.Simple
8> import Distribution.Simple
8−> import Distribution.Simple.BuildPaths
9> import Distribution.Simple.LocalBuildInfo
9> import Distribution.Simple.LocalBuildInfo
10> import Distribution.Simple.Program
10> import Distribution.Simple.Program
11> import Distribution.Simple.Setup
11> import Distribution.Simple.Setup
12−> import System.Directory ( createDirectoryIfMissing )
13−> import System.FilePath
14>
12>
15> main :: IO ()
13> main :: IO ()
16> main = defaultMainWithHooks simpleUserHooks
14> main = defaultMainWithHooks simpleUserHooks
@@ -23,23 +21,20 @@
23>
21>
24> configure :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo
22> configure :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo
25> configure (gpd, hbi) flags = do
23> configure (gpd, hbi) flags = do
26−> lbi <- confHook simpleUserHooks (gpd, hbi) flags
24+> lbi' <- confHook simpleUserHooks (gpd, hbi) flags
27> let paths = [ (p, programPath pc) | p <- programs, Just pc <- [lookupProgram (simpleProgram p) (withPrograms lbi)] ]
25> let paths = [ (p, programPath pc) | p <- programs, Just pc <- [lookupProgram (simpleProgram p) (withPrograms lbi)] ]
28−> dirPath = autogenModulesDir lbi </> "Nix"
26+> descr = localPkgDescr lbi'
29−> createDirectoryIfMissing True dirPath
27+> lib = fromJust (library descr)
30−> writeFile (dirPath </> "Paths.hs") $
28+> libbi = libBuildInfo lib
31−> unlines $
29+> lbi = lbi' { localPkgDescr = descr
32−> "module Nix.Paths where\n" : map (uncurry fmtPath) paths
30+> { library = Just (lib { libBuildInfo = libbi { cppOptions = cppOptions libbi ++ map fmtCppArg paths } })
31+> }
32+> }
33> return lbi
33> return lbi
34>
34>
35−> fmtPath :: String -> FilePath -> String
35+> fmtCppArg :: (String, FilePath) -> String
36−> fmtPath name path = unlines
37−> [ "-- | Complete path to the @" ++ name ++ "@ executable."
38−> , mangle name ++ " :: FilePath"
39−> , mangle name ++ " = " ++ show path
36+> fmtCppArg (prg, path) = "-DPATH_TO_" ++ map mangle prg ++ "=" ++ show path
40−> ]
37+> where
41−>
38+> mangle :: Char -> Char
42−> mangle :: String -> String
43−> mangle [] = []
39+> mangle '-' = '_'
44−> mangle ('-':c:cs) = toUpper c : mangle cs
40+> mangle c = toUpper c
45−> mangle (c:cs) = c : mangle cs
nix-paths/nix-paths.cabal+1
@@ -19,6 +19,7 @@ source-repository head
19
19
20library
20library
21 default-language: Haskell2010
21 default-language: Haskell2010
22+ hs-source-dirs: src
22 exposed-modules: Nix.Paths
23 exposed-modules: Nix.Paths
23 build-depends: base < 5
24 build-depends: base < 5
24 build-tools: nix-instantiate, nix-build, nix-env, nix-store
25 build-tools: nix-instantiate, nix-build, nix-env, nix-store
nix-paths/src/Nix/Paths.hsnew file+19
@@ -0,0 +1,19 @@
1+{-# LANGUAGE CPP #-}
2+
3+module Nix.Paths ( nixInstantiate, nixBuild, nixEnv, nixStore ) where
4+
5+-- | Complete path to the @nix-instantiate@ executable.
6+nixInstantiate :: FilePath
7+nixInstantiate = PATH_TO_NIX_INSTANTIATE
8+
9+-- | Complete path to the @nix-build@ executable.
10+nixBuild :: FilePath
11+nixBuild = PATH_TO_NIX_BUILD
12+
13+-- | Complete path to the @nix-env@ executable.
14+nixEnv :: FilePath
15+nixEnv = PATH_TO_NIX_ENV
16+
17+-- | Complete path to the @nix-store@ executable.
18+nixStore :: FilePath
19+nixStore = PATH_TO_NIX_STORE
release.nix+1−2
@@ -19,8 +19,7 @@ let
19 });
19 });
20 });
20 });
21
21
22− # Don't build nix-paths strictly: it doesn't have a working sdist target yet.
23− # nix-paths = self.mkJob "nix-paths";
22+ nix-paths = self.mkJob "nix-paths";
24
23
25 language-nix = self.mkJob "language-nix";
24 language-nix = self.mkJob "language-nix";
26
25