ssm-session-manager-plugin: Build from source
Source is linked from https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html#plugin-github Go 1.20 is used for `go test -skip`, since one test fails, seemingly because it does network-related things that do not work in the sandbox.
This commit is contained in:
@@ -1,51 +1,55 @@
|
||||
{ stdenv, lib, fetchurl, autoPatchelfHook, dpkg, awscli, unzip }:
|
||||
let
|
||||
ver = "1.2.331.0";
|
||||
source = {
|
||||
url = rec {
|
||||
"x86_64-linux" = "https://s3.amazonaws.com/session-manager-downloads/plugin/${ver}/ubuntu_64bit/session-manager-plugin.deb";
|
||||
"aarch64-linux" = "https://s3.amazonaws.com/session-manager-downloads/plugin/${ver}/ubuntu_arm64/session-manager-plugin.deb";
|
||||
"x86_64-darwin" = "https://s3.amazonaws.com/session-manager-downloads/plugin/${ver}/mac/sessionmanager-bundle.zip";
|
||||
"aarch64-darwin" = x86_64-darwin;
|
||||
}."${stdenv.hostPlatform.system}" or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
|
||||
sha256 = rec {
|
||||
"x86_64-linux" = "sha256-xWnY89dslkGhRTh9llRFkuUqYIjHQNt+TLnkPQr3u1Q=";
|
||||
"aarch64-linux" = "sha256-QE6+EjLoydTPuLitG6fALXAtvIkfyoFuWij8Z2HT6+Q=";
|
||||
"x86_64-darwin" = "0gr6frdn9jvxnkymkcpvgkqw4z2sac9jdf5qj4hzakq1zkfviazf";
|
||||
"aarch64-darwin" = x86_64-darwin;
|
||||
}."${stdenv.hostPlatform.system}" or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
|
||||
};
|
||||
archivePath = if stdenv.isDarwin then "sessionmanager-bundle" else "usr/local/sessionmanagerplugin";
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
{ stdenv
|
||||
, lib
|
||||
, fetchFromGitHub
|
||||
, buildGo120Package
|
||||
}:
|
||||
|
||||
buildGo120Package rec {
|
||||
pname = "ssm-session-manager-plugin";
|
||||
version = ver;
|
||||
version = "1.2.331.0";
|
||||
|
||||
src = fetchurl source;
|
||||
goPackagePath = "github.com/aws/SSMCLI";
|
||||
|
||||
nativeBuildInputs = lib.optionals stdenv.isLinux [
|
||||
autoPatchelfHook
|
||||
dpkg
|
||||
] ++ lib.optionals stdenv.isDarwin [
|
||||
unzip
|
||||
];
|
||||
src = fetchFromGitHub {
|
||||
owner = "aws";
|
||||
repo = "session-manager-plugin";
|
||||
rev = version;
|
||||
sha256 = "MnTiczFdiP9Xn9fkElVp6tPl7K7PWNyOGjsyLnQHreY=";
|
||||
};
|
||||
|
||||
unpackPhase = if stdenv.isDarwin then "unzip $src" else "dpkg-deb -x $src .";
|
||||
postPatch = ''
|
||||
mv vendor{,-old}
|
||||
mv vendor-old/src vendor
|
||||
rm -r vendor-old
|
||||
'';
|
||||
|
||||
preBuild = ''
|
||||
pushd go/src/${lib.escapeShellArg goPackagePath}
|
||||
echo -n ${lib.escapeShellArg version} > VERSION
|
||||
go run src/version/versiongenerator/version-gen.go
|
||||
popd
|
||||
'';
|
||||
|
||||
doCheck = true;
|
||||
checkFlags = "-skip TestSetSessionHandlers";
|
||||
|
||||
preCheck = ''
|
||||
if ! [[ $(go/bin/sessionmanagerplugin-main --version) = ${lib.escapeShellArg version} ]]; then
|
||||
echo 'wrong version'
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -m755 -D ${archivePath}/bin/session-manager-plugin $out/bin/session-manager-plugin
|
||||
|
||||
install -Dm555 go/bin/sessionmanagerplugin-main "$out/bin/session-manager-plugin"
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html";
|
||||
description = "Amazon SSM Session Manager Plugin";
|
||||
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
||||
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
|
||||
license = licenses.unfree;
|
||||
maintainers = with maintainers; [ mbaillie ];
|
||||
license = licenses.asl20;
|
||||
maintainers = with maintainers; [ amarshall mbaillie ];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user