splice.nix: run nixpkgs-fmt
the file was a bit hard to read
This commit is contained in:
parent
ff76349c4f
commit
0a3d351240
|
@ -18,86 +18,103 @@ lib: pkgs: actuallySplice:
|
|||
|
||||
let
|
||||
|
||||
spliceReal = { pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget
|
||||
, pkgsHostHost, pkgsHostTarget
|
||||
, pkgsTargetTarget
|
||||
}: let
|
||||
mash =
|
||||
# Other pkgs sets
|
||||
pkgsBuildBuild // pkgsBuildTarget // pkgsHostHost // pkgsTargetTarget
|
||||
# The same pkgs sets one probably intends
|
||||
// pkgsBuildHost // pkgsHostTarget;
|
||||
merge = name: {
|
||||
inherit name;
|
||||
value = let
|
||||
defaultValue = mash.${name};
|
||||
# `or {}` is for the non-derivation attsert splicing case, where `{}` is the identity.
|
||||
valueBuildBuild = pkgsBuildBuild.${name} or {};
|
||||
valueBuildHost = pkgsBuildHost.${name} or {};
|
||||
valueBuildTarget = pkgsBuildTarget.${name} or {};
|
||||
valueHostHost = pkgsHostHost.${name} or {};
|
||||
valueHostTarget = pkgsHostTarget.${name} or {};
|
||||
valueTargetTarget = pkgsTargetTarget.${name} or {};
|
||||
augmentedValue = defaultValue
|
||||
# TODO(@Artturin): remove before release 23.05 and only have __spliced.
|
||||
// (lib.optionalAttrs (pkgsBuildHost ? ${name}) { nativeDrv = lib.warn "use ${name}.__spliced.buildHost instead of ${name}.nativeDrv" valueBuildHost; })
|
||||
// (lib.optionalAttrs (pkgsHostTarget ? ${name}) { crossDrv = lib.warn "use ${name}.__spliced.hostTarget instead of ${name}.crossDrv" valueHostTarget; })
|
||||
// {
|
||||
__spliced =
|
||||
(lib.optionalAttrs (pkgsBuildBuild ? ${name}) { buildBuild = valueBuildBuild; })
|
||||
// (lib.optionalAttrs (pkgsBuildHost ? ${name}) { buildHost = valueBuildHost; })
|
||||
// (lib.optionalAttrs (pkgsBuildTarget ? ${name}) { buildTarget = valueBuildTarget; })
|
||||
// (lib.optionalAttrs (pkgsHostHost ? ${name}) { hostHost = valueHostHost; })
|
||||
// (lib.optionalAttrs (pkgsHostTarget ? ${name}) { hostTarget = valueHostTarget; })
|
||||
// (lib.optionalAttrs (pkgsTargetTarget ? ${name}) { targetTarget = valueTargetTarget;
|
||||
});
|
||||
};
|
||||
# Get the set of outputs of a derivation. If one derivation fails to
|
||||
# evaluate we don't want to diverge the entire splice, so we fall back
|
||||
# on {}
|
||||
tryGetOutputs = value0: let
|
||||
inherit (builtins.tryEval value0) success value;
|
||||
in getOutputs (lib.optionalAttrs success value);
|
||||
getOutputs = value: lib.genAttrs
|
||||
(value.outputs or (lib.optional (value ? out) "out"))
|
||||
(output: value.${output});
|
||||
in
|
||||
# The derivation along with its outputs, which we recur
|
||||
# on to splice them together.
|
||||
if lib.isDerivation defaultValue then augmentedValue // spliceReal {
|
||||
pkgsBuildBuild = tryGetOutputs valueBuildBuild;
|
||||
pkgsBuildHost = tryGetOutputs valueBuildHost;
|
||||
pkgsBuildTarget = tryGetOutputs valueBuildTarget;
|
||||
pkgsHostHost = tryGetOutputs valueHostHost;
|
||||
pkgsHostTarget = getOutputs valueHostTarget;
|
||||
pkgsTargetTarget = tryGetOutputs valueTargetTarget;
|
||||
# Just recur on plain attrsets
|
||||
} else if lib.isAttrs defaultValue then spliceReal {
|
||||
pkgsBuildBuild = valueBuildBuild;
|
||||
pkgsBuildHost = valueBuildHost;
|
||||
pkgsBuildTarget = valueBuildTarget;
|
||||
pkgsHostHost = valueHostHost;
|
||||
pkgsHostTarget = valueHostTarget;
|
||||
pkgsTargetTarget = valueTargetTarget;
|
||||
# Don't be fancy about non-derivations. But we could have used used
|
||||
# `__functor__` for functions instead.
|
||||
} else defaultValue;
|
||||
};
|
||||
in lib.listToAttrs (map merge (lib.attrNames mash));
|
||||
spliceReal =
|
||||
{ pkgsBuildBuild
|
||||
, pkgsBuildHost
|
||||
, pkgsBuildTarget
|
||||
, pkgsHostHost
|
||||
, pkgsHostTarget
|
||||
, pkgsTargetTarget
|
||||
}:
|
||||
let
|
||||
mash =
|
||||
# Other pkgs sets
|
||||
pkgsBuildBuild // pkgsBuildTarget // pkgsHostHost // pkgsTargetTarget
|
||||
# The same pkgs sets one probably intends
|
||||
// pkgsBuildHost // pkgsHostTarget;
|
||||
merge = name: {
|
||||
inherit name;
|
||||
value =
|
||||
let
|
||||
defaultValue = mash.${name};
|
||||
# `or {}` is for the non-derivation attsert splicing case, where `{}` is the identity.
|
||||
valueBuildBuild = pkgsBuildBuild.${name} or { };
|
||||
valueBuildHost = pkgsBuildHost.${name} or { };
|
||||
valueBuildTarget = pkgsBuildTarget.${name} or { };
|
||||
valueHostHost = pkgsHostHost.${name} or { };
|
||||
valueHostTarget = pkgsHostTarget.${name} or { };
|
||||
valueTargetTarget = pkgsTargetTarget.${name} or { };
|
||||
augmentedValue = defaultValue
|
||||
# TODO(@Artturin): remove before release 23.05 and only have __spliced.
|
||||
// (lib.optionalAttrs (pkgsBuildHost ? ${name}) { nativeDrv = lib.warn "use ${name}.__spliced.buildHost instead of ${name}.nativeDrv" valueBuildHost; })
|
||||
// (lib.optionalAttrs (pkgsHostTarget ? ${name}) { crossDrv = lib.warn "use ${name}.__spliced.hostTarget instead of ${name}.crossDrv" valueHostTarget; })
|
||||
// {
|
||||
__spliced =
|
||||
(lib.optionalAttrs (pkgsBuildBuild ? ${name}) { buildBuild = valueBuildBuild; })
|
||||
// (lib.optionalAttrs (pkgsBuildHost ? ${name}) { buildHost = valueBuildHost; })
|
||||
// (lib.optionalAttrs (pkgsBuildTarget ? ${name}) { buildTarget = valueBuildTarget; })
|
||||
// (lib.optionalAttrs (pkgsHostHost ? ${name}) { hostHost = valueHostHost; })
|
||||
// (lib.optionalAttrs (pkgsHostTarget ? ${name}) { hostTarget = valueHostTarget; })
|
||||
// (lib.optionalAttrs (pkgsTargetTarget ? ${name}) {
|
||||
targetTarget = valueTargetTarget;
|
||||
});
|
||||
};
|
||||
# Get the set of outputs of a derivation. If one derivation fails to
|
||||
# evaluate we don't want to diverge the entire splice, so we fall back
|
||||
# on {}
|
||||
tryGetOutputs = value0:
|
||||
let
|
||||
inherit (builtins.tryEval value0) success value;
|
||||
in
|
||||
getOutputs (lib.optionalAttrs success value);
|
||||
getOutputs = value: lib.genAttrs
|
||||
(value.outputs or (lib.optional (value ? out) "out"))
|
||||
(output: value.${output});
|
||||
in
|
||||
# The derivation along with its outputs, which we recur
|
||||
# on to splice them together.
|
||||
if lib.isDerivation defaultValue then augmentedValue // spliceReal {
|
||||
pkgsBuildBuild = tryGetOutputs valueBuildBuild;
|
||||
pkgsBuildHost = tryGetOutputs valueBuildHost;
|
||||
pkgsBuildTarget = tryGetOutputs valueBuildTarget;
|
||||
pkgsHostHost = tryGetOutputs valueHostHost;
|
||||
pkgsHostTarget = getOutputs valueHostTarget;
|
||||
pkgsTargetTarget = tryGetOutputs valueTargetTarget;
|
||||
# Just recur on plain attrsets
|
||||
} else if lib.isAttrs defaultValue then
|
||||
spliceReal
|
||||
{
|
||||
pkgsBuildBuild = valueBuildBuild;
|
||||
pkgsBuildHost = valueBuildHost;
|
||||
pkgsBuildTarget = valueBuildTarget;
|
||||
pkgsHostHost = valueHostHost;
|
||||
pkgsHostTarget = valueHostTarget;
|
||||
pkgsTargetTarget = valueTargetTarget;
|
||||
# Don't be fancy about non-derivations. But we could have used used
|
||||
# `__functor__` for functions instead.
|
||||
} else defaultValue;
|
||||
};
|
||||
in
|
||||
lib.listToAttrs (map merge (lib.attrNames mash));
|
||||
|
||||
splicePackages = { pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget
|
||||
, pkgsHostHost, pkgsHostTarget
|
||||
, pkgsTargetTarget
|
||||
} @ args:
|
||||
splicePackages =
|
||||
{ pkgsBuildBuild
|
||||
, pkgsBuildHost
|
||||
, pkgsBuildTarget
|
||||
, pkgsHostHost
|
||||
, pkgsHostTarget
|
||||
, pkgsTargetTarget
|
||||
} @ args:
|
||||
if actuallySplice then spliceReal args else pkgsHostTarget;
|
||||
|
||||
splicedPackages = splicePackages {
|
||||
inherit (pkgs)
|
||||
pkgsBuildBuild pkgsBuildHost pkgsBuildTarget
|
||||
pkgsHostHost pkgsHostTarget
|
||||
pkgsTargetTarget
|
||||
;
|
||||
} // {
|
||||
splicedPackages = splicePackages
|
||||
{
|
||||
inherit (pkgs)
|
||||
pkgsBuildBuild pkgsBuildHost pkgsBuildTarget
|
||||
pkgsHostHost pkgsHostTarget
|
||||
pkgsTargetTarget
|
||||
;
|
||||
} // {
|
||||
# These should never be spliced under any circumstances
|
||||
inherit (pkgs)
|
||||
pkgsBuildBuild pkgsBuildHost pkgsBuildTarget
|
||||
|
@ -109,7 +126,10 @@ let
|
|||
};
|
||||
|
||||
splicedPackagesWithXorg = splicedPackages // builtins.removeAttrs splicedPackages.xorg [
|
||||
"callPackage" "newScope" "overrideScope" "packages"
|
||||
"callPackage"
|
||||
"newScope"
|
||||
"overrideScope"
|
||||
"packages"
|
||||
];
|
||||
|
||||
in
|
||||
|
@ -120,7 +140,7 @@ in
|
|||
# We use `callPackage' to be able to omit function arguments that can be
|
||||
# obtained `pkgs` or `buildPackages` and their `xorg` package sets. Use
|
||||
# `newScope' for sets of packages in `pkgs' (see e.g. `gnome' below).
|
||||
callPackage = pkgs.newScope {};
|
||||
callPackage = pkgs.newScope { };
|
||||
|
||||
callPackages = lib.callPackagesWith splicedPackagesWithXorg;
|
||||
|
||||
|
|
Loading…
Reference in a new issue