core: rework mkWrappedExecutable helper

- returns packages with high priority
- inherits wrapperArgs so they could be overriden
- fixed typo in description
This commit is contained in:
Wroclaw 2024-05-31 23:47:56 +02:00
parent 898b301fbc
commit 9abc9c10ba

View file

@ -6,20 +6,24 @@
let let
/* /*
* pkgs: package - nixpkgs package * pkg: package - nixpkgs package
* exe: string - executable (under bin) in pkgs * exe: string - executable (under bin) in pkgs
* wrapperArgs: string[] - arguments to pass to the wrapper * wrapperArgs: string[] - arguments to pass to the wrapper
*/ */
mkWrappedExecutable = {pkg, exe ? pkg.meta.mainProgram, wrapperArgs}: let inherit (pkgs) lib makeWrapper; in pkgs.stdenv.mkDerivation { 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}"; name = "${pkg.name}-wrap-${exe}";
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [ makeWrapper ];
phases = ["installPhase"]; phases = ["installPhase"];
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
makeWrapper ${pkg}/bin/${exe} $out/bin/${exe} ${lib.concatStringsSep " " wrapperArgs} makeWrapper ${pkg}/bin/${exe} $out/bin/${exe} $wrapperArgs
''; '';
}; }
wrapedNixPrograms = builtins.map lib.hiPrio [ );
wrapedNixPrograms = [
(mkWrappedExecutable {pkg = pkgs.nix; exe = "nix-build"; wrapperArgs = ["--add-flags" "\"--log-format\"" "--add-flags" "bar-with-logs"];}) (mkWrappedExecutable {pkg = pkgs.nix; exe = "nix-build"; wrapperArgs = ["--add-flags" "\"--log-format\"" "--add-flags" "bar-with-logs"];})
(mkWrappedExecutable {pkg = pkgs.nix; exe = "nix-shell"; wrapperArgs = ["--add-flags" "\"--log-format\"" "--add-flags" "bar"];}) (mkWrappedExecutable {pkg = pkgs.nix; exe = "nix-shell"; wrapperArgs = ["--add-flags" "\"--log-format\"" "--add-flags" "bar"];})
]; ];