substituteAll: validate arguments
So no one can repeat my mistakes.
This commit is contained in:
parent
c46a2c35ab
commit
05624e48e2
@ -1,12 +1,22 @@
|
|||||||
{ stdenvNoCC }:
|
{ lib, stdenvNoCC }:
|
||||||
|
|
||||||
args:
|
|
||||||
|
|
||||||
# see the substituteAll in the nixpkgs documentation for usage and constraints
|
# see the substituteAll in the nixpkgs documentation for usage and constraints
|
||||||
stdenvNoCC.mkDerivation ({
|
args:
|
||||||
name = if args ? name then args.name else baseNameOf (toString args.src);
|
let
|
||||||
builder = ./substitute-all.sh;
|
# keep this in sync with substituteAll
|
||||||
inherit (args) src;
|
isInvalidArgName = x: builtins.match "^[a-z][a-zA-Z0-9_]*$" x == null;
|
||||||
preferLocalBuild = true;
|
invalidArgs = builtins.filter isInvalidArgName (builtins.attrNames args);
|
||||||
allowSubstitutes = false;
|
in
|
||||||
} // args)
|
if invalidArgs == [] then
|
||||||
|
stdenvNoCC.mkDerivation ({
|
||||||
|
name = if args ? name then args.name else baseNameOf (toString args.src);
|
||||||
|
builder = ./substitute-all.sh;
|
||||||
|
inherit (args) src;
|
||||||
|
preferLocalBuild = true;
|
||||||
|
allowSubstitutes = false;
|
||||||
|
} // args)
|
||||||
|
else throw ''
|
||||||
|
Argument names for `pkgs.substituteAll` must:
|
||||||
|
- start with a lower case ASCII letter
|
||||||
|
- only contain ASCII letters, digits and underscores
|
||||||
|
Found invalid argument names: ${lib.concatStringsSep ", " invalidArgs}.
|
||||||
|
''
|
||||||
|
Loading…
Reference in New Issue
Block a user