shell.nix with the core Dhall tools (#899)

* shell.nix with the core Dhall tools

* Inheriting 'pkgs' from ./nix/shared.nix. Meaningfull welcome message with
usage examples.

* Update shell.nix

Co-Authored-By: antislava <antislava@gmail.com>

* Update shell.nix

Co-Authored-By: antislava <antislava@gmail.com>

* Top-level nix-shell mention in README.md
This commit is contained in:
antislava 2019-04-19 22:16:52 +02:00 committed by GitHub
parent 1f40b633d6
commit f462dcc90a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 1 deletions

View File

@ -111,7 +111,7 @@ trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDS
substituters = https://cache.nixos.org https://cache.dhall-lang.org
```
If you use an older version of Nix (i.e. Nix 1.*) then use these options
If you use an older version of Nix (i.e. Nix `1.*`) then use these options
instead:
```
@ -137,6 +137,9 @@ $ nix-env --install --file default.nix
... or you can run the same command within each package's respective directory
to install just that one package.
If you prefer installing the binaries locally in a nix shell environment instead, just run `nix-shell` in the top-level directory.
This option provides additional flexibility with respect to overriding some of the default parameters e.g. the compiler version, which makes it particularly useful for developers.
You can develop any package by navigating to that package's directory and
running:

View File

@ -563,6 +563,8 @@ in
rec {
inherit trivial;
inherit pkgs;
possibly-static = {
dhall = makeStaticIfPossible "dhall" ;
dhall-bash = makeStaticIfPossible "dhall-bash" ;

32
shell.nix Normal file
View File

@ -0,0 +1,32 @@
{ args ? {} , shell ? "bash" }:
let
shared = import ./nix/shared.nix args;
static = shared.possibly-static;
in
shared.pkgs.runCommand "dhall-shell-${shell}" {
buildInputs = [
static.dhall
static.dhall-json
static.dhall-text
static.dhall-bash
static.dhall-nix
];
shellHook = ''
echo "Dhall core tools shell"
echo "USAGE EXAMPLES"
echo " Default (GHC version ${(import ./nix/shared.nix {}).pkgs.haskellPackages.ghc.version}, option completions shell - bash):"
echo " $ nix-shell"
echo " Overriding default GHC compiler (see ./nix/shared.nix for available options):"
echo " $ nix-shell --arg args '{ compiler = "ghc7103"; }'"
echo " Overriding option completion shell flavor:"
echo " $ nix-shell --argstr shell zsh"
source <(dhall --${shell}-completion-script dhall)
source <(dhall-to-text --${shell}-completion-script dhall-to-text)
source <(dhall-to-bash --${shell}-completion-script dhall-to-bash)
source <(dhall-to-nix --${shell}-completion-script dhall-to-nix)
source <(dhall-to-json --${shell}-completion-script dhall-to-json)
source <(dhall-to-yaml --${shell}-completion-script dhall-to-yaml)
source <(json-to-dhall --${shell}-completion-script json-to-dhall)
'';
} ""