git.iko.soy/typeable/cabal2nix
on master help sign in
nix-paths: create a new library that provides stable paths to various Nix utilities
commit21be08a8f965904e7df7fea4d9263e8e3e2f7abc authorPeter Simons <simons@cryp.to> dateWed 9 Sep 2015, 11:22 (11 years ago) parentf2a512b
5 files changed+108−4
nix-paths/LICENSE+30 nix-paths/Setup.lhs+45 nix-paths/nix-paths.cabal+24 release.nix+4 stack.yaml+5−4
nix-paths/LICENSEnew file+30
@@ -0,0 +1,30 @@
1+Redistribution and use in source and binary forms, with or
2+without modification, are permitted provided that the
3+following conditions are met:
4+
5+ * Redistributions of source code must retain the above
6+ copyright notice, this list of conditions and the
7+ following disclaimer.
8+
9+ * Redistributions in binary form must reproduce the above
10+ copyright notice, this list of conditions and the
11+ following disclaimer in the documentation and/or other
12+ materials provided with the distribution.
13+
14+ * The names of its contributors may not be used to endorse
15+ or promote products derived from this software without
16+ specific prior written permission.
17+
18+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19+CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nix-paths/Setup.lhsnew file+45
@@ -0,0 +1,45 @@
1+#! /usr/bin/env runhaskell
2+
3+> module Main ( main ) where
4+>
5+> import Data.Char
6+> import Distribution.PackageDescription
7+> import Distribution.Simple
8+> import Distribution.Simple.BuildPaths
9+> import Distribution.Simple.LocalBuildInfo
10+> import Distribution.Simple.Program
11+> import Distribution.Simple.Setup
12+> import System.Directory ( createDirectoryIfMissing )
13+> import System.FilePath
14+>
15+> main :: IO ()
16+> main = defaultMainWithHooks simpleUserHooks
17+> { hookedPrograms = map simpleProgram programs
18+> , confHook = configure
19+> }
20+>
21+> programs :: [String]
22+> programs = ["nix-instantiate", "nix-build", "nix-env", "nix-store"]
23+>
24+> configure :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo
25+> configure (gpd, hbi) flags = do
26+> lbi <- confHook simpleUserHooks (gpd, hbi) flags
27+> let paths = [ (p, programPath pc) | p <- programs, Just pc <- [lookupProgram (simpleProgram p) (withPrograms lbi)] ]
28+> dirPath = autogenModulesDir lbi </> "Nix"
29+> createDirectoryIfMissing True dirPath
30+> writeFile (dirPath </> "Paths.hs") $
31+> unlines $
32+> "module Nix.Paths where\n" : map (uncurry fmtPath) paths
33+> return lbi
34+>
35+> fmtPath :: String -> FilePath -> String
36+> fmtPath name path = unlines
37+> [ "-- | Complete path to the @" ++ name ++ "@ executable."
38+> , mangle name ++ " :: FilePath"
39+> , mangle name ++ " = " ++ show path
40+> ]
41+>
42+> mangle :: String -> String
43+> mangle [] = []
44+> mangle ('-':c:cs) = toUpper c : mangle cs
45+> mangle (c:cs) = c : mangle cs
nix-paths/nix-paths.cabalnew file+24
@@ -0,0 +1,24 @@
1+name: nix-paths
2+version: 1
3+synopsis: Knowledge of Nix's installation directories.
4+description: This module provides full paths to various Nix
5+ utilities, like @nix-store@, @nix-instantiate@, and
6+ @nix-env@.
7+category: Distribution
8+homepage: https://github.com/nixos/cabal2nix#readme
9+bug-reports: https://github.com/nixos/cabal2nix/issues
10+maintainer: Peter Simons <simons@cryp.to>
11+license: BSD3
12+license-file: LICENSE
13+build-type: Custom
14+cabal-version: >= 1.10
15+
16+source-repository head
17+ type: git
18+ location: https://github.com/nixos/cabal2nix
19+
20+library
21+ default-language: Haskell2010
22+ exposed-modules: Nix.Paths
23+ build-depends: base < 5
24+ build-tools: nix-instantiate, nix-build, nix-env, nix-store
release.nix+4
@@ -19,6 +19,9 @@ let
1919 });
2020 });
2121
22+ # Don't build nix-paths strictly: it doesn't have a working sdist target yet.
23+ # nix-paths = self.mkJob "nix-paths";
24+
2225 language-nix = self.mkJob "language-nix";
2326
2427 distribution-nixpkgs = self.mkJob "distribution-nixpkgs";
@@ -33,6 +36,7 @@ let
3336
3437in
3538{
39+ nix-paths = mkJob "nix-paths";
3640
3741 language-nix = mkJob "language-nix";
3842
stack.yaml+5−4
@@ -1,8 +1,9 @@
11flags: {}
22packages:
3−- distribution-nixpkgs/
4−- hackage2nix/
5−- cabal2nix/
6−- language-nix/
3+ - nix-paths
4+ - distribution-nixpkgs
5+ - hackage2nix
6+ - cabal2nix
7+ - language-nix
78extra-deps: []
89resolver: lts-3.3