[Nix-dev] reimplementation of nukeReferences - when to commit?

Marc Weber marco-oweber at gmx.de
Fri Nov 14 12:47:26 CET 2008


Anyway: the stdenv-update branch doesn't contain the writeTextFile yet.
We're using svn-1.5 now which should handle multiple branches much
better (?).. So can I just merge that one commit adding writeTextFile
without causing trouble later on when merging?

How would you like to have that writeShellScript function?
maybe writeScriptBinSh is a better name?

is:
  # Create a single file.
  writeTextFile =
    { name # the name of the derivation
    , text
    , executable ? false # run chmod +x ?
    , destination ? ""   # relative path appended to $out eg "/bin/foo"
    }:
  [...]

proposal:
  # Create a single file.
  writeTextFile =
    { name # the name of the derivation
    , text
    , executable ? (interpreter != null) # run chmod +x ?
    , destination ? ""   # relative path appended to $out eg "/bin/foo"
    , interpreter ? null # eg "/bin/sh -e"
    }:
    runCommand name {inherit text executable; }
    (if interpreter == null then "" else "#! ${interpreter} ${interpreterArgs}"
    +''
      n=$out${destination}
      mkdir -p "$(dirname "$n")"
      echo -n "$text" > "$n"
      (test -n "$executable" && chmod +x "$n") || true
    '';

 # you should use "cmd || true" if you really don't care about exit status
 writeScriptBinSh = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}"; interpreter = "/bin/sh -e"; };

I'm not sure which is the best way to handle args.. It seems to me that
adding another argument is overkill..

btw : Thanks for having done that cleanup "# Shorthands for `writeTextFile'"
I already had it implemented as well.. But I didn't want to force rebuilds..

Marc



More information about the nix-dev mailing list