1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 nix-update-script,
6 bash,
7 coreutils,
8 gnutar,
9 gzip,
10 makeWrapper,
11}:
12
13buildGoModule {
14 pname = "spread";
15 version = "0-unstable-2025-02-06";
16
17 src = fetchFromGitHub {
18 owner = "snapcore";
19 repo = "spread";
20 rev = "d6447c43754c8ca0741901e9db73d5fdb4d21c93";
21 hash = "sha256-6d7FuEzO5Ond3xjKpf5iRIp9LEV/4O5g3j/tZQEDCZg=";
22 };
23
24 vendorHash = "sha256-yKDz8Hz8T6D7MZAV8ePa3mVwo4jycX3uVgzxjRp2O5o=";
25
26 subPackages = [ "cmd/spread" ];
27
28 nativeBuildInputs = [ makeWrapper ];
29
30 patches = [
31 # The upstream project statically assigns a PATH when running scripts in the
32 # local machine context. This patch keeps that static PATH assignment, but also
33 # appends the PATH from the environment context in which spread was run, so
34 # that nix-installed binaries are also available.
35 ./local-script-path.patch
36 ];
37
38 postPatch = ''
39 # Replace direct calls to /bin/bash
40 substituteInPlace spread/lxd.go --replace-fail '"/bin/bash", ' '"/usr/bin/env", "bash", '
41 substituteInPlace spread/client.go --replace-fail '"/bin/bash", ' '"/usr/bin/env", "bash", '
42 substituteInPlace spread/project.go --replace-fail '"/bin/bash", ' '"/usr/bin/env", "bash", '
43 '';
44
45 postInstall = ''
46 wrapProgram $out/bin/spread --prefix PATH : ${
47 lib.makeBinPath [
48 bash
49 coreutils
50 gnutar
51 gzip
52 ]
53 }
54 '';
55
56 passthru.updateScript = nix-update-script { };
57
58 meta = {
59 mainProgram = "spread";
60 license = lib.licenses.gpl3Only;
61 description = "Convenient full-system test (task) distribution";
62 homepage = "https://github.com/snapcore/spread";
63 maintainers = with lib.maintainers; [ jnsgruk ];
64 platforms = lib.platforms.unix;
65 };
66}