nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv
2, lib
3, buildGoModule
4, coreutils
5, fetchFromGitHub
6, installShellFiles
7, git
8 # passthru
9, runCommand
10, makeWrapper
11, pulumi
12, pulumiPackages
13}:
14
15buildGoModule rec {
16 pname = "pulumi";
17 version = "3.60.1";
18
19 # Used in pulumi-language packages, which inherit this prop
20 sdkVendorHash = "sha256-oXsU4h4CwukJHttYLT7JiW2He8Yq5qAwnxL8+G5FIpc=";
21
22 src = fetchFromGitHub {
23 owner = pname;
24 repo = pname;
25 rev = "v${version}";
26 hash = "sha256-bSuntT5b8UVrYw4ds4AfZB3Plvav5zGaEQpe34FefXk=";
27 # Some tests rely on checkout directory name
28 name = "pulumi";
29 };
30
31 vendorHash = "sha256-QDF2z8AjULQYvlxah/JgmbzoPuKQrgQng/33S+7K1Bw=";
32
33 sourceRoot = "${src.name}/pkg";
34
35 nativeBuildInputs = [ installShellFiles ];
36
37 # Bundle release metadata
38 ldflags = [
39 # Omit the symbol table and debug information.
40 "-s"
41 # Omit the DWARF symbol table.
42 "-w"
43 ] ++ importpathFlags;
44
45 importpathFlags = [
46 "-X github.com/pulumi/pulumi/pkg/v3/version.Version=v${version}"
47 ];
48
49 doCheck = true;
50
51 disabledTests = [
52 # Flaky test
53 "TestPendingDeleteOrder"
54 ];
55
56 nativeCheckInputs = [
57 git
58 ];
59
60 preCheck = ''
61 # The tests require `version.Version` to be unset
62 ldflags=''${ldflags//"$importpathFlags"/}
63
64 # Create some placeholders for plugins used in tests. Otherwise, Pulumi
65 # tries to donwload them and fails, resulting in really long test runs
66 dummyPluginPath=$(mktemp -d)
67 for name in pulumi-{resource-pkg{A,B},-pkgB}; do
68 ln -s ${coreutils}/bin/true "$dummyPluginPath/$name"
69 done
70
71 export PATH=$dummyPluginPath''${PATH:+:}$PATH
72
73 # Code generation tests also download dependencies from network
74 rm codegen/{docs,dotnet,go,nodejs,python,schema}/*_test.go
75 rm -R codegen/{dotnet,go,nodejs,python}/gen_program_test
76
77 # Only run tests not marked as disabled
78 buildFlagsArray+=("-run" "[^(${lib.concatStringsSep "|" disabledTests})]")
79 '' + lib.optionalString stdenv.isDarwin ''
80 export PULUMI_HOME=$(mktemp -d)
81 '';
82
83 # Allow tests that bind or connect to localhost on macOS.
84 __darwinAllowLocalNetworking = true;
85
86 doInstallCheck = true;
87 installCheckPhase = ''
88 PULUMI_SKIP_UPDATE_CHECK=1 $out/bin/pulumi version | grep v${version} > /dev/null
89 '';
90
91 postInstall = ''
92 installShellCompletion --cmd pulumi \
93 --bash <($out/bin/pulumi gen-completion bash) \
94 --fish <($out/bin/pulumi gen-completion fish) \
95 --zsh <($out/bin/pulumi gen-completion zsh)
96 '';
97
98 passthru = {
99 pkgs = pulumiPackages;
100 withPackages = f: runCommand "${pulumi.name}-with-packages"
101 {
102 nativeBuildInputs = [ makeWrapper ];
103 }
104 ''
105 mkdir -p $out/bin
106 makeWrapper ${pulumi}/bin/pulumi $out/bin/pulumi \
107 --suffix PATH : ${lib.makeSearchPath "bin" (f pulumiPackages)}
108 '';
109 };
110
111 meta = with lib; {
112 homepage = "https://pulumi.io/";
113 description = "Pulumi is a cloud development platform that makes creating cloud programs easy and productive";
114 sourceProvenance = [ sourceTypes.fromSource ];
115 license = licenses.asl20;
116 platforms = platforms.unix;
117 maintainers = with maintainers; [
118 trundle
119 veehaitch
120 ];
121 };
122}