-
-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
447 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
{ lib | ||
, stdenv | ||
, fetchFromGitHub | ||
, fetchYarnDeps | ||
, buildGoModule | ||
, systemd | ||
, yarn | ||
, fixup-yarn-lock | ||
, nodejs | ||
, grafana-alloy | ||
, nix-update-script | ||
, installShellFiles | ||
, testers | ||
}: | ||
|
||
buildGoModule rec { | ||
pname = "grafana-alloy"; | ||
version = "1.1.1"; | ||
|
||
src = fetchFromGitHub { | ||
rev = "v${version}"; | ||
owner = "grafana"; | ||
repo = "alloy"; | ||
hash = "sha256-jaOQG+QkVi10lUp6izvSGE9j76ULc4yKbxdDhLHykYI="; | ||
}; | ||
|
||
proxyVendor = true; | ||
vendorHash = "sha256-6Xc2siImM1Dl716uGhtAGcn+PO2OLuYLxanzg8Ho6SA="; | ||
|
||
nativeBuildInputs = [ fixup-yarn-lock yarn nodejs installShellFiles ]; | ||
|
||
ldflags = | ||
let | ||
prefix = "github.com/grafana/alloy/internal/build"; | ||
in | ||
[ | ||
"-s" | ||
"-w" | ||
# https://github.com/grafana/alloy/blob/3201389252d2c011bee15ace0c9f4cdbcb978f9f/Makefile#L110 | ||
"-X ${prefix}.Branch=v${version}" | ||
"-X ${prefix}.Version=${version}" | ||
"-X ${prefix}.Revision=v${version}" | ||
"-X ${prefix}.BuildUser=nix" | ||
"-X ${prefix}.BuildDate=1970-01-01T00:00:00Z" | ||
]; | ||
|
||
tags = [ | ||
"netgo" | ||
"builtinassets" | ||
"promtail_journal_enabled" | ||
]; | ||
|
||
subPackages = [ | ||
"." | ||
]; | ||
|
||
yarnOfflineCache = fetchYarnDeps { | ||
yarnLock = "${src}/internal/web/ui/yarn.lock"; | ||
sha256 = "sha256-o3vCI9GHCr4SjYsiT0wQ4mN76QeAGwOfLVCzGp7NMf4="; | ||
}; | ||
|
||
preBuild = '' | ||
pushd internal/web/ui | ||
# Yarn wants a real home directory to write cache, config, etc to | ||
export HOME=$NIX_BUILD_TOP/fake_home | ||
fixup-yarn-lock yarn.lock | ||
yarn config --offline set yarn-offline-mirror ${yarnOfflineCache} | ||
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive | ||
patchShebangs node_modules/ | ||
yarn --offline build | ||
popd | ||
''; | ||
|
||
# uses go-systemd, which uses libsystemd headers | ||
# https://github.com/coreos/go-systemd/issues/351 | ||
NIX_CFLAGS_COMPILE = lib.optionals stdenv.isLinux [ "-I${lib.getDev systemd}/include" ]; | ||
|
||
checkFlags = [ | ||
"-tags nonetwork" # disable network tests | ||
"-tags nodocker" # disable docker tests | ||
]; | ||
|
||
# go-systemd uses libsystemd under the hood, which does dlopen(libsystemd) at | ||
# runtime. | ||
# Add to RUNPATH so it can be found. | ||
postFixup = lib.optionalString stdenv.isLinux '' | ||
patchelf \ | ||
--set-rpath "${lib.makeLibraryPath [ (lib.getLib systemd) ]}:$(patchelf --print-rpath $out/bin/alloy)" \ | ||
$out/bin/alloy | ||
''; | ||
|
||
postInstall = '' | ||
installShellCompletion --cmd alloy \ | ||
--bash <($out/bin/alloy completion bash) \ | ||
--fish <($out/bin/alloy completion fish) \ | ||
--zsh <($out/bin/alloy completion zsh) | ||
''; | ||
|
||
passthru = { | ||
tests = { | ||
version = testers.testVersion { | ||
version = "v${version}"; | ||
command = "${lib.getExe grafana-alloy} --version"; | ||
package = grafana-alloy; | ||
}; | ||
}; | ||
updateScript = nix-update-script { }; | ||
# alias for nix-update to be able to find and update this attribute | ||
offlineCache = yarnOfflineCache; | ||
}; | ||
|
||
meta = with lib; { | ||
description = "Open source OpenTelemetry Collector distribution with built-in Prometheus pipelines and support for metrics, logs, traces, and profiles"; | ||
mainProgram = "alloy"; | ||
license = licenses.asl20; | ||
homepage = "https://grafana.com/oss/alloy"; | ||
maintainers = with maintainers; [ flokli emilylange ]; | ||
platforms = lib.platforms.unix; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
{ | ||
lib, | ||
stdenv, | ||
fetchFromGitHub, | ||
makeWrapper, | ||
nodejs, | ||
overrideSDK, | ||
pnpm_9, | ||
python3, | ||
renovate, | ||
testers, | ||
xcbuild, | ||
}: | ||
|
||
let | ||
# fix build error, `no member named 'aligned_alloc'` on x86_64-darwin | ||
# https://github.com/NixOS/nixpkgs/issues/272156#issuecomment-1839904283 | ||
stdenv' = if stdenv.hostPlatform.isDarwin then overrideSDK stdenv "11.0" else stdenv; | ||
in | ||
stdenv'.mkDerivation (finalAttrs: { | ||
pname = "renovate"; | ||
version = "37.393.0"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "renovatebot"; | ||
repo = "renovate"; | ||
rev = "refs/tags/${finalAttrs.version}"; | ||
hash = "sha256-YgxcGNMgmwrausdR7kvG1NiyQPn0FcCq/isf9qUDCFY="; | ||
}; | ||
|
||
postPatch = '' | ||
substituteInPlace package.json \ | ||
--replace-fail "0.0.0-semantic-release" "${finalAttrs.version}" | ||
''; | ||
|
||
nativeBuildInputs = [ | ||
makeWrapper | ||
nodejs | ||
pnpm_9.configHook | ||
python3 | ||
] ++ lib.optional stdenv'.hostPlatform.isDarwin xcbuild; | ||
|
||
pnpmDeps = pnpm_9.fetchDeps { | ||
inherit (finalAttrs) pname version src; | ||
hash = "sha256-Zbe561q6xDKDIN+E/2eyQMz2GtpPvJEv2pAauMa+8pE="; | ||
}; | ||
|
||
env.COREPACK_ENABLE_STRICT = 0; | ||
|
||
buildPhase = | ||
'' | ||
runHook preBuild | ||
pnpm build | ||
pnpm prune --prod --ignore-scripts | ||
'' | ||
# The optional dependency re2 is not built by pnpm and needs to be built manually. | ||
# If re2 is not built, you will get an annoying warning when you run renovate. | ||
+ '' | ||
pushd node_modules/.pnpm/re2*/node_modules/re2 | ||
mkdir -p $HOME/.node-gyp/${nodejs.version} | ||
echo 9 > $HOME/.node-gyp/${nodejs.version}/installVersion | ||
ln -sfv ${nodejs}/include $HOME/.node-gyp/${nodejs.version} | ||
export npm_config_nodedir=${nodejs} | ||
npm run rebuild | ||
popd | ||
runHook postBuild | ||
''; | ||
|
||
# TODO: replace with `pnpm deploy` | ||
# now it fails to build with ERR_PNPM_NO_OFFLINE_META | ||
# see https://github.com/pnpm/pnpm/issues/5315 | ||
installPhase = '' | ||
runHook preInstall | ||
mkdir -p $out/{bin,lib/node_modules/renovate} | ||
cp -r dist node_modules package.json $out/lib/node_modules/renovate | ||
makeWrapper "${lib.getExe nodejs}" "$out/bin/renovate" \ | ||
--add-flags "$out/lib/node_modules/renovate/dist/renovate.js" | ||
makeWrapper "${lib.getExe nodejs}" "$out/bin/config-validator" \ | ||
--add-flags "$out/lib/node_modules/renovate/dist/config-validator.js" | ||
runHook postInstall | ||
''; | ||
|
||
passthru.tests = { | ||
version = testers.testVersion { package = renovate; }; | ||
}; | ||
|
||
meta = { | ||
description = "Cross-platform Dependency Automation by Mend.io"; | ||
homepage = "https://github.com/renovatebot/renovate"; | ||
license = lib.licenses.agpl3Only; | ||
maintainers = with lib.maintainers; [ | ||
marie | ||
natsukium | ||
]; | ||
mainProgram = "renovate"; | ||
platforms = nodejs.meta.platforms; | ||
}; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.