summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2018-12-05 16:41:38 +0100
committermakefu <github@syntax-fehler.de>2018-12-05 16:41:38 +0100
commita4556a17f6639efe13e709bf53af15bb2a70c82d (patch)
treec81f829077d32fce39baaf7bfa526d8cac071879 /krebs/5pkgs/simple
parent1859d6653a12e1bfda9465780610f63da8f5ce69 (diff)
parente4750d38e76db94a0b255fa143408b8cbe38b61b (diff)
Merge remote-tracking branch 'lass/master' into HEAD
Diffstat (limited to 'krebs/5pkgs/simple')
-rw-r--r--krebs/5pkgs/simple/cabal-read.nix35
-rw-r--r--krebs/5pkgs/simple/default.nix8
2 files changed, 36 insertions, 7 deletions
diff --git a/krebs/5pkgs/simple/cabal-read.nix b/krebs/5pkgs/simple/cabal-read.nix
new file mode 100644
index 00000000..f8fc71e0
--- /dev/null
+++ b/krebs/5pkgs/simple/cabal-read.nix
@@ -0,0 +1,35 @@
+{ writeHaskellPackage }:
+
+# Because `sed -n 's/.*\<ghc-options:\s\+\(.*\)/\1/p'` is too simple.
+writeHaskellPackage "cabal-read" {
+ executables.ghc-options = {
+ extra-depends = ["Cabal"];
+ text = /* haskell */ ''
+ module Main (main) where
+ import Data.List
+ import Data.Maybe
+ import Distribution.Compiler
+ import Distribution.PackageDescription.Parsec
+ import Distribution.Types.BuildInfo
+ import Distribution.Types.CondTree
+ import Distribution.Types.Executable
+ import Distribution.Types.GenericPackageDescription
+ import Distribution.Types.UnqualComponentName
+ import Distribution.Verbosity
+ import System.Environment
+ main :: IO ()
+ main = do
+ [path, name] <- getArgs
+
+ desc <- readGenericPackageDescription normal path
+
+ case lookup (mkUnqualComponentName name) (condExecutables desc) of
+ Just exe ->
+ putStrLn . intercalate " " . fromMaybe [] . lookup GHC
+ . options . buildInfo . condTreeData $ exe
+
+ Nothing ->
+ error ("executable " <> name <> " not found in " <> path)
+ '';
+ };
+}
diff --git a/krebs/5pkgs/simple/default.nix b/krebs/5pkgs/simple/default.nix
index 1b9d8c23..6ba4fec8 100644
--- a/krebs/5pkgs/simple/default.nix
+++ b/krebs/5pkgs/simple/default.nix
@@ -15,10 +15,4 @@ let
else override;
in
- listToAttrs
- (map
- (name: nameValuePair (removeSuffix ".nix" name)
- (callPackage (./. + "/${name}") {}))
- (filter
- (name: name != "default.nix" && !hasPrefix "." name)
- (attrNames (readDir ./.))))
+ mapNixDir (path: callPackage path {}) ./.