about summary refs log tree commit diff
path: root/pkgs/by-name/zi
diff options
context:
space:
mode:
authorRuby Juric <ruby@srxl.me>2023-10-03 05:11:18 +0000
committerGitHub <noreply@github.com>2023-10-03 07:11:18 +0200
commit638d19ac92232265a6e7031878ea35a0734c8def (patch)
tree44e683fe562d5b6d4f14f5b9c6f0f4b1bbb0cefc /pkgs/by-name/zi
parent4d29250d5b55fe14280906afad7afacd910850b8 (diff)
zitadel: init at 2.37.2; nixos/zitadel: init (#254896)
Diffstat (limited to 'pkgs/by-name/zi')
-rw-r--r--pkgs/by-name/zi/zitadel/console.nix51
-rw-r--r--pkgs/by-name/zi/zitadel/package.json88
-rw-r--r--pkgs/by-name/zi/zitadel/package.nix150
3 files changed, 289 insertions, 0 deletions
diff --git a/pkgs/by-name/zi/zitadel/console.nix b/pkgs/by-name/zi/zitadel/console.nix
new file mode 100644
index 0000000000000..f2e1f26f3b879
--- /dev/null
+++ b/pkgs/by-name/zi/zitadel/console.nix
@@ -0,0 +1,51 @@
+{ generateProtobufCode
+, version
+, zitadelRepo
+}:
+
+{ mkYarnPackage
+, fetchYarnDeps
+, lib
+}:
+
+let
+  protobufGenerated = generateProtobufCode {
+    pname = "zitadel-console";
+    workDir = "console";
+    bufArgs = "../proto --include-imports --include-wkt";
+    outputPath = "src/app/proto";
+    hash = "sha256-s0dzmcjKd8ot7t+KlRlNVA9oiIDKVMnGOT/HjdaUjGI=";
+  };
+in
+mkYarnPackage rec {
+  name = "zitadel-console";
+  inherit version;
+
+  src = "${zitadelRepo}/console";
+
+  packageJSON = ./package.json;
+  offlineCache = fetchYarnDeps {
+    yarnLock = "${src}/yarn.lock";
+    hash = "sha256-48IC4LxqbkH+95k7rCmhRWT+qAlJ9CDXWwRjbric9no=";
+  };
+
+  postPatch = ''
+    substituteInPlace src/styles.scss \
+      --replace "/node_modules/flag-icons" "flag-icons"
+
+    substituteInPlace angular.json \
+      --replace "./node_modules/tinycolor2" "../../node_modules/tinycolor2"
+  '';
+
+  buildPhase = ''
+    mkdir deps/console/src/app/proto
+    cp -r ${protobufGenerated}/* deps/console/src/app/proto/
+    yarn --offline build
+  '';
+
+  installPhase = ''
+    cp -r deps/console/dist/console $out
+  '';
+
+  doDist = false;
+}
diff --git a/pkgs/by-name/zi/zitadel/package.json b/pkgs/by-name/zi/zitadel/package.json
new file mode 100644
index 0000000000000..0add6d2556b18
--- /dev/null
+++ b/pkgs/by-name/zi/zitadel/package.json
@@ -0,0 +1,88 @@
+{
+  "name": "console",
+  "version": "0.0.0",
+  "scripts": {
+    "ng": "ng",
+    "start": "node prebuild.development.js && ng serve",
+    "build": "ng build --configuration production --base-href=/ui/console/",
+    "prelint": "npm run generate",
+    "lint": "ng lint && prettier --check src",
+    "lint:fix": "prettier --write src",
+    "generate": "buf generate ../proto --include-imports --include-wkt"
+  },
+  "private": true,
+  "dependencies": {
+    "@angular/animations": "^16.2.0",
+    "@angular/cdk": "^16.2.0",
+    "@angular/common": "^16.2.0",
+    "@angular/compiler": "^16.2.0",
+    "@angular/core": "^16.2.0",
+    "@angular/forms": "^16.2.0",
+    "@angular/material": "^16.2.0",
+    "@angular/material-moment-adapter": "^16.2.0",
+    "@angular/platform-browser": "^16.2.0",
+    "@angular/platform-browser-dynamic": "^16.2.0",
+    "@angular/router": "^16.2.0",
+    "@angular/service-worker": "^16.2.0",
+    "@ctrl/ngx-codemirror": "^6.1.0",
+    "@grpc/grpc-js": "^1.8.14",
+    "@ngx-translate/core": "^14.0.0",
+    "angular-oauth2-oidc": "^15.0.1",
+    "angularx-qrcode": "^16.0.0",
+    "buffer": "^6.0.3",
+    "codemirror": "^5.65.8",
+    "cors": "^2.8.5",
+    "file-saver": "^2.0.5",
+    "flag-icons": "^6.7.0",
+    "google-proto-files": "^3.0.3",
+    "google-protobuf": "^3.21.2",
+    "grpc-web": "^1.4.1",
+    "i18n-iso-countries": "^7.6.0",
+    "libphonenumber-js": "^1.10.30",
+    "material-design-icons-iconfont": "^6.1.1",
+    "moment": "^2.29.4",
+    "opentype.js": "^1.3.4",
+    "ngx-color": "^9.0.0",
+    "rxjs": "~7.8.0",
+    "tinycolor2": "^1.6.0",
+    "tslib": "^2.4.1",
+    "uuid": "^9.0.0",
+    "zone.js": "~0.13.1"
+  },
+  "devDependencies": {
+    "@angular-devkit/build-angular": "^16.2.0",
+    "@angular-eslint/builder": "16.1.0",
+    "@angular-eslint/eslint-plugin": "16.1.0",
+    "@angular-eslint/eslint-plugin-template": "16.1.0",
+    "@angular-eslint/schematics": "16.1.0",
+    "@angular-eslint/template-parser": "16.1.0",
+    "@angular/cli": "^16.2.0",
+    "@angular/compiler-cli": "^16.2.0",
+    "@angular/language-service": "^16.2.0",
+    "@bufbuild/buf": "^1.23.1",
+    "@types/file-saver": "^2.0.2",
+    "@types/google-protobuf": "^3.15.3",
+    "@types/jasmine": "~4.3.3",
+    "@types/jasminewd2": "~2.0.10",
+    "@types/jsonwebtoken": "^9.0.1",
+    "@types/node": "^18.15.11",
+    "@types/opentype.js": "^1.3.4",
+    "@types/qrcode": "^1.5.0",
+    "@types/uuid": "^9.0.2",
+    "@typescript-eslint/eslint-plugin": "^5.59.11",
+    "@typescript-eslint/parser": "^5.60.1",
+    "codelyzer": "^6.0.2",
+    "eslint": "^8.44.0",
+    "jasmine-core": "~4.6.0",
+    "jasmine-spec-reporter": "~7.0.0",
+    "karma": "^6.4.2",
+    "karma-chrome-launcher": "^3.2.0",
+    "karma-coverage-istanbul-reporter": "^3.0.3",
+    "karma-jasmine": "^5.1.0",
+    "karma-jasmine-html-reporter": "^2.1.0",
+    "prettier": "^2.8.7",
+    "prettier-plugin-organize-imports": "^3.2.2",
+    "protractor": "~7.0.0",
+    "typescript": "^4.9.5"
+  }
+}
diff --git a/pkgs/by-name/zi/zitadel/package.nix b/pkgs/by-name/zi/zitadel/package.nix
new file mode 100644
index 0000000000000..cd4780965e138
--- /dev/null
+++ b/pkgs/by-name/zi/zitadel/package.nix
@@ -0,0 +1,150 @@
+{ stdenv
+, buildGo121Module
+, callPackage
+, fetchFromGitHub
+, lib
+
+, buf
+, cacert
+, grpc-gateway
+, protoc-gen-go
+, protoc-gen-go-grpc
+, protoc-gen-validate
+, sass
+, statik
+}:
+
+let
+  version = "2.37.2";
+  zitadelRepo = fetchFromGitHub {
+    owner = "zitadel";
+    repo = "zitadel";
+    rev = "v${version}";
+    hash = "sha256-iWEL7R7eNDV4c1CZhmxxiHHI9ExwU6gnmHI6ildaXWY=";
+  };
+  goModulesHash = "sha256-lk4jEiI85EKk0G4JCHvCazqBBTfiNJqSfzvrJgDZ1Nc=";
+
+  buildZitadelProtocGen = name:
+    buildGo121Module {
+      pname = "protoc-gen-${name}";
+      inherit version;
+
+      src = zitadelRepo;
+
+      proxyVendor = true;
+      vendorHash = goModulesHash;
+
+      buildPhase = ''
+        go install internal/protoc/protoc-gen-${name}/main.go
+      '';
+
+      postInstall = ''
+        mv $out/bin/main $out/bin/protoc-gen-${name}
+      '';
+    };
+
+  protoc-gen-authoption = buildZitadelProtocGen "authoption";
+  protoc-gen-zitadel = buildZitadelProtocGen "zitadel";
+
+  # Buf downloads dependencies from an external repo - there doesn't seem to
+  # really be any good way around it. We'll use a fixed-output derivation so it
+  # can download what it needs, and output the relevant generated code for use
+  # during the main build.
+  generateProtobufCode =
+    { pname
+    , nativeBuildInputs ? [ ]
+    , bufArgs ? ""
+    , workDir ? "."
+    , outputPath
+    , hash
+    }:
+    stdenv.mkDerivation {
+      name = "${pname}-buf-generated";
+
+      src = zitadelRepo;
+
+      nativeBuildInputs = nativeBuildInputs ++ [ buf ];
+
+      buildPhase = ''
+        cd ${workDir}
+        export SSL_CERT_FILE="${cacert}/etc/ssl/certs/ca-bundle.crt"
+        HOME=$TMPDIR buf generate ${bufArgs}
+      '';
+
+      installPhase = ''
+        cp -r ${outputPath} $out
+      '';
+
+      outputHashMode = "recursive";
+      outputHashAlgo = "sha256";
+      outputHash = hash;
+    };
+
+  protobufGenerated = generateProtobufCode {
+    pname = "zitadel";
+    nativeBuildInputs = [
+      grpc-gateway
+      protoc-gen-authoption
+      protoc-gen-go
+      protoc-gen-go-grpc
+      protoc-gen-validate
+      protoc-gen-zitadel
+    ];
+    outputPath = ".artifacts";
+    hash = "sha256-+9UFBWBuSYNbfimKwJUSoiUh+8bDHGnPdx1MKDul1U4=";
+  };
+in
+buildGo121Module rec {
+  name = "zitadel";
+  inherit version;
+
+  src = zitadelRepo;
+
+  nativeBuildInputs = [ sass statik ];
+
+  proxyVendor = true;
+  vendorHash = goModulesHash;
+
+  # Adapted from Makefile in repo, with dependency fetching and protobuf codegen
+  # bits removed
+  buildPhase = ''
+    mkdir -p pkg/grpc
+    cp -r ${protobufGenerated}/grpc/github.com/zitadel/zitadel/pkg/grpc/* pkg/grpc
+    mkdir -p openapi/v2/zitadel
+    cp -r ${protobufGenerated}/grpc/zitadel/ openapi/v2/zitadel
+
+    go generate internal/api/ui/login/static/resources/generate.go
+    go generate internal/api/ui/login/statik/generate.go
+    go generate internal/notification/statik/generate.go
+    go generate internal/statik/generate.go
+
+    mkdir -p docs/apis/assets
+    go run internal/api/assets/generator/asset_generator.go -directory=internal/api/assets/generator/ -assets=docs/apis/assets/assets.md
+
+    cp -r ${passthru.console}/* internal/api/ui/console/static
+    CGO_ENABLED=0 go build -o zitadel -v -ldflags="-s -w -X 'github.com/zitadel/zitadel/cmd/build.version=${version}'"
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    install -Dm755 zitadel $out/bin/
+  '';
+
+  passthru = {
+    console = callPackage
+      (import ./console.nix {
+        inherit generateProtobufCode version zitadelRepo;
+      })
+      { };
+  };
+
+  meta = with lib; {
+    description = "Identity and access management platform";
+    homepage = "https://zitadel.com/";
+    downloadPage = "https://github.com/zitadel/zitadel/releases";
+    platforms = platforms.linux ++ platforms.darwin;
+    license = licenses.asl20;
+    sourceProvenance = [ sourceTypes.fromSource ];
+    maintainers = with maintainers; [ Sorixelle ];
+  };
+}