mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 19:21:04 +00:00
writeTextFile,doc/build-helpers: assert destination without a leading slash (#343595)
This commit is contained in:
commit
51296fce6f
|
@ -501,7 +501,7 @@ writeTextFile {
|
|||
text = ''
|
||||
Contents of File
|
||||
'';
|
||||
destination = "share/my-file";
|
||||
destination = "/share/my-file";
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -586,7 +586,7 @@ writeTextFile {
|
|||
echo "hi"
|
||||
'';
|
||||
executable = true;
|
||||
destination = "bin/my-script";
|
||||
destination = "/bin/my-script";
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -674,7 +674,7 @@ writeTextFile {
|
|||
echo "hi"
|
||||
'';
|
||||
executable = true;
|
||||
destination = "bin/my-script";
|
||||
destination = "/bin/my-script";
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -86,6 +86,13 @@ rec {
|
|||
, preferLocalBuild ? true
|
||||
, derivationArgs ? { }
|
||||
}:
|
||||
assert lib.assertMsg (destination != "" -> (lib.hasPrefix "/" destination && destination != "/")) ''
|
||||
destination must be an absolute path, relative to the derivation's out path,
|
||||
got '${destination}' instead.
|
||||
|
||||
Ensure that the path starts with a / and specifies at least the filename.
|
||||
'';
|
||||
|
||||
let
|
||||
matches = builtins.match "/bin/([^/]+)" destination;
|
||||
in
|
||||
|
|
Loading…
Reference in a new issue