crc: init at 2.4.1

This commit is contained in:
Shikanime Deva 2022-05-19 21:59:13 +00:00
parent e7fd74997f
commit 6ac3297217
No known key found for this signature in database
GPG key ID: B9443725856FF9EB
3 changed files with 129 additions and 0 deletions

View file

@ -0,0 +1,74 @@
{ lib
, buildGoModule
, fetchFromGitHub
, git
, stdenv
, testers
, crc
, runtimeShell
, coreutils
}:
let
openShiftVersion = "4.10.22";
podmanVersion = "4.1.0";
writeKey = "cvpHsNcmGCJqVzf6YxrSnVlwFSAZaYtp";
in
buildGoModule rec {
version = "2.4.1";
pname = "crc";
gitCommit = "6b954d40ec3280ca63e825805503d4414a3ff55b";
src = fetchFromGitHub {
owner = "code-ready";
repo = "crc";
rev = "v${version}";
sha256 = "sha256-wjwTf+d19F1NLYmUORMU0PGJeQZd+IrlScm5DiFvAk0=";
};
vendorSha256 = null;
nativeBuildInputs = [ git ];
postPatch = ''
substituteInPlace pkg/crc/oc/oc_linux_test.go \
--replace "/bin/echo" "${coreutils}/bin/echo"
substituteInPlace Makefile \
--replace "/bin/bash" "${runtimeShell}"
'';
tags = [ "containers_image_openpgp" ];
ldflags = [
"-X github.com/code-ready/crc/pkg/crc/version.crcVersion=${version}"
"-X github.com/code-ready/crc/pkg/crc/version.bundleVersion=${openShiftVersion}"
"-X github.com/code-ready/crc/pkg/crc/version.podmanVersion=${podmanVersion}"
"-X github.com/code-ready/crc/pkg/crc/version.commitSha=${gitCommit}"
"-X github.com/code-ready/crc/pkg/crc/segment.WriteKey=${writeKey}"
];
preBuild = ''
export HOME=$(mktemp -d)
'';
# tests are currently broken on aarch64-darwin
# https://github.com/code-ready/crc/issues/3237
doCheck = !(stdenv.isDarwin && stdenv.isAarch64);
checkFlags = [ "-args --crc-binary=$out/bin/crc" ];
passthru.tests.version = testers.testVersion {
package = crc;
command = ''
export HOME=$(mktemp -d)
crc version
'';
};
meta = with lib; {
description = "Manages a local OpenShift 4.x cluster or a Podman VM optimized for testing and development purposes";
homepage = "https://crc.dev";
license = licenses.asl20;
maintainers = with maintainers; [ shikanime tricktron ];
};
}

View file

@ -0,0 +1,53 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnugrep gnused jq
set -x -eu -o pipefail
WORKDIR=$(mktemp -d)
trap "rm -rf ${WORKDIR}" EXIT
NIXPKGS_CRC_FOLDER=$(
cd $(dirname ${BASH_SOURCE[0]})
pwd -P
)
cd ${NIXPKGS_CRC_FOLDER}
LATEST_TAG_RAWFILE=${WORKDIR}/latest_tag.json
curl --silent ${GITHUB_TOKEN:+"-u \":$GITHUB_TOKEN\""} \
https://api.github.com/repos/code-ready/crc/releases >${LATEST_TAG_RAWFILE}
LATEST_TAG_NAME=$(jq 'map(.tag_name)' ${LATEST_TAG_RAWFILE} |
grep -v -e rc -e engine | tail -n +2 | head -n -1 | sed 's|[", ]||g' | sort -rV | head -n1)
CRC_VERSION=$(echo ${LATEST_TAG_NAME} | sed 's/^v//')
CRC_COMMIT=$(curl --silent ${GITHUB_TOKEN:+"-u \":$GITHUB_TOKEN\""} \
https://api.github.com/repos/code-ready/crc/tags |
jq -r "map(select(.name == \"${LATEST_TAG_NAME}\")) | .[0] | .commit.sha")
FILE_MAKEFILE=${WORKDIR}/Makefile
curl --silent https://raw.githubusercontent.com/code-ready/crc/${CRC_COMMIT}/Makefile >$FILE_MAKEFILE
OPENSHIFT_VERSION=$(grep 'OPENSHIFT_VERSION' ${FILE_MAKEFILE} |
head -n1 | awk '{print $3}')
PODMAN_VERSION=$(grep 'PODMAN_VERSION' ${FILE_MAKEFILE} |
head -n1 | awk '{print $3}')
WRITE_KEY=$(grep '$(REPOPATH)/pkg/crc/segment.WriteKey' ${FILE_MAKEFILE} |
head -n1 | awk '{print $4}' | sed -e 's/$(REPOPATH)\/pkg\/crc\/segment.WriteKey=//g')
sed -i "s|version = \".*\"|version = \"${CRC_VERSION:-}\"|" \
${NIXPKGS_CRC_FOLDER}/default.nix
sed -i "s|gitCommit = \".*\"|gitCommit = \"${CRC_COMMIT:-}\"|" \
${NIXPKGS_CRC_FOLDER}/default.nix
sed -i "s|openShiftVersion = \".*\"|openShiftVersion = \"${OPENSHIFT_VERSION:-}\"|" \
${NIXPKGS_CRC_FOLDER}/default.nix
sed -i "s|podmanVersion = \".*\"|podmanVersion = \"${PODMAN_VERSION:-}\"|" \
${NIXPKGS_CRC_FOLDER}/default.nix
sed -i "s|writeKey = \".*\"|writeKey = \"${WRITE_KEY:-}\"|" \
${NIXPKGS_CRC_FOLDER}/default.nix

View file

@ -374,6 +374,8 @@ with pkgs;
containerpilot = callPackage ../applications/networking/cluster/containerpilot { };
crc = callPackage ../applications/networking/cluster/crc { };
coordgenlibs = callPackage ../development/libraries/coordgenlibs { };
cp437 = callPackage ../tools/misc/cp437 { };