trivial-builders: add runCommandLocalOverridable
, like runCommand
, but supports standard hooks like postBuild
, etc.
This commit is contained in:
@@ -1,9 +1,22 @@
|
|||||||
{ lib
|
{ lib
|
||||||
, runCommandLocal
|
|
||||||
, rmDbusServicesInPlace
|
, rmDbusServicesInPlace
|
||||||
|
, runCommandLocalOverridable
|
||||||
|
, stdenv
|
||||||
, symlinkJoin
|
, symlinkJoin
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
|
# like `runCommandLocal`, but can be `.overrideAttrs` and supports standard phases/hooks like `postBuild`, etc.
|
||||||
|
runCommandLocalOverridable = name: env: buildPhase: stdenv.mkDerivation {
|
||||||
|
inherit name;
|
||||||
|
preferLocalBuild = true;
|
||||||
|
dontUnpack = true;
|
||||||
|
|
||||||
|
buildPhase = lib.concatStringsSep "\n" [
|
||||||
|
"runHook preBuild"
|
||||||
|
buildPhase
|
||||||
|
"runHook postBuild"
|
||||||
|
];
|
||||||
|
};
|
||||||
# given some package and a path, extract the item at `${package}/${path}` into
|
# given some package and a path, extract the item at `${package}/${path}` into
|
||||||
# its own package, but otherwise keeping the same path.
|
# its own package, but otherwise keeping the same path.
|
||||||
# this is done by copying the bits, so as to avoid including the item's neighbors
|
# this is done by copying the bits, so as to avoid including the item's neighbors
|
||||||
@@ -12,7 +25,7 @@
|
|||||||
paths = if lib.isList path then path else [ path ];
|
paths = if lib.isList path then path else [ path ];
|
||||||
suffix = (lib.head paths) + (if paths != [ path ] then "-and-other-paths" else "");
|
suffix = (lib.head paths) + (if paths != [ path ] then "-and-other-paths" else "");
|
||||||
in
|
in
|
||||||
runCommandLocal "${pkg.pname or pkg.name}-${suffix}" { } ''
|
runCommandLocalOverridable "${pkg.pname or pkg.name}-${suffix}" { } ''
|
||||||
for item in ${lib.escapeShellArgs paths}; do
|
for item in ${lib.escapeShellArgs paths}; do
|
||||||
mkdir -p "$out/$(dirname $item)"
|
mkdir -p "$out/$(dirname $item)"
|
||||||
cp -a "${pkg}/$item" "$out/$item"
|
cp -a "${pkg}/$item" "$out/$item"
|
||||||
@@ -24,7 +37,7 @@
|
|||||||
paths = if lib.isList path then path else [ path ];
|
paths = if lib.isList path then path else [ path ];
|
||||||
suffix = (lib.head paths) + (if paths != [ path ] then "-and-other-paths" else "");
|
suffix = (lib.head paths) + (if paths != [ path ] then "-and-other-paths" else "");
|
||||||
in
|
in
|
||||||
runCommandLocal "${pkg.pname or pkg.name}-${suffix}" { } ''
|
runCommandLocalOverridable "${pkg.pname or pkg.name}-${suffix}" { } ''
|
||||||
for item in ${lib.escapeShellArgs paths}; do
|
for item in ${lib.escapeShellArgs paths}; do
|
||||||
mkdir -p "$out/$(dirname $item)"
|
mkdir -p "$out/$(dirname $item)"
|
||||||
ln -s "${pkg}/$item" "$out/$item"
|
ln -s "${pkg}/$item" "$out/$item"
|
||||||
|
@@ -87,6 +87,7 @@ let
|
|||||||
linkIntoOwnPackage
|
linkIntoOwnPackage
|
||||||
rmDbusServices
|
rmDbusServices
|
||||||
rmDbusServicesInPlace
|
rmDbusServicesInPlace
|
||||||
|
runCommandLocalOverridable
|
||||||
;
|
;
|
||||||
unftp = callPackage ./additional/unftp { };
|
unftp = callPackage ./additional/unftp { };
|
||||||
where-am-i = callPackage ./additional/where-am-i { };
|
where-am-i = callPackage ./additional/where-am-i { };
|
||||||
|
Reference in New Issue
Block a user