diff options
author | Shea Levy <shea@shealevy.com> | 2017-05-01 11:43:53 -0400 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2017-05-01 11:44:21 -0400 |
commit | 8a1707ad0d26013bf6014a01831a3af2a506fa14 (patch) | |
tree | 34276ada19d94007b73389cc8c865c8853c3b351 /pkgs/build-support/emacs | |
parent | ecd2a344685f97bee836753ccc98e910a8014573 (diff) |
nixBufferBuilders: Add haskellMonoRepo builder
Diffstat (limited to 'pkgs/build-support/emacs')
-rw-r--r-- | pkgs/build-support/emacs/buffer.nix | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/pkgs/build-support/emacs/buffer.nix b/pkgs/build-support/emacs/buffer.nix index 6c5e0570fd0dd..75e660d021436 100644 --- a/pkgs/build-support/emacs/buffer.nix +++ b/pkgs/build-support/emacs/buffer.nix @@ -3,7 +3,7 @@ { lib, writeText, inherit-local }: -{ +rec { withPackages = pkgs: let extras = map (x: x.emacsBufferSetup pkgs) (builtins.filter (builtins.hasAttr "emacsBufferSetup") pkgs); in writeText "dir-locals.el" '' @@ -49,4 +49,28 @@ ${lib.concatStringsSep "\n" extras} ''; + # nix-buffer function for a project with a bunch of haskell packages + # in one directory + haskellMonoRepo = { project-root # The monorepo root + , haskellPackages # The composed haskell packages set that contains all of the packages + }: { root }: + let # The haskell paths. + haskell-paths = lib.filesystem.haskellPathsInDir project-root; + # Find the haskell package that the 'root' is in, if any. + haskell-path-parent = + let filtered = builtins.filter (name: + lib.hasPrefix (toString (project-root + "/${name}")) (toString root) + ) (builtins.attrNames haskell-paths); + in + if filtered == [] then null else builtins.head filtered; + # We're in the directory of a haskell package + is-haskell-package = haskell-path-parent != null; + haskell-package = haskellPackages.${haskell-path-parent}; + # GHC environment with all needed deps for the haskell package + haskell-package-env = + builtins.head haskell-package.env.nativeBuildInputs; + in + if is-haskell-package + then withPackages [ haskell-package-env ] + else {}; } |