writers: Allow string paths

Before this change, it was not possible to use string paths,
because then the `types.str.check` would succeed. So the only paths that
could be used were ones from the local filesystem via e.g.
`./some/path`.

We can easily fix this by using `types.path.check` instead to determine
whether we are dealing with a path.

This notably also allows using Nix-fetched sources as the content, e.g.
`fetchFromGitHub { ... } + "/some/file"`
This commit is contained in:
Silvan Mosberger 2021-06-25 14:39:59 +02:00
parent 370a10c27f
commit 33ffb05d39

View File

@ -15,12 +15,12 @@ rec {
name = last (builtins.split "/" nameOrPath);
in
pkgs.runCommandLocal name (if (types.str.check content) then {
inherit content interpreter;
passAsFile = [ "content" ];
} else {
pkgs.runCommandLocal name (if types.path.check content then {
inherit interpreter;
contentPath = content;
} else {
inherit content interpreter;
passAsFile = [ "content" ];
}) ''
# On darwin a script cannot be used as an interpreter in a shebang but
# there doesn't seem to be a limit to the size of shebang and multiple