1{ lib
2, buildGoPackage
3, fetchFromGitHub
4, makeWrapper
5}:
6
7buildGoPackage rec {
8 pname = "docker-slim";
9 version = "1.37.2";
10
11 goPackagePath = "github.com/docker-slim/docker-slim";
12
13 src = fetchFromGitHub {
14 owner = "docker-slim";
15 repo = "docker-slim";
16 rev = version;
17 sha256 = "1svhi9xf71zrk843bnwkpmq4iaaln07dpfrdvq0vdqhj5xvbx47g";
18 };
19
20 subPackages = [ "cmd/docker-slim" "cmd/docker-slim-sensor" ];
21
22 nativeBuildInputs = [
23 makeWrapper
24 ];
25
26 ldflags = [
27 "-s" "-w"
28 "-X ${goPackagePath}/pkg/version.appVersionTag=${version}"
29 "-X ${goPackagePath}/pkg/version.appVersionRev=${src.rev}"
30 ];
31
32 # docker-slim tries to create its state dir next to the binary (inside the nix
33 # store), so we set it to use the working directory at the time of invocation
34 postInstall = ''
35 wrapProgram "$out/bin/docker-slim" --add-flags '--state-path "$(pwd)"'
36 '';
37
38 meta = with lib; {
39 description = "Minify and secure Docker containers";
40 homepage = "https://dockersl.im/";
41 changelog = "https://github.com/docker-slim/docker-slim/raw/${version}/CHANGELOG.md";
42 license = licenses.asl20;
43 maintainers = with maintainers; [ Br1ght0ne marsam mbrgm ];
44 };
45}