overlays: add 'woodpecker-2.0.0-rc.0'

The point was initially to quickly test the release candidate and wait
for the official v2.

Unfortunately I've encountered some issues trying to get the package
working for the official version. So let's just roll with it for now...
This commit is contained in:
Bruno BELANYI 2023-11-30 20:28:25 +01:00
parent 49742deb18
commit 63314c9a4a
9 changed files with 3783 additions and 0 deletions

View file

@ -0,0 +1,17 @@
{ buildGoModule, callPackage }:
let
common = callPackage ./common.nix { };
in
buildGoModule {
pname = "woodpecker-agent";
inherit (common) version src ldflags postInstall vendorHash;
subPackages = "cmd/agent";
CGO_ENABLED = 0;
meta = common.meta // {
description = "Woodpecker Continuous Integration agent";
mainProgram = "woodpecker-agent";
};
}

View file

@ -0,0 +1,17 @@
{ buildGoModule, callPackage }:
let
common = callPackage ./common.nix { };
in
buildGoModule {
pname = "woodpecker-cli";
inherit (common) version src ldflags postInstall vendorHash;
subPackages = "cmd/cli";
CGO_ENABLED = 0;
meta = common.meta // {
description = "Command line client for the Woodpecker Continuous Integration server";
mainProgram = "woodpecker-cli";
};
}

View file

@ -0,0 +1,38 @@
{ lib, fetchFromGitHub }:
let
version = "2.0.0-rc.0";
srcHash = "sha256-n4rJNBgOQV4rKoFirHW63q520HF8PYBmtwx7iEmht+E=";
vendorHash = "sha256-/GOwsrYzVoYjJZ27sp/gzp1N3de6P16v+kHY1u1wTKs=";
yarnHash = "sha256-IZbhn95wBCeh0DJDe+S/9Vqx4CHAQ+4QA5jp6xc9hmY=";
in
{
inherit version yarnHash vendorHash;
src = fetchFromGitHub {
owner = "woodpecker-ci";
repo = "woodpecker";
rev = "v${version}";
hash = srcHash;
};
postInstall = ''
cd $out/bin
for f in *; do
mv -- "$f" "woodpecker-$f"
done
cd -
'';
ldflags = [
"-s"
"-w"
"-X go.woodpecker-ci.org/woodpecker/version.Version=${version}"
];
meta = with lib; {
homepage = "https://woodpecker-ci.org/";
changelog = "https://github.com/woodpecker-ci/woodpecker/blob/v${version}/CHANGELOG.md";
license = licenses.asl20;
maintainers = with maintainers; [ ambroisie techknowlogick adamcstephens ];
};
}

View file

@ -0,0 +1,10 @@
self: _super:
{
woodpecker-agent = self.callPackage ./agent.nix { };
woodpecker-cli = self.callPackage ./cli.nix { };
woodpecker-server = self.callPackage ./server.nix {
woodpecker-frontend = self.callPackage ./frontend.nix { };
};
}

View file

@ -0,0 +1,63 @@
{ lib, buildPackages, callPackage, fetchFromGitHub, fetchYarnDeps, mkYarnPackage }:
let
common = callPackage ./common.nix { };
esbuild_0_18_20 = buildPackages.esbuild.overrideAttrs (_: rec {
version = "0.18.20";
src = fetchFromGitHub {
owner = "evanw";
repo = "esbuild";
rev = "v${version}";
hash = "sha256-mED3h+mY+4H465m02ewFK/BgA1i/PQ+ksUNxBlgpUoI=";
};
vendorHash = "sha256-+BfxCyg0KkDQpHt/wycy/8CTG6YBA/VJvJFhhzUnSiQ=";
});
in
mkYarnPackage {
pname = "woodpecker-frontend";
inherit (common) version;
src = "${common.src}/web";
packageJSON = ./woodpecker-package.json;
yarnLock = ./yarn.lock;
offlineCache = fetchYarnDeps {
yarnLock = ./yarn.lock;
hash = common.yarnHash;
};
ESBUILD_BINARY_PATH = lib.getExe esbuild_0_18_20;
postPatch = ''
substituteInPlace vite.config.ts \
--replace 'src/' '/build/web/deps/woodpecker-ci/src/' \
--replace 'node_modules/' '/build/web/node_modules/'
'';
buildPhase = ''
runHook preBuild
yarn --offline build
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -R deps/woodpecker-ci/dist $out
echo "${common.version}" > "$out/version"
runHook postInstall
'';
# Do not attempt generating a tarball for woodpecker-frontend again.
doDist = false;
meta = common.meta // {
description = "Woodpecker Continuous Integration server frontend";
};
}

View file

@ -0,0 +1,27 @@
{ buildGoModule, callPackage, woodpecker-frontend }:
let
common = callPackage ./common.nix { };
in
buildGoModule {
pname = "woodpecker-server";
inherit (common) version src ldflags postInstall vendorHash;
postPatch = ''
cp -r ${woodpecker-frontend} web/dist
'';
subPackages = "cmd/server";
CGO_ENABLED = 1;
passthru = {
inherit woodpecker-frontend;
updateScript = ./update.sh;
};
meta = common.meta // {
description = "Woodpecker Continuous Integration server";
mainProgram = "woodpecker-server";
};
}

View file

@ -0,0 +1,50 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix wget prefetch-yarn-deps nix-prefetch-github jq nix-prefetch pnpm-lock-export
# shellcheck shell=bash
if [ -n "$GITHUB_TOKEN" ]; then
TOKEN_ARGS=(--header "Authorization: token $GITHUB_TOKEN")
fi
if [[ $# -gt 1 || $1 == -* ]]; then
echo "Regenerates packaging data for the woodpecker packages."
echo "Usage: $0 [git release tag]"
exit 1
fi
set -x
cd "$(dirname "$0")"
version="$1"
set -euo pipefail
if [ -z "$version" ]; then
version="$(wget -O- "${TOKEN_ARGS[@]}" "https://api.github.com/repos/woodpecker-ci/woodpecker/releases?per_page=1" | jq -r '.[0].tag_name')"
fi
# strip leading "v"
version="${version#v}"
sed -i -E -e "s#version = \".*\"#version = \"$version\"#" common.nix
# Woodpecker repository
src_hash=$(nix-prefetch-github woodpecker-ci woodpecker --rev "v${version}" | jq -r .hash)
src_hash=$(nix hash to-sri --type sha256 "$src_hash")
sed -i -E -e "s#srcHash = \".*\"#srcHash = \"$src_hash\"#" common.nix
# Go modules
vendorHash=$(nix-prefetch '{ sha256 }: (callPackage (import ./cli.nix) { }).goModules.overrideAttrs (_: { modHash = sha256; })')
vendorHash=$(nix hash to-sri --type sha256 "$vendorHash")
sed -i -E -e "s#vendorHash = \".*\"#vendorHash = \"$vendorHash\"#" common.nix
# Front-end dependencies
woodpecker_src="https://raw.githubusercontent.com/woodpecker-ci/woodpecker/v$version"
wget "${TOKEN_ARGS[@]}" "$woodpecker_src/web/package.json" -O woodpecker-package.json
trap 'rm -rf pnpm-lock.yaml' EXIT
wget "${TOKEN_ARGS[@]}" "$woodpecker_src/web/pnpm-lock.yaml"
pnpm-lock-export --schema yarn.lock@v1
yarn_hash=$(prefetch-yarn-deps yarn.lock)
yarn_hash=$(nix hash to-sri --type sha256 "$yarn_hash")
sed -i -E -e "s#yarnHash = \".*\"#yarnHash = \"$yarn_hash\"#" common.nix

View file

@ -0,0 +1,76 @@
{
"name": "woodpecker-ci",
"author": "Woodpecker CI",
"version": "0.0.0",
"license": "Apache-2.0",
"engines": {
"node": ">=14"
},
"scripts": {
"start": "vite",
"build": "vite build --base=/BASE_PATH",
"serve": "vite preview",
"lint": "eslint --max-warnings 0 --ext .js,.ts,.vue,.json .",
"format": "prettier --write .",
"format:check": "prettier -c .",
"typecheck": "vue-tsc --noEmit",
"test": "echo 'No tests configured' && exit 0"
},
"dependencies": {
"@intlify/unplugin-vue-i18n": "^1.0.0",
"@kyvg/vue3-notification": "^3.0.0",
"@vueuse/core": "^10.5.0",
"ansi_up": "^6.0.0",
"dayjs": "^1.11.9",
"fuse.js": "^7.0.0",
"humanize-duration": "^3.28.0",
"javascript-time-ago": "^2.5.9",
"lodash": "^4.17.21",
"node-emoji": "^2.0.0",
"pinia": "^2.1.4",
"prismjs": "^1.29.0",
"vue": "^3.3.4",
"vue-i18n": "^9.2.2",
"vue-router": "^4.2.2"
},
"devDependencies": {
"@iconify/json": "^2.2.131",
"@types/humanize-duration": "^3.27.1",
"@types/javascript-time-ago": "^2.0.3",
"@types/lodash": "^4.14.195",
"@types/node": "^20.0.0",
"@types/node-emoji": "^1.8.2",
"@types/prismjs": "^1.26.0",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"@vitejs/plugin-vue": "^4.2.3",
"@vue/compiler-sfc": "^3.3.6",
"eslint": "^8.44.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-vue": "^9.17.0",
"eslint-plugin-vue-scoped-css": "^2.5.0",
"prettier": "^3.0.0",
"tinycolor2": "^1.6.0",
"typescript": "5.2.2",
"unplugin-icons": "^0.17.0",
"unplugin-vue-components": "^0.25.0",
"vite": "^4.3.9",
"vite-plugin-prismjs": "^0.0.8",
"vite-plugin-windicss": "^1.9.0",
"vite-svg-loader": "^4.0.0",
"vue-eslint-parser": "^9.3.1",
"vue-tsc": "^1.8.19",
"windicss": "^3.5.6"
},
"pnpm": {
"overrides": {
"semver@<7.5.2": ">=7.5.2"
}
}
}

File diff suppressed because it is too large Load diff