Unverified Commit 82a03c32 authored by figsoda's avatar figsoda Committed by GitHub
Browse files

Merge pull request #233898 from figsoda/runme

parents 22f90176 2abb67c0
Loading
Loading
Loading
Loading
+70 −0
Original line number Diff line number Diff line
{ lib
, buildGoModule
, fetchFromGitHub
, installShellFiles
, runtimeShell
, stdenv
, testers
, runme
}:

buildGoModule rec {
  pname = "runme";
  version = "1.2.1";

  src = fetchFromGitHub {
    owner = "stateful";
    repo = "runme";
    rev = "v${version}";
    hash = "sha256-Gk15sqGQRL5v7Fo+tIYM4GM1FihoEAs23HK0cQN9hy4=";
  };

  vendorHash = "sha256-el+gM3GRN5KU4RlSAx02rn+22xj28IZq3erZUzPbUUw=";

  nativeBuildInputs = [
    installShellFiles
  ];

  subPackages = [
    "."
  ];

  ldflags = [
    "-s"
    "-w"
    "-X=github.com/stateful/runme/internal/version.BuildDate=1970-01-01T00:00:00Z"
    "-X=github.com/stateful/runme/internal/version.BuildVersion=${version}"
    "-X=github.com/stateful/runme/internal/version.Commit=${src.rev}"
  ];

  postPatch = ''
    substituteInPlace testdata/script/basic.txtar \
      --replace /bin/bash "${runtimeShell}"
  '';

  # version test assumes `ldflags` is unspecified
  preCheck = ''
    unset ldflags
  '';

  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
    installShellCompletion --cmd runme \
      --bash <($out/bin/runme completion bash) \
      --fish <($out/bin/runme completion fish) \
      --zsh <($out/bin/runme completion zsh)
  '';

  passthru.tests = {
    version = testers.testVersion {
      package = runme;
    };
  };

  meta = with lib; {
    description = "Execute commands inside your runbooks, docs, and READMEs";
    homepage = "https://runme.dev";
    changelog = "https://github.com/stateful/runme/releases/tag/v${src.rev}";
    license = licenses.asl20;
    maintainers = with maintainers; [ figsoda ];
  };
}
+2 −0
Original line number Diff line number Diff line
@@ -12037,6 +12037,8 @@ with pkgs;
  rund = callPackage ../development/tools/rund { };
  runme = callPackage ../development/tools/misc/runme { };
  runzip = callPackage ../tools/archivers/runzip { };
  unzoo = callPackage ../tools/archivers/unzoo { };