Commit 4b94ae4b authored by figsoda's avatar figsoda
Browse files

writeTextFile: set meta.mainProgram based on destination

parent 3580ac6c
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -135,9 +135,15 @@ rec {
    , allowSubstitutes ? false
    , preferLocalBuild ? true
    }:
    let
      matches = builtins.match "/bin/([^/]+)" destination;
    in
    runCommand name
      { inherit text executable checkPhase meta allowSubstitutes preferLocalBuild;
      { inherit text executable checkPhase allowSubstitutes preferLocalBuild;
        passAsFile = [ "text" ];
        meta = lib.optionalAttrs (executable && matches != null) {
          mainProgram = lib.head matches;
        } // meta;
      }
      ''
        target=$out${lib.escapeShellArg destination}
@@ -230,7 +236,7 @@ rec {


  */
  writeScriptBin = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}"; meta.mainProgram = name;};
  writeScriptBin = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}";};

  /*
    Similar to writeScript. Writes a Shell script and checks its syntax.
@@ -288,7 +294,6 @@ rec {
      checkPhase = ''
        ${stdenv.shellDryRun} "$target"
      '';
      meta.mainProgram = name;
    };

  /*
@@ -351,8 +356,6 @@ rec {
          runHook postCheck
        ''
        else checkPhase;

      meta.mainProgram = name;
    };

  # Create a C binary