mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 15:11:25 +00:00
stdenv: Reindent
This commit is contained in:
parent
15103e5e5f
commit
cd948c093f
@ -36,6 +36,73 @@ let
|
||||
gcc
|
||||
];
|
||||
|
||||
# Add a utility function to produce derivations that use this
|
||||
# stdenv and its shell.
|
||||
mkDerivation = attrs:
|
||||
let
|
||||
pos =
|
||||
if attrs.meta.description or null != null then
|
||||
unsafeGetAttrPos "description" attrs.meta
|
||||
else
|
||||
unsafeGetAttrPos "name" attrs;
|
||||
pos' = if pos != null then "‘" + pos.file + ":" + toString pos.line + "’" else "«unknown-file»";
|
||||
in
|
||||
if !allowUnfree
|
||||
&& (let l = lib.lists.toList attrs.meta.license or []; in lib.lists.elem "unfree" l || lib.lists.elem "unfree-redistributable" l)
|
||||
&& !allowUnfreePredicate attrs then
|
||||
throw ''
|
||||
Package ‘${attrs.name}’ in ${pos'} has an unfree license, refusing to evaluate. You can set
|
||||
{ nixpkgs.config.allowUnfree = true; }
|
||||
in configuration.nix to override this. If you use Nix standalone, you can add
|
||||
{ allowUnfree = true; }
|
||||
to ~/.nixpkgs/config.nix.''
|
||||
else if !allowBroken && attrs.meta.broken or false then
|
||||
throw "you can't use package ‘${attrs.name}’ in ${pos'} because it has been marked as broken"
|
||||
else if !allowBroken && attrs.meta.platforms or null != null && !lib.lists.elem result.system attrs.meta.platforms then
|
||||
throw "the package ‘${attrs.name}’ in ${pos'} is not supported on ‘${result.system}’"
|
||||
else
|
||||
lib.addPassthru (derivation (
|
||||
(removeAttrs attrs ["meta" "passthru" "crossAttrs"])
|
||||
// (let
|
||||
buildInputs = attrs.buildInputs or [];
|
||||
nativeBuildInputs = attrs.nativeBuildInputs or [];
|
||||
propagatedBuildInputs = attrs.propagatedBuildInputs or [];
|
||||
propagatedNativeBuildInputs = attrs.propagatedNativeBuildInputs or [];
|
||||
crossConfig = attrs.crossConfig or null;
|
||||
in
|
||||
{
|
||||
builder = attrs.realBuilder or shell;
|
||||
args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
|
||||
stdenv = result;
|
||||
system = result.system;
|
||||
userHook = config.stdenv.userHook or null;
|
||||
__ignoreNulls = true;
|
||||
|
||||
# Inputs built by the cross compiler.
|
||||
buildInputs = lib.optionals (crossConfig != null) (buildInputs ++ extraBuildInputs');
|
||||
propagatedBuildInputs = lib.optionals (crossConfig != null) propagatedBuildInputs;
|
||||
# Inputs built by the usual native compiler.
|
||||
nativeBuildInputs = nativeBuildInputs ++ lib.optionals (crossConfig == null) (buildInputs ++ extraBuildInputs');
|
||||
propagatedNativeBuildInputs = propagatedNativeBuildInputs ++
|
||||
lib.optionals (crossConfig == null) propagatedBuildInputs;
|
||||
}))) (
|
||||
{
|
||||
# The meta attribute is passed in the resulting attribute set,
|
||||
# but it's not part of the actual derivation, i.e., it's not
|
||||
# passed to the builder and is not a dependency. But since we
|
||||
# include it in the result, it *is* available to nix-env for
|
||||
# queries. We also a meta.position attribute here to
|
||||
# identify the source location of the package.
|
||||
meta = attrs.meta or {} // (if pos != null then {
|
||||
position = pos.file + ":" + (toString pos.line);
|
||||
} else {});
|
||||
passthru = attrs.passthru or {};
|
||||
} //
|
||||
# Pass through extra attributes that are not inputs, but
|
||||
# should be made available to Nix expressions using the
|
||||
# derivation (e.g., in assertions).
|
||||
(attrs.passthru or {}));
|
||||
|
||||
# The stdenv that we are producing.
|
||||
result =
|
||||
|
||||
@ -61,76 +128,7 @@ let
|
||||
|
||||
// rec {
|
||||
|
||||
meta = {
|
||||
description = "The default build environment for Unix packages in Nixpkgs";
|
||||
};
|
||||
|
||||
# Add a utility function to produce derivations that use this
|
||||
# stdenv and its shell.
|
||||
mkDerivation = attrs:
|
||||
let
|
||||
pos =
|
||||
if attrs.meta.description or null != null then
|
||||
unsafeGetAttrPos "description" attrs.meta
|
||||
else
|
||||
unsafeGetAttrPos "name" attrs;
|
||||
pos' = if pos != null then "‘" + pos.file + ":" + toString pos.line + "’" else "«unknown-file»";
|
||||
in
|
||||
if !allowUnfree
|
||||
&& (let l = lib.lists.toList attrs.meta.license or []; in lib.lists.elem "unfree" l || lib.lists.elem "unfree-redistributable" l)
|
||||
&& !allowUnfreePredicate attrs then
|
||||
throw ''
|
||||
Package ‘${attrs.name}’ in ${pos'} has an unfree license, refusing to evaluate. You can set
|
||||
{ nixpkgs.config.allowUnfree = true; }
|
||||
in configuration.nix to override this. If you use Nix standalone, you can add
|
||||
{ allowUnfree = true; }
|
||||
to ~/.nixpkgs/config.nix.''
|
||||
else if !allowBroken && attrs.meta.broken or false then
|
||||
throw "you can't use package ‘${attrs.name}’ in ${pos'} because it has been marked as broken"
|
||||
else if !allowBroken && attrs.meta.platforms or null != null && !lib.lists.elem result.system attrs.meta.platforms then
|
||||
throw "the package ‘${attrs.name}’ in ${pos'} is not supported on ‘${result.system}’"
|
||||
else
|
||||
lib.addPassthru (derivation (
|
||||
(removeAttrs attrs ["meta" "passthru" "crossAttrs"])
|
||||
// (let
|
||||
buildInputs = attrs.buildInputs or [];
|
||||
nativeBuildInputs = attrs.nativeBuildInputs or [];
|
||||
propagatedBuildInputs = attrs.propagatedBuildInputs or [];
|
||||
propagatedNativeBuildInputs = attrs.propagatedNativeBuildInputs or [];
|
||||
crossConfig = attrs.crossConfig or null;
|
||||
in
|
||||
{
|
||||
builder = attrs.realBuilder or shell;
|
||||
args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
|
||||
stdenv = result;
|
||||
system = result.system;
|
||||
userHook = config.stdenv.userHook or null;
|
||||
__ignoreNulls = true;
|
||||
|
||||
# Inputs built by the cross compiler.
|
||||
buildInputs = lib.optionals (crossConfig != null) (buildInputs ++ extraBuildInputs');
|
||||
propagatedBuildInputs = lib.optionals (crossConfig != null) propagatedBuildInputs;
|
||||
# Inputs built by the usual native compiler.
|
||||
nativeBuildInputs = nativeBuildInputs ++ lib.optionals (crossConfig == null) (buildInputs ++ extraBuildInputs');
|
||||
propagatedNativeBuildInputs = propagatedNativeBuildInputs ++
|
||||
lib.optionals (crossConfig == null) propagatedBuildInputs;
|
||||
}))) (
|
||||
{
|
||||
# The meta attribute is passed in the resulting attribute set,
|
||||
# but it's not part of the actual derivation, i.e., it's not
|
||||
# passed to the builder and is not a dependency. But since we
|
||||
# include it in the result, it *is* available to nix-env for
|
||||
# queries. We also a meta.position attribute here to
|
||||
# identify the source location of the package.
|
||||
meta = attrs.meta or {} // (if pos != null then {
|
||||
position = pos.file + ":" + (toString pos.line);
|
||||
} else {});
|
||||
passthru = attrs.passthru or {};
|
||||
} //
|
||||
# Pass through extra attributes that are not inputs, but
|
||||
# should be made available to Nix expressions using the
|
||||
# derivation (e.g., in assertions).
|
||||
(attrs.passthru or {}));
|
||||
meta.description = "The default build environment for Unix packages in Nixpkgs";
|
||||
|
||||
# Utility flags to test the type of platform.
|
||||
isDarwin = system == "x86_64-darwin";
|
||||
@ -180,6 +178,8 @@ let
|
||||
# Whether we should run paxctl to pax-mark binaries.
|
||||
needsPax = isLinux;
|
||||
|
||||
inherit mkDerivation;
|
||||
|
||||
# For convenience, bring in the library functions in lib/ so
|
||||
# packages don't have to do that themselves.
|
||||
inherit lib;
|
||||
|
Loading…
Reference in New Issue
Block a user