From 06a3718bc9d393727fbc7752fe9b6c094731dc8b Mon Sep 17 00:00:00 2001 From: "(cdep)illabout" Date: Fri, 29 Oct 2021 17:17:19 +0900 Subject: doc: Add explanation of --fixed-output-derivations arg for dhall-nixpkgs to Dhall section --- doc/languages-frameworks/dhall.section.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'doc') diff --git a/doc/languages-frameworks/dhall.section.md b/doc/languages-frameworks/dhall.section.md index d1adcbf736b..20470e337c1 100644 --- a/doc/languages-frameworks/dhall.section.md +++ b/doc/languages-frameworks/dhall.section.md @@ -342,6 +342,37 @@ $ dhall-to-nixpkgs directory ~/proj/dhall-semver } ``` +### Remote imports as fixed-output derivations {#ssec-dhall-remote-imports-as-fod} + +`dhall-to-nixpkgs` has the ability to fetch and build remote imports as +fixed-output derivations by using their Dhall integrity check. This is +sometimes easier than manually packaging all remote imports. + +This can be used like the following: + +```bash +$ dhall-to-nixpkgs directory --fixed-output-derivations ~/proj/dhall-semver +{ buildDhallDirectoryPackage, buildDhallUrl }: + buildDhallDirectoryPackage { + name = "proj"; + src = /Users/gabriel/proj/dhall-semver; + file = "package.dhall"; + source = false; + document = false; + dependencies = [ + (buildDhallUrl { + url = "https://prelude.dhall-lang.org/v17.0.0/package.dhall"; + hash = "sha256-ENs8kZwl6QRoM9+Jeo/+JwHcOQ+giT2VjDQwUkvlpD4="; + dhall-hash = "sha256:10db3c919c25e9046833df897a8ffe2701dc390fa0893d958c3430524be5a43e"; + }) + ]; + } +``` + +Here, `dhall-semver`'s `Prelude` dependency is fetched and built with the +`buildDhallUrl` helper function, instead of being passed in as a function +argument. + ## Overriding dependency versions {#ssec-dhall-overriding-dependency-versions} Suppose that we change our `true.dhall` example expression to depend on an older -- cgit 1.4.1 From 2e1d84e9fb5385eb4bb2f4cb93177fc1ee0dcc39 Mon Sep 17 00:00:00 2001 From: Dennis Gosnell Date: Mon, 1 Nov 2021 13:44:50 +0900 Subject: dhallPackages.buildDhallUrl: small formatting fixes Co-authored-by: Sandro --- doc/languages-frameworks/dhall.section.md | 2 +- pkgs/development/interpreters/dhall/build-dhall-url.nix | 4 +--- pkgs/test/dhall/default.nix | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) (limited to 'doc') diff --git a/doc/languages-frameworks/dhall.section.md b/doc/languages-frameworks/dhall.section.md index 20470e337c1..4ea26682d56 100644 --- a/doc/languages-frameworks/dhall.section.md +++ b/doc/languages-frameworks/dhall.section.md @@ -345,7 +345,7 @@ $ dhall-to-nixpkgs directory ~/proj/dhall-semver ### Remote imports as fixed-output derivations {#ssec-dhall-remote-imports-as-fod} `dhall-to-nixpkgs` has the ability to fetch and build remote imports as -fixed-output derivations by using their Dhall integrity check. This is +fixed-output derivations by using their Dhall integrity check. This is sometimes easier than manually packaging all remote imports. This can be used like the following: diff --git a/pkgs/development/interpreters/dhall/build-dhall-url.nix b/pkgs/development/interpreters/dhall/build-dhall-url.nix index 54aa775ef14..5dce209a6b0 100644 --- a/pkgs/development/interpreters/dhall/build-dhall-url.nix +++ b/pkgs/development/interpreters/dhall/build-dhall-url.nix @@ -79,12 +79,10 @@ in runCommand name { } ('' set -eu - mkdir -p ${cacheDhall} + mkdir -p ${cacheDhall} $out/${cacheDhall} export XDG_CACHE_HOME=$PWD/${cache} - mkdir -p $out/${cacheDhall} - SHA_HASH="${dhall-hash}" HASH_FILE="''${SHA_HASH/sha256:/1220}" diff --git a/pkgs/test/dhall/default.nix b/pkgs/test/dhall/default.nix index 487e045bab5..bdb33acf023 100644 --- a/pkgs/test/dhall/default.nix +++ b/pkgs/test/dhall/default.nix @@ -3,4 +3,3 @@ lib.recurseIntoAttrs { buildDhallUrl = callPackage ./buildDhallUrl { }; } - -- cgit 1.4.1 From 10c5a4cca54d21071ded19f553a466eb10567f40 Mon Sep 17 00:00:00 2001 From: "(cdep)illabout" Date: Mon, 8 Nov 2021 13:15:17 +0900 Subject: dhallPackages.buildDhallUrl: change argument from dhall-hash to dhallHash --- doc/languages-frameworks/dhall.section.md | 2 +- pkgs/development/interpreters/dhall/build-dhall-url.nix | 6 +++--- pkgs/test/dhall/buildDhallUrl/default.nix | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'doc') diff --git a/doc/languages-frameworks/dhall.section.md b/doc/languages-frameworks/dhall.section.md index 4ea26682d56..2e57392e083 100644 --- a/doc/languages-frameworks/dhall.section.md +++ b/doc/languages-frameworks/dhall.section.md @@ -363,7 +363,7 @@ $ dhall-to-nixpkgs directory --fixed-output-derivations ~/proj/dhall-semver (buildDhallUrl { url = "https://prelude.dhall-lang.org/v17.0.0/package.dhall"; hash = "sha256-ENs8kZwl6QRoM9+Jeo/+JwHcOQ+giT2VjDQwUkvlpD4="; - dhall-hash = "sha256:10db3c919c25e9046833df897a8ffe2701dc390fa0893d958c3430524be5a43e"; + dhallHash = "sha256:10db3c919c25e9046833df897a8ffe2701dc390fa0893d958c3430524be5a43e"; }) ]; } diff --git a/pkgs/development/interpreters/dhall/build-dhall-url.nix b/pkgs/development/interpreters/dhall/build-dhall-url.nix index 5dce209a6b0..766fe3c1c2e 100644 --- a/pkgs/development/interpreters/dhall/build-dhall-url.nix +++ b/pkgs/development/interpreters/dhall/build-dhall-url.nix @@ -22,7 +22,7 @@ # Dhall hash of the input Dhall file. # example: "sha256:6534a24145e93db3df3ef4bc39e2ba743404ea3e8d6cfdbb868d5c83d61f10d2" -, dhall-hash +, dhallHash # Name for this derivation. , name ? (baseNameOf url + "-cache") @@ -61,7 +61,7 @@ let nativeBuildInputs = [ cacert ]; } '' - echo "${url} ${dhall-hash}" > in-dhall-file + echo "${url} ${dhallHash}" > in-dhall-file ${dhall}/bin/dhall --alpha --plain --file in-dhall-file | ${dhallNoHTTP}/bin/dhall encode > $out ''; @@ -83,7 +83,7 @@ in export XDG_CACHE_HOME=$PWD/${cache} - SHA_HASH="${dhall-hash}" + SHA_HASH="${dhallHash}" HASH_FILE="''${SHA_HASH/sha256:/1220}" diff --git a/pkgs/test/dhall/buildDhallUrl/default.nix b/pkgs/test/dhall/buildDhallUrl/default.nix index 37992c4783b..d2e214fb977 100644 --- a/pkgs/test/dhall/buildDhallUrl/default.nix +++ b/pkgs/test/dhall/buildDhallUrl/default.nix @@ -9,6 +9,6 @@ dhallPackages.buildDhallUrl { url = "https://raw.githubusercontent.com/cdepillabout/example-dhall-nix/e6a675c72ecd4dd23d254a02aea8181fe875747f/mydhallfile.dhall"; hash = "sha256-434x+QjHRzuprBdw0h6wmwB1Zj6yZqQb533me8XdO4c="; - dhall-hash = "sha256:e37e31f908c7473ba9ac1770d21eb09b0075663eb266a41be77de67bc5dd3b87"; + dhallHash = "sha256:e37e31f908c7473ba9ac1770d21eb09b0075663eb266a41be77de67bc5dd3b87"; source = true; } -- cgit 1.4.1 From 048939c593c85df1a66b562af3c12c5ebb43e3c9 Mon Sep 17 00:00:00 2001 From: "(cdep)illabout" Date: Mon, 8 Nov 2021 13:18:48 +0900 Subject: dhall docs: change code block formatting to use ShellSession instead of bash --- doc/languages-frameworks/dhall.section.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'doc') diff --git a/doc/languages-frameworks/dhall.section.md b/doc/languages-frameworks/dhall.section.md index 2e57392e083..b4c013e9a7f 100644 --- a/doc/languages-frameworks/dhall.section.md +++ b/doc/languages-frameworks/dhall.section.md @@ -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`, like this: -```bash +```ShellSession $ dhall freeze --inplace ./true.dhall ``` @@ -113,7 +113,7 @@ in … which we can then build using this command: -```bash +```ShellSession $ 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: -```bash +```ShellSession $ tree -a ./result result ├── .cache @@ -135,7 +135,7 @@ result * `source.dhall` contains the result of interpreting our Dhall package: - ```bash + ```ShellSession $ cat ./result/source.dhall True ``` @@ -143,7 +143,7 @@ result * The `.cache` subdirectory contains one binary cache product encoding the same result as `source.dhall`: - ```bash + ```ShellSession $ dhall decode < ./result/.cache/dhall/122027abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70 True ``` @@ -151,7 +151,7 @@ result * `binary.dhall` contains a Dhall expression which handles fetching and decoding the same cache product: - ```bash + ```ShellSession $ cat ./result/binary.dhall missing sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70 $ 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 encoding of the expression: -```bash +```ShellSession $ nix build --file ./example.nix dhallPackages.Prelude $ tree -a result @@ -199,7 +199,7 @@ Dhall overlay like this: … and now the Prelude will contain the fully decoded result of interpreting the Prelude: -```bash +```ShellSession $ nix build --file ./example.nix dhallPackages.Prelude $ 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 packaging Dhall code. For example: -```bash +```ShellSession $ nix-env --install --attr haskellPackages.dhall-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 Dhall directories, too: -```bash +```ShellSession $ dhall-to-nixpkgs directory ~/proj/dhall-semver { buildDhallDirectoryPackage, Prelude }: buildDhallDirectoryPackage { @@ -350,7 +350,7 @@ sometimes easier than manually packaging all remote imports. This can be used like the following: -```bash +```ShellSession $ dhall-to-nixpkgs directory --fixed-output-derivations ~/proj/dhall-semver { buildDhallDirectoryPackage, buildDhallUrl }: buildDhallDirectoryPackage { @@ -390,7 +390,7 @@ in Prelude.Bool.not False If we try to rebuild that expression the build will fail: -``` +```ShellSession $ nix build --file ./example.nix dhallPackages.true 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` to create a Dhall package for our desired Prelude: -```bash +```ShellSession $ dhall-to-nixpkgs github https://github.com/dhall-lang/dhall-lang.git \ --name 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 the Prelude globally for all packages, like this: -```bash +```nix dhallOverrides = self: super: { 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, like this: -```bash +```nix dhallOverrides = self: super: { true = self.callPackage ./true.nix { Prelude = self.callPackage ./Prelude.nix { }; -- cgit 1.4.1 From 1c67b0deeff770b79193ba2cc657144c1b8ba5c1 Mon Sep 17 00:00:00 2001 From: "(cdep)illabout" Date: Mon, 8 Nov 2021 13:21:26 +0900 Subject: dhall docs: replace two paths with more general versions --- doc/languages-frameworks/dhall.section.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/languages-frameworks/dhall.section.md b/doc/languages-frameworks/dhall.section.md index b4c013e9a7f..4b49908b0b0 100644 --- a/doc/languages-frameworks/dhall.section.md +++ b/doc/languages-frameworks/dhall.section.md @@ -334,7 +334,7 @@ $ dhall-to-nixpkgs directory ~/proj/dhall-semver { buildDhallDirectoryPackage, Prelude }: buildDhallDirectoryPackage { name = "proj"; - src = /Users/gabriel/proj/dhall-semver; + src = ~/proj/dhall-semver; file = "package.dhall"; source = false; document = false; @@ -355,7 +355,7 @@ $ dhall-to-nixpkgs directory --fixed-output-derivations ~/proj/dhall-semver { buildDhallDirectoryPackage, buildDhallUrl }: buildDhallDirectoryPackage { name = "proj"; - src = /Users/gabriel/proj/dhall-semver; + src = ~/proj/dhall-semver; file = "package.dhall"; source = false; document = false; -- cgit 1.4.1