Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, buildGoModule
3, fetchFromGitHub
4, installShellFiles
5, nodejs
6, python3
7, runtimeShell
8, stdenv
9, testers
10, runme
11}:
12
13buildGoModule rec {
14 pname = "runme";
15 version = "3.0.2";
16
17 src = fetchFromGitHub {
18 owner = "stateful";
19 repo = "runme";
20 rev = "v${version}";
21 hash = "sha256-a+7Gff3Z1V17uaywoUE+nLVeVprB50Gslarcle/NPB8=";
22 };
23
24 vendorHash = "sha256-QoZzEq1aC7cjY/RVp5Z5HhSuTFf2BSYQnfg0jSaeTJU=";
25
26 nativeBuildInputs = [
27 installShellFiles
28 ];
29
30 nativeCheckInputs = [
31 nodejs
32 python3
33 ];
34
35 subPackages = [
36 "."
37 ];
38
39 ldflags = [
40 "-s"
41 "-w"
42 "-X=github.com/stateful/runme/internal/version.BuildDate=1970-01-01T00:00:00Z"
43 "-X=github.com/stateful/runme/internal/version.BuildVersion=${version}"
44 "-X=github.com/stateful/runme/internal/version.Commit=${src.rev}"
45 ];
46
47 # tests fail to access /etc/bashrc on darwin
48 doCheck = !stdenv.isDarwin;
49
50 postPatch = ''
51 substituteInPlace testdata/{categories/basic,runall/basic,script/basic}.txtar \
52 --replace /bin/bash "${runtimeShell}"
53 '';
54
55 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
56 installShellCompletion --cmd runme \
57 --bash <($out/bin/runme completion bash) \
58 --fish <($out/bin/runme completion fish) \
59 --zsh <($out/bin/runme completion zsh)
60 '';
61
62 passthru.tests = {
63 version = testers.testVersion {
64 package = runme;
65 };
66 };
67
68 meta = with lib; {
69 description = "Execute commands inside your runbooks, docs, and READMEs";
70 mainProgram = "runme";
71 homepage = "https://runme.dev";
72 changelog = "https://github.com/stateful/runme/releases/tag/v${version}";
73 license = licenses.asl20;
74 maintainers = with maintainers; [ figsoda ];
75 };
76}