summaryrefslogtreecommitdiffstats
path: root/pkgs/development/interpreters/dhall/generate-dhall-directory-package.nix
blob: 2d5c36657ae3884bc4082cdc82afc989448dbdfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
  dhall-nixpkgs,
  lib,
  stdenv,
}:

# This function calls `dhall-to-nixpkgs directory --fixed-output-derivations`
# within a Nix derivation.
#
# This is possible because
# `dhall-to-nixpkgs directory --fixed-output-derivations` will turn remote
# Dhall imports protected with Dhall integrity checksinto fixed-output
# derivations (with the `buildDhallUrl` function), so no unrestricted network
# access is necessary.
lib.makePackageOverridable (
  {
    src,
    # The file to import, relative to the root directory
    file ? "package.dhall",
    # Set to `true` to generate documentation for the package
    document ? false,
  }:
  stdenv.mkDerivation {
    name = "dhall-directory-package.nix";

    buildCommand = ''
      dhall-to-nixpkgs directory --fixed-output-derivations --file "${file}" "${src}" ${lib.optionalString document "--document"} > $out
    '';

    nativeBuildInputs = [ dhall-nixpkgs ];
  }
)