git.iko.soy/typeable/nixpkgs
on master help sign in
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"`

commit33ffb05d390987802fe939f9c9a3d6a451076535 authorSilvan Mosberger <contact@infinisil.com> dateFri 25 Jun 2021, 14:39 (5 years ago) parent370a10c
1 file changed+4−4
pkgs/build-support/writers/default.nix+4−4
pkgs/build-support/writers/default.nix+4−4
@@ -15,12 +15,12 @@ rec {
1515 name = last (builtins.split "/" nameOrPath);
1616 in
1717
18− pkgs.runCommandLocal name (if (types.str.check content) then {
19− inherit content interpreter;
20− passAsFile = [ "content" ];
21− } else {
18+ pkgs.runCommandLocal name (if types.path.check content then {
2219 inherit interpreter;
2320 contentPath = content;
21+ } else {
22+ inherit content interpreter;
23+ passAsFile = [ "content" ];
2424 }) ''
2525 # On darwin a script cannot be used as an interpreter in a shebang but
2626 # there doesn't seem to be a limit to the size of shebang and multiple