nixos/nix-required-mounts: allow passing extra arguments to the hook

This commit is contained in:
Someone Serge 2023-11-21 16:03:58 +00:00
parent 6a6b6ac359
commit 927b15ed6d
2 changed files with 22 additions and 6 deletions

View File

@ -3,9 +3,6 @@
let
cfg = config.programs.nix-required-mounts;
package = pkgs.nix-required-mounts;
overridenPackage = package.override {
inherit (cfg) allowedPatterns;
};
Mount = with lib;
types.submodule {
@ -86,9 +83,26 @@ in
example.require-ipfs.paths = [ "/ipfs" ];
example.require-ipfs.onFeatures = [ "ifps" ];
};
extraWrapperArgs = lib.mkOption {
type = with lib.types; listOf str;
default = [ ];
description =
lib.mdDoc
"List of extra arguments (such as `--add-flags -v`) to pass to the hook's wrapper";
};
package = lib.mkOption {
type = lib.types.package;
default = package.override {
inherit (cfg)
allowedPatterns
extraWrapperArgs;
};
description = lib.mdDoc "The final package with the final config applied";
internal = true;
};
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{ nix.settings.pre-build-hook = lib.getExe overridenPackage; }
{ nix.settings.pre-build-hook = lib.getExe cfg.package; }
(lib.mkIf cfg.presets.nvidia-gpu.enable {
nix.settings.system-features = cfg.allowedPatterns.nvidia-gpu.onFeatures;
programs.nix-required-mounts.allowedPatterns = {

View File

@ -16,12 +16,13 @@
}
, buildPackages
, callPackage
, extraWrapperArgs ? [ ]
, formats
, lib
, makeWrapper
, nix
, nixosTests
, python3Packages
, makeWrapper
, runCommand
}:
@ -47,7 +48,8 @@ python3Packages.buildPythonApplication
postFixup = ''
wrapProgram $out/bin/${pname} \
--add-flags "--patterns ${allowedPatternsPath}" \
--add-flags "--nix-exe ${lib.getExe nix}"
--add-flags "--nix-exe ${lib.getExe nix}" \
${builtins.concatStringsSep " " extraWrapperArgs}
'';
passthru = {