diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-10-20 22:09:03 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-10-20 22:09:03 +0000 |
commit | 50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e (patch) | |
tree | f2556b911180125ccbb7ed0e78a54e92da89adce /nixpkgs/pkgs/applications/networking/cluster/ssm-agent/default.nix | |
parent | 4c16d4548a98563c9d9ad76f4e5b2202864ccd54 (diff) | |
parent | cfc75eec4603c06503ae750f88cf397e00796ea8 (diff) | |
download | nixlib-50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e.tar nixlib-50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e.tar.gz nixlib-50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e.tar.bz2 nixlib-50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e.tar.lz nixlib-50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e.tar.xz nixlib-50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e.tar.zst nixlib-50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e.zip |
Merge commit 'cfc75eec4603c06503ae750f88cf397e00796ea8'
Conflicts: nixpkgs/pkgs/build-support/rust/build-rust-package/default.nix
Diffstat (limited to 'nixpkgs/pkgs/applications/networking/cluster/ssm-agent/default.nix')
-rw-r--r-- | nixpkgs/pkgs/applications/networking/cluster/ssm-agent/default.nix | 118 |
1 files changed, 68 insertions, 50 deletions
diff --git a/nixpkgs/pkgs/applications/networking/cluster/ssm-agent/default.nix b/nixpkgs/pkgs/applications/networking/cluster/ssm-agent/default.nix index a073c9b6fd84..f6afcd7d884f 100644 --- a/nixpkgs/pkgs/applications/networking/cluster/ssm-agent/default.nix +++ b/nixpkgs/pkgs/applications/networking/cluster/ssm-agent/default.nix @@ -1,13 +1,17 @@ { lib , writeShellScriptBin -, buildGoPackage +, buildGoModule , makeWrapper , fetchFromGitHub , coreutils , nettools -, dmidecode , util-linux +, stdenv +, dmidecode , bashInteractive +, nix-update-script +, testers +, ssm-agent , overrideEtc ? true }: @@ -24,22 +28,29 @@ let -r) echo "''${VERSION:-unknown}";; esac ''; + + binaries = { + "core" = "amazon-ssm-agent"; + "agent" = "ssm-agent-worker"; + "cli-main" = "ssm-cli"; + "worker" = "ssm-document-worker"; + "logging" = "ssm-session-logger"; + "sessionworker" = "ssm-session-worker"; + }; in -buildGoPackage rec { +buildGoModule rec { pname = "amazon-ssm-agent"; - version = "3.2.1478.0"; - - goPackagePath = "github.com/aws/${pname}"; - - nativeBuildInputs = [ makeWrapper ]; + version = "3.2.1630.0"; src = fetchFromGitHub { - rev = version; owner = "aws"; repo = "amazon-ssm-agent"; - hash = "sha256-SS0N3Wcksk2vq52K6GYE9z4hrckXGqiuCuYPHkH4SWc="; + rev = "refs/tags/${version}"; + hash = "sha256-0tN0rBfz2VZ4UkYLFDGg9218O9vyyRT2Lrppu9TETao="; }; + vendorHash = null; + patches = [ # Some tests use networking, so we skip them. ./0001-Disable-NIC-tests-that-fail-in-the-Nix-sandbox.patch @@ -49,7 +60,9 @@ buildGoPackage rec { ./0002-version-gen-don-t-use-unnecessary-constants.patch ]; - # See the list https://github.com/aws/amazon-ssm-agent/blob/3.2.1478.0/makefile#L120-L138 + nativeBuildInputs = [ makeWrapper ]; + + # See the list https://github.com/aws/amazon-ssm-agent/blob/3.2.1630.0/makefile#L120-L138 # The updater is not built because it cannot work on NixOS subPackages = [ "core" @@ -60,80 +73,85 @@ buildGoPackage rec { "agent/framework/processor/executer/outofproc/sessionworker" ]; - ldflags = [ - "-s" - "-w" - ]; + ldflags = [ "-s" "-w" ]; - preConfigure = '' + postPatch = '' printf "#!/bin/sh\ntrue" > ./Tools/src/checkstyle.sh substituteInPlace agent/platform/platform_unix.go \ - --replace "/usr/bin/uname" "${coreutils}/bin/uname" \ - --replace '"/bin", "hostname"' '"${nettools}/bin/hostname"' \ - --replace '"lsb_release"' '"${fake-lsb-release}/bin/lsb_release"' - - substituteInPlace agent/managedInstances/fingerprint/hardwareInfo_unix.go \ - --replace /usr/sbin/dmidecode ${dmidecode}/bin/dmidecode + --replace "/usr/bin/uname" "${coreutils}/bin/uname" \ + --replace '"/bin", "hostname"' '"${nettools}/bin/hostname"' \ + --replace '"lsb_release"' '"${fake-lsb-release}/bin/lsb_release"' substituteInPlace agent/session/shell/shell_unix.go \ - --replace '"script"' '"${util-linux}/bin/script"' + --replace '"script"' '"${util-linux}/bin/script"' + + substituteInPlace agent/rebooter/rebooter_unix.go \ + --replace "/sbin/shutdown" "shutdown" echo "${version}" > VERSION '' + lib.optionalString overrideEtc '' substituteInPlace agent/appconfig/constants_unix.go \ --replace '"/etc/amazon/ssm/"' '"${placeholder "out"}/etc/amazon/ssm/"' + '' + lib.optionalString stdenv.isLinux '' + substituteInPlace agent/managedInstances/fingerprint/hardwareInfo_unix.go \ + --replace /usr/sbin/dmidecode ${dmidecode}/bin/dmidecode ''; preBuild = '' - pushd go/src/${goPackagePath} - # Note: if this step fails, please patch the code to fix it! Please only skip # tests if it is not feasible for the test to pass in a sandbox. make quick-integtest make pre-release make pre-build - - popd ''; - postBuild = '' - pushd go/bin + installPhase = '' + runHook preInstall - mv core amazon-ssm-agent - mv agent ssm-agent-worker - mv cli-main ssm-cli - mv worker ssm-document-worker - mv logging ssm-session-logger - mv sessionworker ssm-session-worker + declare -A map=(${builtins.concatStringsSep " " (lib.mapAttrsToList (name: value: "[\"${name}\"]=\"${value}\"") binaries)}) - popd - ''; + for key in ''${!map[@]}; do + install -D -m 0555 -T "$GOPATH/bin/''${key}" "$out/bin/''${map[''${key}]}" + done - # These templates retain their `.template` extensions on installation. The - # amazon-ssm-agent.json.template is required as default configuration when an - # amazon-ssm-agent.json isn't present. Here, we retain the template to show - # we're using the default configuration. - - # seelog.xml isn't actually required to run, but it does ship as a template - # with debian packages, so it's here for reference. Future work in the nixos - # module could use this template and substitute a different log level. - postInstall = '' - mkdir -p $out/etc/amazon/ssm - cp go/src/${goPackagePath}/amazon-ssm-agent.json.template $out/etc/amazon/ssm/amazon-ssm-agent.json.template - cp go/src/${goPackagePath}/seelog_unix.xml $out/etc/amazon/ssm/seelog.xml.template + # These templates retain their `.template` extensions on installation. The + # amazon-ssm-agent.json.template is required as default configuration when an + # amazon-ssm-agent.json isn't present. Here, we retain the template to show + # we're using the default configuration. + + # seelog.xml isn't actually required to run, but it does ship as a template + # with debian packages, so it's here for reference. Future work in the nixos + # module could use this template and substitute a different log level. + + install -D -m 0444 -t $out/etc/amazon/ssm amazon-ssm-agent.json.template + install -D -m 0444 -T seelog_unix.xml $out/etc/amazon/ssm/seelog.xml.template + + runHook postInstall ''; postFixup = '' wrapProgram $out/bin/amazon-ssm-agent --prefix PATH : ${bashInteractive}/bin ''; + passthru = { + updateScript = nix-update-script { }; + tests.version = testers.testVersion { + package = ssm-agent; + command = "amazon-ssm-agent --version"; + }; + }; + meta = with lib; { description = "Agent to enable remote management of your Amazon EC2 instance configuration"; + changelog = "https://github.com/aws/amazon-ssm-agent/releases/tag/${version}"; homepage = "https://github.com/aws/amazon-ssm-agent"; license = licenses.asl20; platforms = platforms.unix; - maintainers = with maintainers; [ copumpkin manveru ]; + maintainers = with maintainers; [ copumpkin manveru anthonyroussel ]; + + # Darwin support is broken + broken = stdenv.isDarwin; }; } |