summary refs log tree commit diff
path: root/pkgs/applications/networking/cluster/openshift/default.nix
blob: 3b96ef4ea45e10560151671da22159697b0dc9f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{ stdenv, lib, fetchFromGitHub, buildGoPackage, which, go-bindata, rsync, utillinux
, coreutils, kerberos, clang
, components ? [
  "cmd/oc"
  "cmd/openshift"
  ]
}:

with lib;

let
  version = "3.11.0";
  ver = stdenv.lib.elemAt (stdenv.lib.splitVersion version);
  versionMajor = ver 0;
  versionMinor = ver 1;
  versionPatch = ver 2;
  gitCommit = "0cbc58b";
  # version is in vendor/k8s.io/kubernetes/pkg/version/base.go
  k8sversion = "v1.11.1";
  k8sgitcommit = "b1b2997";
  k8sgitMajor = "0";
  k8sgitMinor = "1";
in buildGoPackage rec {
  pname = "openshift-origin";
  inherit version;

  src = fetchFromGitHub {
    owner = "openshift";
    repo = "origin";
    rev = "v${version}";
    sha256 = "06q4v2a1mm6c659ab0rzkqz6b66vx4avqfg0s9xckwhq420lzgka";
  };

  goPackagePath = "github.com/openshift/origin";

  buildInputs = [ which rsync go-bindata kerberos clang ];

  patchPhase = ''
    patchShebangs ./hack

    substituteInPlace pkg/oc/clusterup/docker/host/host.go  \
      --replace 'nsenter --mount=/rootfs/proc/1/ns/mnt findmnt' \
      'nsenter --mount=/rootfs/proc/1/ns/mnt ${utillinux}/bin/findmnt'

    substituteInPlace pkg/oc/clusterup/docker/host/host.go  \
      --replace 'nsenter --mount=/rootfs/proc/1/ns/mnt mount' \
      'nsenter --mount=/rootfs/proc/1/ns/mnt ${utillinux}/bin/mount'

    substituteInPlace pkg/oc/clusterup/docker/host/host.go  \
      --replace 'nsenter --mount=/rootfs/proc/1/ns/mnt mkdir' \
      'nsenter --mount=/rootfs/proc/1/ns/mnt ${coreutils}/bin/mkdir'
  '';

  buildPhase = ''
    cd go/src/${goPackagePath}
    # Openshift build require this variables to be set
    # unless there is a .git folder which is not the case with fetchFromGitHub
    echo "OS_GIT_VERSION=v${version}" >> os-version-defs
    echo "OS_GIT_MAJOR=${versionMajor}" >> os-version-defs
    echo "OS_GIT_MINOR=${versionMinor}" >> os-version-defs
    echo "OS_GIT_PATCH=${versionPatch}" >> os-version-defs
    echo "OS_GIT_COMMIT=${gitCommit}" >> os-version-defs
    echo "KUBE_GIT_VERSION=${k8sversion}" >> os-version-defs
    echo "KUBE_GIT_COMMIT=${k8sgitcommit}" >> os-version-defs
    echo "KUBE_GIT_MAJOR=${k8sgitMajor}" >> os-version-defs
    echo "KUBE_GIT_MINOR=${k8sgitMinor}" >> os-version-defs
    export OS_VERSION_FILE="os-version-defs"
    export CC=clang
    make all WHAT='${concatStringsSep " " components}'
  '';

  installPhase = ''
    mkdir -p $bin/bin
    cp -a "_output/local/bin/$(go env GOOS)/$(go env GOARCH)/"* "$bin/bin/"
    install -D -t "$bin/etc/bash_completion.d" contrib/completions/bash/*
    install -D -t "$bin/share/zsh/site-functions" contrib/completions/zsh/*
  '';

  meta = with stdenv.lib; {
    description = "Build, deploy, and manage your applications with Docker and Kubernetes";
    license = licenses.asl20;
    homepage = http://www.openshift.org;
    maintainers = with maintainers; [offline bachp moretea];
    platforms = platforms.unix;
  };
}