pkgs/mkWrappedExecutable: factor out to its own package

This commit is contained in:
Wroclaw 2024-07-09 11:47:10 +02:00
parent 6e76c7422a
commit 8c1eb9dec3
2 changed files with 23 additions and 17 deletions

View file

@ -5,23 +5,7 @@
{ inputs, lib, pkgs, ... }:
let
/*
* pkg: package - nixpkgs package
* exe: string - executable (under bin) in pkgs
* wrapperArgs: string[] - arguments to pass to the wrapper
*/
mkWrappedExecutable = {pkg, exe ? pkg.meta.mainProgram, wrapperArgs}: let inherit (pkgs) lib makeWrapper; in lib.hiPrio (
pkgs.stdenv.mkDerivation {
inherit wrapperArgs;
name = "${pkg.name}-wrap-${exe}";
nativeBuildInputs = [ makeWrapper ];
phases = ["installPhase"];
installPhase = ''
mkdir -p $out/bin
makeWrapper ${pkg}/bin/${exe} $out/bin/${exe} $wrapperArgs
'';
}
);
inherit (pkgs) mkWrappedExecutable;
# bool -> nixpkgs[]
wrappedNixExecutables = inEnvironment: assert builtins.isBool inEnvironment; [

View file

@ -0,0 +1,22 @@
{
lib,
makeWrapper,
stdenv
}:
/*
pkg: package - nixpkgs package
exe: string - executable (under bin) in pkg
wrapperArgs: string[] - arguments to pass to the wrapper
*/
{ pkg, exe ? pkg.meta.mainProgram, wrapperArgs }:
lib.hiPrio (stdenv.mkDerivation {
inherit wrapperArgs;
name = "${pkg.name}-wrap-${exe}";
nativeBuildInputs = [ makeWrapper ];
phases = ["installPhase"];
installPhase = ''
mkdir -p $out/bin
makeWrapper ${pkg}/bin/${exe} $out/bin/${exe} $wrapperArgs
'';
})