writeTextFile,doc/build-helpers: assert destination without a leading slash (#343595)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user