mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-25 20:34:52 +03:00
commit
cb81126e8e
@ -42,9 +42,9 @@ with lib;
|
||||
# Those pieces of software we entirely ignore upstream's handling of, and just
|
||||
# make sure they're in the path if desired.
|
||||
let
|
||||
k3sVersion = "1.17.3+k3s1"; # k3s git tag
|
||||
traefikChartVersion = "1.81.0"; # taken from ./scripts/version.sh at the above k3s tag
|
||||
k3sRootVersion = "0.3.0"; # taken from .s/cripts/version.sh at the above k3s tag
|
||||
k3sVersion = "1.18.2+k3s1"; # k3s git tag
|
||||
traefikChartVersion = "1.81.0"; # taken from ./scripts/download at the above k3s tag
|
||||
k3sRootVersion = "0.3.0"; # taken from .s/cripts/download at the above k3s tag
|
||||
# bundled into the k3s binary
|
||||
traefikChart = fetchurl {
|
||||
url = "https://kubernetes-charts.storage.googleapis.com/traefik-${traefikChartVersion}.tgz";
|
||||
@ -93,7 +93,7 @@ let
|
||||
url = "https://github.com/rancher/k3s";
|
||||
rev = "v${k3sVersion}";
|
||||
leaveDotGit = true; # ./scripts/version.sh depends on git
|
||||
sha256 = "0qahyc0mf9glxj49va6d20mcncqg4svfic2iz8b1lqid5c4g68mm";
|
||||
sha256 = "01ww3d71mlri2fk6z54rbd697aqwj942kbg323k0hfsnx7flkhps";
|
||||
};
|
||||
# Stage 1 of the k3s build:
|
||||
# Let's talk about how k3s is structured.
|
||||
@ -124,7 +124,7 @@ let
|
||||
|
||||
src = k3sRepo;
|
||||
|
||||
patches = [ ./patches/00-k3s.patch ];
|
||||
patches = [ ./patches/0001-Use-rm-from-path-in-go-generate.patch ./patches/0002-Add-nixpkgs-patches.patch ];
|
||||
|
||||
nativeBuildInputs = [ git pkgconfig ];
|
||||
buildInputs = [ libseccomp ];
|
||||
@ -164,7 +164,7 @@ let
|
||||
|
||||
src = k3sRepo;
|
||||
|
||||
patches = [ ./patches/00-k3s.patch ];
|
||||
patches = [ ./patches/0001-Use-rm-from-path-in-go-generate.patch ./patches/0002-Add-nixpkgs-patches.patch ];
|
||||
|
||||
nativeBuildInputs = [ git pkgconfig ];
|
||||
buildInputs = [ k3sBuildStage1 k3sPlugins runc ];
|
||||
|
@ -1,81 +0,0 @@
|
||||
diff --git a/main.go b/main.go
|
||||
index 62908bb7bb..0527222887 100644
|
||||
--- a/main.go
|
||||
+++ b/main.go
|
||||
@@ -1,5 +1,5 @@
|
||||
//go:generate go run pkg/codegen/cleanup/main.go
|
||||
-//go:generate /bin/rm -rf pkg/generated
|
||||
+//go:generate rm -rf pkg/generated
|
||||
//go:generate go run pkg/codegen/main.go
|
||||
//go:generate go fmt pkg/deploy/zz_generated_bindata.go
|
||||
//go:generate go fmt pkg/static/zz_generated_bindata.go
|
||||
diff --git a/scripts/build b/scripts/build
|
||||
index 72d3c07ece..3e5455b262 100755
|
||||
--- a/scripts/build
|
||||
+++ b/scripts/build
|
||||
@@ -10,7 +10,8 @@ PKG_CONTAINERD="github.com/containerd/containerd"
|
||||
PKG_RANCHER_CONTAINERD="github.com/rancher/containerd"
|
||||
PKG_CRICTL="github.com/kubernetes-sigs/cri-tools"
|
||||
|
||||
-buildDate=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
|
||||
+# Deterministic build date
|
||||
+buildDate="$(date -d "$(git log -1 --format=%ai)" -u "+%Y-%m-%dT%H:%M:%SZ")"
|
||||
|
||||
VENDOR_PREFIX="${PKG}/vendor/"
|
||||
VERSIONFLAGS="
|
||||
@@ -82,17 +83,7 @@ cleanup() {
|
||||
}
|
||||
|
||||
INSTALLBIN=$(pwd)/bin
|
||||
-if [ ! -x ${INSTALLBIN}/cni ]; then
|
||||
-(
|
||||
- echo Building cni
|
||||
- TMPDIR=$(mktemp -d)
|
||||
- trap cleanup EXIT
|
||||
- WORKDIR=$TMPDIR/src/github.com/containernetworking/plugins
|
||||
- git clone -b $VERSION_CNIPLUGINS https://github.com/rancher/plugins.git $WORKDIR
|
||||
- cd $WORKDIR
|
||||
- GOPATH=$TMPDIR CGO_ENABLED=0 go build -tags "$TAGS" -ldflags "$LDFLAGS $STATIC" -o $INSTALLBIN/cni
|
||||
-)
|
||||
-fi
|
||||
+# skip building cni, use our separately built one
|
||||
# echo Building agent
|
||||
# CGO_ENABLED=1 go build -tags "$TAGS" -ldflags "$VERSIONFLAGS $LDFLAGS $STATIC" -o bin/k3s-agent ./cmd/agent/main.go
|
||||
echo Building server
|
||||
@@ -108,9 +99,8 @@ ln -s containerd ./bin/ctr
|
||||
#CGO_ENABLED=1 go build -tags "$TAGS" -ldflags "$VERSIONFLAGS $LDFLAGS $STATIC_SQLITE" -o bin/ctr ./cmd/ctr/main.go
|
||||
# echo Building containerd
|
||||
# CGO_ENABLED=0 go build -tags "$TAGS" -ldflags "$VERSIONFLAGS $LDFLAGS $STATIC" -o bin/containerd ./cmd/containerd/
|
||||
-echo Building runc
|
||||
-make EXTRA_LDFLAGS="-w -s" BUILDTAGS="apparmor seccomp" -C ./vendor/github.com/opencontainers/runc static
|
||||
-cp -f ./vendor/github.com/opencontainers/runc/runc ./bin/runc
|
||||
+
|
||||
+# skip building runc; use our packaged one
|
||||
|
||||
echo Building containerd-shim
|
||||
make -C ./vendor/github.com/containerd/containerd bin/containerd-shim
|
||||
diff --git a/scripts/package-cli b/scripts/package-cli
|
||||
index 4c66ce32df..280b428bb8 100755
|
||||
--- a/scripts/package-cli
|
||||
+++ b/scripts/package-cli
|
||||
@@ -49,16 +49,16 @@ fi
|
||||
|
||||
CMD_NAME=dist/artifacts/k3s${BIN_SUFFIX}
|
||||
|
||||
-go generate
|
||||
+CGO_ENABLED=0 env -u GOARCH go generate
|
||||
LDFLAGS="
|
||||
-X github.com/rancher/k3s/pkg/version.Version=$VERSION
|
||||
-X github.com/rancher/k3s/pkg/version.GitCommit=${COMMIT:0:8}
|
||||
-w -s
|
||||
"
|
||||
-STATIC="-extldflags '-static'"
|
||||
if [ "$DQLITE" = "true" ]; then
|
||||
DQLITE_TAGS="dqlite"
|
||||
fi
|
||||
-CGO_ENABLED=0 go build -tags "$DQLITE_TAGS" -ldflags "$LDFLAGS $STATIC" -o ${CMD_NAME} ./cmd/k3s/main.go
|
||||
+go build -tags "$DQLITE_TAGS" -ldflags "$LDFLAGS" -o ${CMD_NAME} ./cmd/k3s/main.go
|
||||
|
||||
-./scripts/build-upload ${CMD_NAME} ${COMMIT}
|
||||
+# for nixos, don't upload it
|
||||
+# ./scripts/build-upload ${CMD_NAME} ${COMMIT}
|
@ -0,0 +1,25 @@
|
||||
From e79ddef65d08599ae3fe8ff39d202ea2416650b8 Mon Sep 17 00:00:00 2001
|
||||
From: Euan Kemp <euank@euank.com>
|
||||
Date: Sun, 31 May 2020 17:27:05 -0700
|
||||
Subject: [PATCH 1/2] Use 'rm' from path in go generate
|
||||
|
||||
/bin/rm is less portable. On some distros, like nixos, it doesn't exist
|
||||
at all.
|
||||
---
|
||||
main.go | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/main.go b/main.go
|
||||
index 62908bb7bb..0527222887 100644
|
||||
--- a/main.go
|
||||
+++ b/main.go
|
||||
@@ -1,5 +1,5 @@
|
||||
//go:generate go run pkg/codegen/cleanup/main.go
|
||||
-//go:generate /bin/rm -rf pkg/generated
|
||||
+//go:generate rm -rf pkg/generated
|
||||
//go:generate go run pkg/codegen/main.go
|
||||
//go:generate go fmt pkg/deploy/zz_generated_bindata.go
|
||||
//go:generate go fmt pkg/static/zz_generated_bindata.go
|
||||
--
|
||||
2.25.4
|
||||
|
@ -0,0 +1,87 @@
|
||||
From 1891be119e298ef7c86347a6b74d40ff539cf06e Mon Sep 17 00:00:00 2001
|
||||
From: Euan Kemp <euank@euank.com>
|
||||
Date: Sun, 31 May 2020 19:02:37 -0700
|
||||
Subject: [PATCH 2/2] Add nixpkgs patches
|
||||
|
||||
These patches let us re-use the upstream build scripts when building for
|
||||
nix.
|
||||
---
|
||||
scripts/build | 20 ++++----------------
|
||||
scripts/package-cli | 10 ++++++----
|
||||
2 files changed, 10 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/scripts/build b/scripts/build
|
||||
index 4ca6333c4a..df15f7db1d 100755
|
||||
--- a/scripts/build
|
||||
+++ b/scripts/build
|
||||
@@ -12,7 +12,8 @@ PKG_CONTAINERD="github.com/containerd/containerd"
|
||||
PKG_RANCHER_CONTAINERD="github.com/rancher/containerd"
|
||||
PKG_CRICTL="github.com/kubernetes-sigs/cri-tools"
|
||||
|
||||
-buildDate=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
|
||||
+# nixpkgs: deterministic build date
|
||||
+buildDate="$(date -d "$(git log -1 --format=%ai)" -u "+%Y-%m-%dT%H:%M:%SZ")"
|
||||
|
||||
VENDOR_PREFIX="${PKG}/vendor/"
|
||||
VERSIONFLAGS="
|
||||
@@ -92,17 +93,7 @@ cleanup() {
|
||||
}
|
||||
|
||||
INSTALLBIN=$(pwd)/bin
|
||||
-if [ ! -x ${INSTALLBIN}/cni ]; then
|
||||
-(
|
||||
- echo Building cni
|
||||
- TMPDIR=$(mktemp -d)
|
||||
- trap cleanup EXIT
|
||||
- WORKDIR=$TMPDIR/src/github.com/containernetworking/plugins
|
||||
- git clone -b $VERSION_CNIPLUGINS https://github.com/rancher/plugins.git $WORKDIR
|
||||
- cd $WORKDIR
|
||||
- GOPATH=$TMPDIR CGO_ENABLED=0 "${GO}" build -tags "$TAGS" -ldflags "$LDFLAGS $STATIC" -o $INSTALLBIN/cni
|
||||
-)
|
||||
-fi
|
||||
+# nixpkgs: skip building cni, we build it separately
|
||||
# echo Building agent
|
||||
# CGO_ENABLED=1 "${GO}" build -tags "$TAGS" -ldflags "$VERSIONFLAGS $LDFLAGS $STATIC" -o bin/k3s-agent ./cmd/agent/main.go
|
||||
echo Building server
|
||||
@@ -118,10 +109,7 @@ ln -s containerd ./bin/ctr
|
||||
#CGO_ENABLED=1 "${GO}" build -tags "$TAGS" -ldflags "$VERSIONFLAGS $LDFLAGS $STATIC_SQLITE" -o bin/ctr ./cmd/ctr/main.go
|
||||
# echo Building containerd
|
||||
# CGO_ENABLED=0 "${GO}" build -tags "$TAGS" -ldflags "$VERSIONFLAGS $LDFLAGS $STATIC" -o bin/containerd ./cmd/containerd/
|
||||
-echo Building runc
|
||||
-rm -f ./vendor/github.com/opencontainers/runc/runc
|
||||
-make EXTRA_LDFLAGS="-w -s" BUILDTAGS="$RUNC_TAGS" -C ./vendor/github.com/opencontainers/runc $RUNC_STATIC
|
||||
-cp -f ./vendor/github.com/opencontainers/runc/runc ./bin/runc
|
||||
+# nixpkgs: we build runc separately
|
||||
|
||||
echo Building containerd-shim
|
||||
rm -f ./vendor/github.com/containerd/containerd/bin/containerd-shim
|
||||
diff --git a/scripts/package-cli b/scripts/package-cli
|
||||
index f33d8c66dd..da34397a28 100755
|
||||
--- a/scripts/package-cli
|
||||
+++ b/scripts/package-cli
|
||||
@@ -49,16 +49,18 @@ fi
|
||||
|
||||
CMD_NAME=dist/artifacts/k3s${BIN_SUFFIX}
|
||||
|
||||
-"${GO}" generate
|
||||
+CGO_ENABLED=0 env -u GOARCH "${GO}" generate
|
||||
LDFLAGS="
|
||||
-X github.com/rancher/k3s/pkg/version.Version=$VERSION
|
||||
-X github.com/rancher/k3s/pkg/version.GitCommit=${COMMIT:0:8}
|
||||
-w -s
|
||||
"
|
||||
-STATIC="-extldflags '-static'"
|
||||
+# STATIC="-extldflags '-static'"
|
||||
+# nixpkgs: we can depend on dynamic linking because we have a good package manager
|
||||
if [ "$DQLITE" = "true" ]; then
|
||||
DQLITE_TAGS="dqlite"
|
||||
fi
|
||||
-CGO_ENABLED=0 "${GO}" build -tags "$DQLITE_TAGS" -ldflags "$LDFLAGS $STATIC" -o ${CMD_NAME} ./cmd/k3s/main.go
|
||||
+"${GO}" build -tags "$DQLITE_TAGS" -ldflags "$LDFLAGS" -o ${CMD_NAME} ./cmd/k3s/main.go
|
||||
|
||||
-./scripts/build-upload ${CMD_NAME} ${COMMIT}
|
||||
+# nixpkgs: skip uploading
|
||||
+# ./scripts/build-upload ${CMD_NAME} ${COMMIT}
|
||||
--
|
||||
2.25.4
|
||||
|
Loading…
Reference in New Issue
Block a user