1
0
Fork 1
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:
Philip Taron 2024-09-24 07:39:11 -07:00 committed by GitHub
commit 51296fce6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View file

@ -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";
}
```

View file

@ -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