Commit 7ae1fdc9 authored by Valentin Gagarin's avatar Valentin Gagarin Committed by fricklerhandwerk
Browse files

doc: reformat

parent 0d000e9f
Loading
Loading
Loading
Loading
+229 −205
Original line number Diff line number Diff line
@@ -9,18 +9,23 @@ in

rec {

  /* Run the shell command `buildCommand' to produce a store path named
   `name'.  The attributes in `env' are added to the environment
   prior to running the command. By default `runCommand` runs in a
   stdenv with no compiler environment. `runCommandCC` uses the default
   stdenv, `pkgs.stdenv`.
  /*
    Run the shell command `buildCommand' to produce a store path named `name'.

    The attributes in `env' are added to the environment prior to running the command.

    By default `runCommand` runs in a stdenv with no compiler environment.
    `runCommandCC` uses the default stdenv, `pkgs.stdenv`.

    Example:

    ```nix
    runCommand "name" {envVariable = true;} ''echo hello > $out'';
    ```

   runCommand "name" {envVariable = true;} ''echo hello > $out''
    ```nix
    runCommandCC "name" {} ''gcc -o myfile myfile.c; cp myfile $out'';

    ```

    The `*Local` variants force a derivation to be built locally,
    it is not substituted.
@@ -30,8 +35,12 @@ rec {

    It is the same as adding the special fields

   `preferLocalBuild = true;`
   `allowSubstitutes = false;`
    ```nix
    {
      preferLocalBuild = true;
      allowSubstitutes = false;
    }
    ```

    to a derivation’s attributes.
  */
@@ -57,7 +66,8 @@ rec {
  # `runCommandCCLocal` left out on purpose.
  # We shouldn’t force the user to have a cc in scope.

  /* Generalized version of the `runCommand`-variants
  /*
    Generalized version of the `runCommand`-variants
    which does customized behavior via a single
    attribute set passed as the first argument
    instead of having a lot of variants like
@@ -101,7 +111,8 @@ rec {
      // builtins.removeAttrs derivationArgs [ "passAsFile" ]);


  /* Writes a text file to the nix store.
  /*
    Writes a text file to the nix store.
    The contents of text is added to the file in the store.

    Example:
@@ -145,9 +156,11 @@ rec {
      matches = builtins.match "/bin/([^/]+)" destination;
    in
    runCommand name
      { inherit text executable checkPhase allowSubstitutes preferLocalBuild;
      {
        inherit text executable checkPhase allowSubstitutes preferLocalBuild;
        passAsFile = [ "text" ];
        meta = lib.optionalAttrs (executable && matches != null) {
        meta = lib.optionalAttrs (executable && matches != null)
          {
            mainProgram = lib.head matches;
          } // meta;
      }
@@ -544,7 +557,8 @@ rec {
        inherit preferLocalBuild allowSubstitutes;
        passAsFile = [ "paths" ];
      }; # pass the defaults
    in runCommand name args
    in
    runCommand name args
      ''
        mkdir -p $out
        for i in $(cat $pathsPath); do
@@ -591,12 +605,15 @@ rec {
        else if (lib.isList entries) then lib.foldl (a: b: a // { "${b.name}" = b.path; }) { } entries
        else throw "linkFarm entries must be either attrs or a list!";

    linkCommands = lib.mapAttrsToList (name: path: ''
      linkCommands = lib.mapAttrsToList
        (name: path: ''
          mkdir -p "$(dirname ${lib.escapeShellArg "${name}"})"
          ln -s ${lib.escapeShellArg "${path}"} ${lib.escapeShellArg "${name}"}
    '') entries';
        '')
        entries';
    in
  runCommand name {
    runCommand name
      {
        preferLocalBuild = true;
        allowSubstitutes = false;
        passthru.entries = entries';
@@ -830,7 +847,8 @@ rec {
    }

   */
  requireFile = { name ? null
  requireFile =
    { name ? null
    , sha256 ? null
    , sha1 ? null
    , hash ? null
@@ -841,7 +859,8 @@ rec {
      assert (message != null) || (url != null);
      assert (sha256 != null) || (sha1 != null) || (hash != null);
      assert (name != null) || (url != null);
    let msg =
      let
        msg =
          if message != null then message
          else ''
            Unfortunately, we cannot download file ${name_} automatically.
@@ -851,11 +870,13 @@ rec {
            or
              nix-prefetch-url --type ${hashAlgo} file:///path/to/${name_}
          '';
      hashAlgo = if hash != null then (builtins.head (lib.strings.splitString "-" hash))
        hashAlgo =
          if hash != null then (builtins.head (lib.strings.splitString "-" hash))
          else if sha256 != null then "sha256"
          else "sha1";
        hashAlgo_ = if hash != null then "" else hashAlgo;
      hash_ = if hash != null then hash
        hash_ =
          if hash != null then hash
          else if sha256 != null then sha256
          else sha1;
        name_ = if name == null then baseNameOf (toString url) else name;
@@ -924,7 +945,8 @@ rec {
    , patches ? [ ]
    , postPatch ? ""
    , ...
    }@args: stdenvNoCC.mkDerivation {
    }@args: stdenvNoCC.mkDerivation
      {
        inherit name src patches postPatch;
        preferLocalBuild = true;
        allowSubstitutes = false;
@@ -936,7 +958,8 @@ rec {
    // (removeAttrs args [ "src" "name" "patches" "postPatch" ]);

  /* An immutable file in the store with a length of 0 bytes. */
  emptyFile = runCommand "empty-file" {
  emptyFile = runCommand "empty-file"
    {
      outputHashAlgo = "sha256";
      outputHashMode = "recursive";
      outputHash = "0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p";
@@ -944,7 +967,8 @@ rec {
    } "touch $out";

  /* An immutable empty directory in the store. */
  emptyDirectory = runCommand "empty-directory" {
  emptyDirectory = runCommand "empty-directory"
    {
      outputHashAlgo = "sha256";
      outputHashMode = "recursive";
      outputHash = "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5";