Unverified Commit 6215daa5 authored by networkException's avatar networkException
Browse files

writeTextFile: assert destination starting with a /

This patch adds an assertion to the writeTextFile trivial
builder, asserting that a specified destination starts with
a slash.

This matches the current behavior of the function and merely
provides a helpful error message.
parent f0b6425d
Loading
Loading
Loading
Loading
+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