summary refs log tree commit diff
path: root/pkgs/tools/admin/bash-my-aws/default.nix
blob: b99f031f416547dfda635a69a56f255487957640 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{ stdenv
, awscli
, jq
, fetchgit
, installShellFiles
, bashInteractive
}:

stdenv.mkDerivation rec {
  pname = "bash-my-aws";
  version = "20200111";

  src = fetchgit {
    url = "https://github.com/bash-my-aws/bash-my-aws";
    rev = "5a97ce2c22affca1299022a5afa109d7b62242ba";
    sha256 = "459bda8b244af059d96c7c8b916cf956b01cb2732d1c2888a3ae06a4d660bea6";
  };

  dontConfigure = true;
  dontBuild = true;

  propagatedBuildInputs = [
    awscli
    jq
    bashInteractive
  ];
  nativeBuildInputs = [ installShellFiles ];

  checkPhase = ''
    pushd test
    ./shared-spec.sh
    ./stack-spec.sh
    popd
  '';
  installPhase=''
    mkdir -p $out
    cp -r . $out
  '';
  postFixup = ''
    pushd $out
    substituteInPlace scripts/build \
        --replace '~/.bash-my-aws' $out
    substituteInPlace scripts/build-completions \
        --replace "{HOME}" $out \
        --replace '~/.bash-my-aws' $out
    ./scripts/build
    ./scripts/build-completions
    substituteInPlace bash_completion.sh \
        --replace "{HOME}" $out \
        --replace .bash-my-aws ""
    substituteInPlace bin/bma \
        --replace '~/.bash-my-aws' $out
    installShellCompletion --bash --name bash-my-aws.bash bash_completion.sh
    chmod +x $out/lib/*
    patchShebangs --host $out/lib
    installShellCompletion --bash --name bash-my-aws.bash bash_completion.sh
    cat > $out/bin/bma-init <<EOF
    echo source $out/aliases
    echo source $out/bash_completion.sh
    EOF
    chmod +x $out/bin/bma-init
    popd
  '';

  meta = with stdenv.lib; {
    homepage = "https://bash-my-aws.org";
    description = "CLI commands for AWS";
    license = licenses.mit;
    maintainers = with maintainers; [ tomberek ];
  };
}