aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval-error.hh1
-rw-r--r--src/libexpr/eval-settings.hh1
-rw-r--r--src/libexpr/fetchurl.nix102
-rw-r--r--src/libexpr/flake/call-flake.nix112
-rw-r--r--src/libexpr/gc-small-vector.hh1
-rw-r--r--src/libexpr/imported-drv-to-derivation.nix33
-rw-r--r--src/libexpr/pos-idx.hh1
-rw-r--r--src/libexpr/pos-table.hh1
-rw-r--r--src/libexpr/primops/derivation.nix38
-rw-r--r--src/libexpr/print-ambiguous.hh1
-rw-r--r--src/libexpr/repl-exit-status.hh1
11 files changed, 172 insertions, 120 deletions
diff --git a/src/libexpr/eval-error.hh b/src/libexpr/eval-error.hh
index 2fb6bcf41..4f0e0d24c 100644
--- a/src/libexpr/eval-error.hh
+++ b/src/libexpr/eval-error.hh
@@ -1,4 +1,5 @@
#pragma once
+///@file
#include <algorithm>
diff --git a/src/libexpr/eval-settings.hh b/src/libexpr/eval-settings.hh
index e8bfe81a4..98fe6881e 100644
--- a/src/libexpr/eval-settings.hh
+++ b/src/libexpr/eval-settings.hh
@@ -1,4 +1,5 @@
#pragma once
+///@file
#include "config.hh"
namespace nix {
diff --git a/src/libexpr/fetchurl.nix b/src/libexpr/fetchurl.nix
index 9d1b61d7f..50007c738 100644
--- a/src/libexpr/fetchurl.nix
+++ b/src/libexpr/fetchurl.nix
@@ -1,43 +1,75 @@
-{ system ? "" # obsolete
-, url
-, hash ? "" # an SRI hash
-
-# Legacy hash specification
-, md5 ? "", sha1 ? "", sha256 ? "", sha512 ? ""
-, outputHash ?
- if hash != "" then hash else if sha512 != "" then sha512 else if sha1 != "" then sha1 else if md5 != "" then md5 else sha256
-, outputHashAlgo ?
- if hash != "" then "" else if sha512 != "" then "sha512" else if sha1 != "" then "sha1" else if md5 != "" then "md5" else "sha256"
-
-, executable ? false
-, unpack ? false
-, name ? baseNameOf (toString url)
-, impure ? false
+{
+ system ? "", # obsolete
+ url,
+ hash ? "", # an SRI hash
+
+ # Legacy hash specification
+ md5 ? "",
+ sha1 ? "",
+ sha256 ? "",
+ sha512 ? "",
+ outputHash ?
+ if hash != "" then
+ hash
+ else if sha512 != "" then
+ sha512
+ else if sha1 != "" then
+ sha1
+ else if md5 != "" then
+ md5
+ else
+ sha256,
+ outputHashAlgo ?
+ if hash != "" then
+ ""
+ else if sha512 != "" then
+ "sha512"
+ else if sha1 != "" then
+ "sha1"
+ else if md5 != "" then
+ "md5"
+ else
+ "sha256",
+
+ executable ? false,
+ unpack ? false,
+ name ? baseNameOf (toString url),
+ impure ? false,
}:
-derivation ({
- builder = "builtin:fetchurl";
+derivation (
+ {
+ builder = "builtin:fetchurl";
- # New-style output content requirements.
- outputHashMode = if unpack || executable then "recursive" else "flat";
+ # New-style output content requirements.
+ outputHashMode = if unpack || executable then "recursive" else "flat";
- inherit name url executable unpack;
+ inherit
+ name
+ url
+ executable
+ unpack
+ ;
- system = "builtin";
+ system = "builtin";
- # No need to double the amount of network traffic
- preferLocalBuild = true;
+ # No need to double the amount of network traffic
+ preferLocalBuild = true;
- impureEnvVars = [
- # We borrow these environment variables from the caller to allow
- # easy proxy configuration. This is impure, but a fixed-output
- # derivation like fetchurl is allowed to do so since its result is
- # by definition pure.
- "http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy"
- ];
+ impureEnvVars = [
+ # We borrow these environment variables from the caller to allow
+ # easy proxy configuration. This is impure, but a fixed-output
+ # derivation like fetchurl is allowed to do so since its result is
+ # by definition pure.
+ "http_proxy"
+ "https_proxy"
+ "ftp_proxy"
+ "all_proxy"
+ "no_proxy"
+ ];
- # To make "nix-prefetch-url" work.
- urls = [ url ];
-} // (if impure
- then { __impure = true; }
- else { inherit outputHashAlgo outputHash; }))
+ # To make "nix-prefetch-url" work.
+ urls = [ url ];
+ }
+ // (if impure then { __impure = true; } else { inherit outputHashAlgo outputHash; })
+)
diff --git a/src/libexpr/flake/call-flake.nix b/src/libexpr/flake/call-flake.nix
index 4beb0b0fe..58b4a5542 100644
--- a/src/libexpr/flake/call-flake.nix
+++ b/src/libexpr/flake/call-flake.nix
@@ -4,69 +4,69 @@ let
lockFile = builtins.fromJSON lockFileStr;
- allNodes =
- builtins.mapAttrs
- (key: node:
- let
+ allNodes = builtins.mapAttrs (
+ key: node:
+ let
- sourceInfo =
- if key == lockFile.root
- then rootSrc
- else fetchTree (node.info or {} // removeAttrs node.locked ["dir"]);
+ sourceInfo =
+ if key == lockFile.root then
+ rootSrc
+ else
+ fetchTree (node.info or { } // removeAttrs node.locked [ "dir" ]);
- subdir = if key == lockFile.root then rootSubdir else node.locked.dir or "";
+ subdir = if key == lockFile.root then rootSubdir else node.locked.dir or "";
- outPath = sourceInfo + ((if subdir == "" then "" else "/") + subdir);
+ outPath = sourceInfo + ((if subdir == "" then "" else "/") + subdir);
- flake = import (outPath + "/flake.nix");
+ flake = import (outPath + "/flake.nix");
- inputs = builtins.mapAttrs
- (inputName: inputSpec: allNodes.${resolveInput inputSpec})
- (node.inputs or {});
+ inputs = builtins.mapAttrs (inputName: inputSpec: allNodes.${resolveInput inputSpec}) (
+ node.inputs or { }
+ );
- # Resolve a input spec into a node name. An input spec is
- # either a node name, or a 'follows' path from the root
- # node.
- resolveInput = inputSpec:
- if builtins.isList inputSpec
- then getInputByPath lockFile.root inputSpec
- else inputSpec;
+ # Resolve a input spec into a node name. An input spec is
+ # either a node name, or a 'follows' path from the root
+ # node.
+ resolveInput =
+ inputSpec: if builtins.isList inputSpec then getInputByPath lockFile.root inputSpec else inputSpec;
- # Follow an input path (e.g. ["dwarffs" "nixpkgs"]) from the
- # root node, returning the final node.
- getInputByPath = nodeName: path:
- if path == []
- then nodeName
- else
- getInputByPath
- # Since this could be a 'follows' input, call resolveInput.
- (resolveInput lockFile.nodes.${nodeName}.inputs.${builtins.head path})
- (builtins.tail path);
+ # Follow an input path (e.g. ["dwarffs" "nixpkgs"]) from the
+ # root node, returning the final node.
+ getInputByPath =
+ nodeName: path:
+ if path == [ ] then
+ nodeName
+ else
+ getInputByPath
+ # Since this could be a 'follows' input, call resolveInput.
+ (resolveInput lockFile.nodes.${nodeName}.inputs.${builtins.head path})
+ (builtins.tail path);
- outputs = flake.outputs (inputs // { self = result; });
+ outputs = flake.outputs (inputs // { self = result; });
- result =
- outputs
- # We add the sourceInfo attribute for its metadata, as they are
- # relevant metadata for the flake. However, the outPath of the
- # sourceInfo does not necessarily match the outPath of the flake,
- # as the flake may be in a subdirectory of a source.
- # This is shadowed in the next //
- // sourceInfo
- // {
- # This shadows the sourceInfo.outPath
- inherit outPath;
+ result =
+ outputs
+ # We add the sourceInfo attribute for its metadata, as they are
+ # relevant metadata for the flake. However, the outPath of the
+ # sourceInfo does not necessarily match the outPath of the flake,
+ # as the flake may be in a subdirectory of a source.
+ # This is shadowed in the next //
+ // sourceInfo
+ // {
+ # This shadows the sourceInfo.outPath
+ inherit outPath;
- inherit inputs; inherit outputs; inherit sourceInfo; _type = "flake";
- };
-
- in
- if node.flake or true then
- assert builtins.isFunction flake.outputs;
- result
- else
- sourceInfo
- )
- lockFile.nodes;
-
-in allNodes.${lockFile.root}
+ inherit inputs;
+ inherit outputs;
+ inherit sourceInfo;
+ _type = "flake";
+ };
+ in
+ if node.flake or true then
+ assert builtins.isFunction flake.outputs;
+ result
+ else
+ sourceInfo
+ ) lockFile.nodes;
+in
+allNodes.${lockFile.root}
diff --git a/src/libexpr/gc-small-vector.hh b/src/libexpr/gc-small-vector.hh
index 94c3ad28b..c4bd1db26 100644
--- a/src/libexpr/gc-small-vector.hh
+++ b/src/libexpr/gc-small-vector.hh
@@ -1,4 +1,5 @@
#pragma once
+///@file
#include <boost/container/small_vector.hpp>
diff --git a/src/libexpr/imported-drv-to-derivation.nix b/src/libexpr/imported-drv-to-derivation.nix
index 9467e6a22..50864563e 100644
--- a/src/libexpr/imported-drv-to-derivation.nix
+++ b/src/libexpr/imported-drv-to-derivation.nix
@@ -1,21 +1,26 @@
-attrs @ { drvPath, outputs, name, ... }:
+attrs@{
+ drvPath,
+ outputs,
+ name,
+ ...
+}:
let
- commonAttrs = (builtins.listToAttrs outputsList) //
- { all = map (x: x.value) outputsList;
- inherit drvPath name;
- type = "derivation";
- };
+ commonAttrs = (builtins.listToAttrs outputsList) // {
+ all = map (x: x.value) outputsList;
+ inherit drvPath name;
+ type = "derivation";
+ };
- outputToAttrListElement = outputName:
- { name = outputName;
- value = commonAttrs // {
- outPath = builtins.getAttr outputName attrs;
- inherit outputName;
- };
+ outputToAttrListElement = outputName: {
+ name = outputName;
+ value = commonAttrs // {
+ outPath = builtins.getAttr outputName attrs;
+ inherit outputName;
};
+ };
outputsList = map outputToAttrListElement outputs;
-
-in (builtins.head outputsList).value
+in
+(builtins.head outputsList).value
diff --git a/src/libexpr/pos-idx.hh b/src/libexpr/pos-idx.hh
index e94fd85c6..406fc1b36 100644
--- a/src/libexpr/pos-idx.hh
+++ b/src/libexpr/pos-idx.hh
@@ -1,4 +1,5 @@
#pragma once
+///@file
#include <cinttypes>
diff --git a/src/libexpr/pos-table.hh b/src/libexpr/pos-table.hh
index 0b60c4f6d..704f24696 100644
--- a/src/libexpr/pos-table.hh
+++ b/src/libexpr/pos-table.hh
@@ -1,4 +1,5 @@
#pragma once
+///@file
#include <cinttypes>
#include <numeric>
diff --git a/src/libexpr/primops/derivation.nix b/src/libexpr/primops/derivation.nix
index c0fbe8082..674408c6d 100644
--- a/src/libexpr/primops/derivation.nix
+++ b/src/libexpr/primops/derivation.nix
@@ -1,27 +1,35 @@
-/* This is the implementation of the ‘derivation’ builtin function.
- It's actually a wrapper around the ‘derivationStrict’ primop. */
+/*
+ This is the implementation of the ‘derivation’ builtin function.
+ It's actually a wrapper around the ‘derivationStrict’ primop.
+*/
-drvAttrs @ { outputs ? [ "out" ], ... }:
+drvAttrs@{
+ outputs ? [ "out" ],
+ ...
+}:
let
strict = derivationStrict drvAttrs;
- commonAttrs = drvAttrs // (builtins.listToAttrs outputsList) //
- { all = map (x: x.value) outputsList;
+ commonAttrs =
+ drvAttrs
+ // (builtins.listToAttrs outputsList)
+ // {
+ all = map (x: x.value) outputsList;
inherit drvAttrs;
};
- outputToAttrListElement = outputName:
- { name = outputName;
- value = commonAttrs // {
- outPath = builtins.getAttr outputName strict;
- drvPath = strict.drvPath;
- type = "derivation";
- inherit outputName;
- };
+ outputToAttrListElement = outputName: {
+ name = outputName;
+ value = commonAttrs // {
+ outPath = builtins.getAttr outputName strict;
+ drvPath = strict.drvPath;
+ type = "derivation";
+ inherit outputName;
};
+ };
outputsList = map outputToAttrListElement outputs;
-
-in (builtins.head outputsList).value
+in
+(builtins.head outputsList).value
diff --git a/src/libexpr/print-ambiguous.hh b/src/libexpr/print-ambiguous.hh
index 50c260a9b..b615d1e5a 100644
--- a/src/libexpr/print-ambiguous.hh
+++ b/src/libexpr/print-ambiguous.hh
@@ -1,4 +1,5 @@
#pragma once
+///@file
#include "value.hh"
diff --git a/src/libexpr/repl-exit-status.hh b/src/libexpr/repl-exit-status.hh
index 08299ff61..f150b9597 100644
--- a/src/libexpr/repl-exit-status.hh
+++ b/src/libexpr/repl-exit-status.hh
@@ -1,4 +1,5 @@
#pragma once
+///@file
namespace nix {