nix-module-wrapper-manager-fds/modules/wrapper-manager/build.nix
Gabriel Arazas 28dfaefc20 wrapper-manager-fds/modules: overhaul wrapper config
Now, there could be multiple wrappers within the configuration but it
should still result with one derivation unlike the original version.
This could be handy for making package overrides with multiple binaries
(for example, 7Z) while making the interface consistent. This turns out
to be way nicer than I thought which is a good thing.
2024-07-08 21:12:31 +08:00

55 lines
1.4 KiB
Nix

{ config, lib, pkgs, ... }:
{
options.build = {
isBinary = lib.mkOption {
type = lib.types.bool;
description = ''
Sets the build step to create a tiny compiled executable for the
wrapper. By default, it is set to `true`.
'';
default = true;
example = false;
};
extraSetup = lib.mkOption {
type = lib.types.lines;
description = ''
Additional script for setting up the wrapper script derivation.
'';
default = "";
};
toplevel = lib.mkOption {
type = lib.types.package;
readOnly = true;
internal = true;
description = "A derivation containing the wrapper script.";
};
};
config = {
build = {
toplevel =
let
mkWrapBuild = wrappers:
lib.concatMapStrings (v: ''
makeWrapper "${v.arg0}" "${builtins.placeholder "out"}/bin/${v.executableName}" ${lib.concatStringsSep " " v.makeWrapperArgs}
'') wrappers;
in
pkgs.symlinkJoin {
name = "wrapper-manager-fds-wrapped-package";
paths = config.basePackages;
nativeBuildInputs =
if config.build.isBinary
then [ pkgs.makeBinaryWrapper ]
else [ pkgs.makeWrapper ];
postBuild = ''
${config.build.extraSetup}
${mkWrapBuild (lib.attrValues config.wrappers)}
'';
};
};
};
}