Unverified Commit 51296fce authored by Philip Taron's avatar Philip Taron Committed by GitHub
Browse files

writeTextFile,doc/build-helpers: assert destination without a leading slash (#343595)

parents 33e735b4 6215daa5
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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";
}
```

+7 −0
Original line number Diff line number Diff line
@@ -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