dhall docs: change code block formatting to use ShellSession instead of bash

This commit is contained in:
(cdep)illabout 2021-11-08 13:18:48 +09:00
parent 10c5a4cca5
commit 048939c593

View file

@ -50,7 +50,7 @@ expression does not protect the Prelude import with a semantic integrity
check, so the first step is to freeze the expression using `dhall freeze`, check, so the first step is to freeze the expression using `dhall freeze`,
like this: like this:
```bash ```ShellSession
$ dhall freeze --inplace ./true.dhall $ dhall freeze --inplace ./true.dhall
``` ```
@ -113,7 +113,7 @@ in
… which we can then build using this command: … which we can then build using this command:
```bash ```ShellSession
$ nix build --file ./example.nix dhallPackages.true $ nix build --file ./example.nix dhallPackages.true
``` ```
@ -121,7 +121,7 @@ $ nix build --file ./example.nix dhallPackages.true
The above package produces the following directory tree: The above package produces the following directory tree:
```bash ```ShellSession
$ tree -a ./result $ tree -a ./result
result result
├── .cache ├── .cache
@ -135,7 +135,7 @@ result
* `source.dhall` contains the result of interpreting our Dhall package: * `source.dhall` contains the result of interpreting our Dhall package:
```bash ```ShellSession
$ cat ./result/source.dhall $ cat ./result/source.dhall
True True
``` ```
@ -143,7 +143,7 @@ result
* The `.cache` subdirectory contains one binary cache product encoding the * The `.cache` subdirectory contains one binary cache product encoding the
same result as `source.dhall`: same result as `source.dhall`:
```bash ```ShellSession
$ dhall decode < ./result/.cache/dhall/122027abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70 $ dhall decode < ./result/.cache/dhall/122027abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
True True
``` ```
@ -151,7 +151,7 @@ result
* `binary.dhall` contains a Dhall expression which handles fetching and decoding * `binary.dhall` contains a Dhall expression which handles fetching and decoding
the same cache product: the same cache product:
```bash ```ShellSession
$ cat ./result/binary.dhall $ cat ./result/binary.dhall
missing sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70 missing sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
$ cp -r ./result/.cache .cache $ cp -r ./result/.cache .cache
@ -168,7 +168,7 @@ to conserve disk space when they are used exclusively as dependencies. For
example, if we build the Prelude package it will only contain the binary example, if we build the Prelude package it will only contain the binary
encoding of the expression: encoding of the expression:
```bash ```ShellSession
$ nix build --file ./example.nix dhallPackages.Prelude $ nix build --file ./example.nix dhallPackages.Prelude
$ tree -a result $ tree -a result
@ -199,7 +199,7 @@ Dhall overlay like this:
… and now the Prelude will contain the fully decoded result of interpreting … and now the Prelude will contain the fully decoded result of interpreting
the Prelude: the Prelude:
```bash ```ShellSession
$ nix build --file ./example.nix dhallPackages.Prelude $ nix build --file ./example.nix dhallPackages.Prelude
$ tree -a result $ tree -a result
@ -302,7 +302,7 @@ Additionally, `buildDhallGitHubPackage` accepts the same arguments as
You can use the `dhall-to-nixpkgs` command-line utility to automate You can use the `dhall-to-nixpkgs` command-line utility to automate
packaging Dhall code. For example: packaging Dhall code. For example:
```bash ```ShellSession
$ nix-env --install --attr haskellPackages.dhall-nixpkgs $ nix-env --install --attr haskellPackages.dhall-nixpkgs
$ nix-env --install --attr nix-prefetch-git # Used by dhall-to-nixpkgs $ nix-env --install --attr nix-prefetch-git # Used by dhall-to-nixpkgs
@ -329,7 +329,7 @@ The utility takes care of automatically detecting remote imports and converting
them to package dependencies. You can also use the utility on local them to package dependencies. You can also use the utility on local
Dhall directories, too: Dhall directories, too:
```bash ```ShellSession
$ dhall-to-nixpkgs directory ~/proj/dhall-semver $ dhall-to-nixpkgs directory ~/proj/dhall-semver
{ buildDhallDirectoryPackage, Prelude }: { buildDhallDirectoryPackage, Prelude }:
buildDhallDirectoryPackage { buildDhallDirectoryPackage {
@ -350,7 +350,7 @@ sometimes easier than manually packaging all remote imports.
This can be used like the following: This can be used like the following:
```bash ```ShellSession
$ dhall-to-nixpkgs directory --fixed-output-derivations ~/proj/dhall-semver $ dhall-to-nixpkgs directory --fixed-output-derivations ~/proj/dhall-semver
{ buildDhallDirectoryPackage, buildDhallUrl }: { buildDhallDirectoryPackage, buildDhallUrl }:
buildDhallDirectoryPackage { buildDhallDirectoryPackage {
@ -390,7 +390,7 @@ in Prelude.Bool.not False
If we try to rebuild that expression the build will fail: If we try to rebuild that expression the build will fail:
``` ```ShellSession
$ nix build --file ./example.nix dhallPackages.true $ nix build --file ./example.nix dhallPackages.true
builder for '/nix/store/0f1hla7ff1wiaqyk1r2ky4wnhnw114fi-true.drv' failed with exit code 1; last 10 log lines: builder for '/nix/store/0f1hla7ff1wiaqyk1r2ky4wnhnw114fi-true.drv' failed with exit code 1; last 10 log lines:
@ -416,7 +416,7 @@ importing the URL.
However, we can override the default Prelude version by using `dhall-to-nixpkgs` However, we can override the default Prelude version by using `dhall-to-nixpkgs`
to create a Dhall package for our desired Prelude: to create a Dhall package for our desired Prelude:
```bash ```ShellSession
$ dhall-to-nixpkgs github https://github.com/dhall-lang/dhall-lang.git \ $ dhall-to-nixpkgs github https://github.com/dhall-lang/dhall-lang.git \
--name Prelude \ --name Prelude \
--directory Prelude \ --directory Prelude \
@ -427,7 +427,7 @@ $ dhall-to-nixpkgs github https://github.com/dhall-lang/dhall-lang.git \
… and then referencing that package in our Dhall overlay, by either overriding … and then referencing that package in our Dhall overlay, by either overriding
the Prelude globally for all packages, like this: the Prelude globally for all packages, like this:
```bash ```nix
dhallOverrides = self: super: { dhallOverrides = self: super: {
true = self.callPackage ./true.nix { }; true = self.callPackage ./true.nix { };
@ -438,7 +438,7 @@ the Prelude globally for all packages, like this:
… or selectively overriding the Prelude dependency for just the `true` package, … or selectively overriding the Prelude dependency for just the `true` package,
like this: like this:
```bash ```nix
dhallOverrides = self: super: { dhallOverrides = self: super: {
true = self.callPackage ./true.nix { true = self.callPackage ./true.nix {
Prelude = self.callPackage ./Prelude.nix { }; Prelude = self.callPackage ./Prelude.nix { };