From d05a8ebd0bbd341abd501e7fcfb14a914bc43f5d Mon Sep 17 00:00:00 2001 From: Abhilash Shetty Date: Thu, 26 Sep 2024 09:34:57 +0000 Subject: [PATCH] chore(monitoring): adding nix package and readme generator Signed-off-by: Abhilash Shetty --- deploy/charts/README.md | 248 +++++++++++++++++-------------------- nix/README.md | 14 +++ nix/lib/rust.nix | 31 +++++ nix/lib/sourcer.nix | 24 ++++ nix/overlay.nix | 4 + nix/sources.json | 50 ++++++++ nix/sources.nix | 144 +++++++++++++++++++++ scripts/generate-readme.sh | 16 +++ scripts/shell.nix | 21 ++++ 9 files changed, 419 insertions(+), 133 deletions(-) create mode 100644 nix/README.md create mode 100644 nix/lib/rust.nix create mode 100644 nix/lib/sourcer.nix create mode 100644 nix/overlay.nix create mode 100644 nix/sources.json create mode 100644 nix/sources.nix create mode 100755 scripts/generate-readme.sh create mode 100644 scripts/shell.nix diff --git a/deploy/charts/README.md b/deploy/charts/README.md index 60f017d..59fbc88 100644 --- a/deploy/charts/README.md +++ b/deploy/charts/README.md @@ -1,133 +1,115 @@ -# OpenEBS Monitoring - -[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -![Chart Lint and Test](https://github.com/openebs/monitoring/workflows/Chart%20Lint%20and%20Test/badge.svg) -![Release Charts](https://github.com/openebs/monitoring/workflows/Release%20Charts/badge.svg?branch=develop) - -A Helm chart for OpenEBS monitoring. This chart bootstraps OpenEBS monitoring stack on a [Kubernetes](http://kubernetes.io) cluster using the -[Helm](https://helm.sh) package manager. - -**Homepage:** - -## Get Repo Info - -```console -helm repo add monitoring https://openebs.github.io/monitoring/ -helm repo update -``` - -_See [helm repo](https://helm.sh/docs/helm/helm_repo/) for command documentation._ - -## Install Chart - -Please visit the [link](https://openebs.github.io/monitoring/) for install instructions via helm3. - -```console -# Helm -helm install [RELEASE_NAME] monitoring/monitoring --namespace [NAMESPACE] --create-namespace -``` - -_See [configuration](#configuration) below._ - -_See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._ - -## Dependencies - -By default this chart installs additional, dependent charts: - -| Repository | Name | Version | -| ------------------------------------------------------------------------------------------ | --------------------- | -------- | -| https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack | kube-prometheus-stack | `58.0.*` | -| https://charts.deliveryhero.io/ | node-problem-detector | `2.0.*` | - -_See [helm dependency](https://helm.sh/docs/helm/helm_dependency/) for command documentation._ - -## Uninstall Chart - -```console -# Helm -helm uninstall [RELEASE_NAME] --namespace [NAMESPACE] -``` - -This removes all the Kubernetes components associated with the chart and deletes the release. - -_See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._ - -## Upgrading Chart - -```console -# Helm -helm upgrade [RELEASE_NAME] [CHART] --install --namespace [NAMESPACE] -``` - -## Configuration - -The following table lists the configurable parameters of the OpenEBS monitoring chart and their default values. - -You can modify different parameters by specifying the desired value in the `helm install` command by using the `--set` and/or the `--set-string` flag(s). You can modify the parameters of the [kube-prometheus-stack chart](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack) by adding `kube-prometheus-stack` before the desired parameter in the `helm install` command. - -In the following sample command we modify `openebsMonitoringAddon.lvmLocalPV.enabled` from the monitoring chart and `kube-prometheus-stack.kubeProxy.enabled` from the kube-prometheus-stack chart to disable monitoring for lvmLocalPV and kube-proxy. - -```console -helm install monitoring monitoring/monitoring --namespace openebs --create-namespace \ - --set openebsMonitoringAddon.lvmLocalPV.enabled=false \ - --set kube-prometheus-stack.kubeProxy.enabled=false -``` - -| Parameter | Description | Default | -| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | --------------------------------------------------------- | -| `kube-prometheus-stack.global.rbac.pspEnabled` | Disable PSP for alertmanager, prometheus and prometheus-operator | `false` | -| `kube-prometheus-stack.kube-state-metrics.podSecurityPolicy.enabled` | Disable PSP for kube-state-metrics | `false` | -| `kube-prometheus-stack.prometheus.service.type` | Service type for Prometheus | `"NodePort"` | -| `kube-prometheus-stack.prometheus.service.nodePort` | NodePort value for Prometheus service | `32514` | -| `kube-prometheus-stack.prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues` | Enables Prometheus to select every service monitors | `false` | -| `kube-prometheus-stack.prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues` | Enables Prometheus to select every pod monitors | `false` | -| `kube-prometheus-stack.prometheus.prometheusSpec.ruleSelectorNilUsesHelmValues` | Enables Prometheus to select every Prometheus rules | `false` | -| `kube-prometheus-stack.prometheus.prometheusSpec.replicas` | Number of instances to deploy for a Prometheus deployment | `1` | -| `kube-prometheus-stack.prometheus.prometheusSpec.storageSpec` | Storage spec to specify how storage shall be used. | `{}` | -| `kube-prometheus-stack.prometheus-node-exporter.rbac.pspEnabled` | Disable PSP for node-exporter | `false` | -| `kube-prometheus-stack.prometheus-node-exporter.securityContext` | Privilege and access control settings for node-exporter | `{...}` | -| `kube-prometheus-stack.prometheus-node-exporter.extraArgs` | Additional container arguments | `[...]` | -| `kube-prometheus-stack.alertmanager.enabled` | Deploy Alertmanager | `true` | -| `kube-prometheus-stack.alertmanager.config` | Provide YAML to configure Alertmanager. | `{...}` | -| `kube-prometheus-stack.alertmanager.service.type` | Service type for Alertmanager | `"NodePort"` | -| `kube-prometheus-stack.alertmanager.service.nodePort` | NodePort value for Alertmanager service | `30903` | -| `kube-prometheus-stack.alertmanager.alertmanagerSpec.replicas` | Number of instances to deploy for a Alertmanager deployment | `1` | -| `kube-prometheus-stack.alertmanager.alertmanagerSpec.storage` | Storage is the definition of how storage will be used by the Alertmanager instances | `{}` | -| `kube-prometheus-stack.prometheusOperator.enabled` | Deploy Prometheus Operator | `true` | -| `kube-prometheus-stack.grafana.enabled` | Enables monitoring of grafana itself | `true` | -| `kube-prometheus-stack.grafana.rbac.pspEnabled` | Disable PSP for grafana | `false` | -| `kube-prometheus-stack.grafana.grafana.ini` | Append to Grafana's primary configuration | `{panels: {disable_sanitize_html: true}}` | -| `kube-prometheus-stack.grafana.service.type` | Service type for Grafana | `"NodePort"` | -| `kube-prometheus-stack.grafana.service.nodePort` | NodePort value for Grafana service | `32515` | -| `kube-prometheus-stack.grafana.defaultDashboardsEnabled` | Deploys default dashboards | `true` | -| `kube-prometheus-stack.grafana.openebsDashboardsEnabled` | Deploys custom OpenEBS dashboards | `true` | -| `kube-prometheus-stack.grafana.adminPassword` | Administrator password for Grafana | `"admin"` | -| `kube-prometheus-stack.grafana.sidecar.dashboards.enabled` | Allows Grafana sidecar container to provision dashboards | `true` | -| `kube-prometheus-stack.grafana.sidecar.dashboards.label` | Labels for configmaps to be collected by Grafana sidecars | `"grafana_dashboard"` | -| `kube-prometheus-stack.grafana.plugins` | Adds Grafana plugin list to be installed | `["grafana-polystat-panel","snuids-trafficlights-panel"]` | -| `openebsMonitoringAddon.lvmLocalPV.enabled` | Enables installation of monitoring addons for lvm-LocalPV | `true` | -| `openebsMonitoringAddon.lvmLocalPV.dashboards.enabled` | Enables dashboard installation of OpenEBS lvm-localpv storage engine | `true` | -| `openebsMonitoringAddon.npd.dashboards.enabled` | Enables dashboard installation related to node problems | `true` | -| `node-problem-detector.extraVolumes` | Volumes needed by node problem detector | `[...]` | -| `node-problem-detector.extraVolumeMounts` | Volumes mounts needed by node problem detector | `[...]` | -| `node-problem-detector.metrics.serviceMonitor.enabled` | Enables node problem detector monitoring | `true` | -| `openebsMonitoringAddon.lvmLocalPV.alertRules.enabled` | Enables OpenEBS lvm-localpv Storage engine rules | `true` | -| `openebsMonitoringAddon.volume.alertRules.enabled` | Enables persistent volume rules | `true` | -| `openebsMonitoringAddon.lvmLocalPV.serviceMonitor.enabled` | Enables monitoring of lvm localPV | `true` | -| `openebsMonitoringAddon.lvmLocalPV.serviceMonitor.endpoints.port` | Name of the service port lvm localPV node endpoint refers to | `"metrics"` | -| `openebsMonitoringAddon.lvmLocalPV.serviceMonitor.endpoints.path` | HTTP path to scrape for metrics from lvm localPV node | `"/metrics"` | -| `openebsMonitoringAddon.lvmLocalPV.serviceMonitor.selector` | Selector to select endpoints objects | `{matchLabels: {name: openebs-lvm-node}}` | -| `openebsMonitoringAddon.lvmLocalPV.serviceMonitor.namespaceSelector` | Selector to select which namespaces the endpoints objects are discovered from | `[any: true]` | -| `openebsMonitoringAddon.zfsLocalPV.enabled` | Enables installation of monitoring addons for zfs LocalPV | `true` | -| `openebsMonitoringAddon.zfsLocalPV.dashboards.enabled` | Enables dashboard installation of OpenEBS zfs localPV Storage engine | `true` | - -We can edit the npd parameters too accordingly from [here](https://artifacthub.io/packages/helm/deliveryhero/node-problem-detector) - -A YAML file that specifies the values for the parameters can be provided while installing the chart. For example, - -```bash -helm install -f values.yaml --namespace monitoring monitoring/monitoring -``` - -> **Tip**: You can use the default [values.yaml](values.yaml) +# monitoring + +![Version: 4.0.1](https://img.shields.io/badge/Version-4.0.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 4.0.1](https://img.shields.io/badge/AppVersion-4.0.1-informational?style=flat-square) + +A Helm chart for monitoring OpenEBS + +## Source Code + +* + +## Requirements + +| Repository | Name | Version | +|------------|------|---------| +| https://charts.deliveryhero.io/ | node-problem-detector | 2.0.* | +| https://openebs.github.io/dynamic-localpv-provisioner | localpv-provisioner | 4.1.0 | +| https://prometheus-community.github.io/helm-charts | kube-prometheus-stack | 61.0.* | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| fullnameOverride | string | `""` | | +| kube-prometheus-stack.alertmanager.alertmanagerSpec.replicas | int | `1` | | +| kube-prometheus-stack.alertmanager.alertmanagerSpec.storage | object | `{}` | | +| kube-prometheus-stack.alertmanager.config.global.resolve_timeout | string | `"5m"` | | +| kube-prometheus-stack.alertmanager.config.receivers[0].name | string | `"null"` | | +| kube-prometheus-stack.alertmanager.config.route.group_by[0] | string | `"alertname"` | | +| kube-prometheus-stack.alertmanager.config.route.group_by[1] | string | `"job"` | | +| kube-prometheus-stack.alertmanager.config.route.group_by[2] | string | `"volName"` | | +| kube-prometheus-stack.alertmanager.config.route.group_interval | string | `"5m"` | | +| kube-prometheus-stack.alertmanager.config.route.group_wait | string | `"30s"` | | +| kube-prometheus-stack.alertmanager.config.route.receiver | string | `"null"` | | +| kube-prometheus-stack.alertmanager.config.route.repeat_interval | string | `"4h"` | | +| kube-prometheus-stack.alertmanager.config.route.routes[0].matchers[0] | string | `"product=\"openebs\""` | | +| kube-prometheus-stack.alertmanager.config.route.routes[0].receiver | string | `"null"` | | +| kube-prometheus-stack.alertmanager.config.templates[0] | string | `"/etc/alertmanager/config/*.tmpl"` | | +| kube-prometheus-stack.alertmanager.enabled | bool | `true` | | +| kube-prometheus-stack.alertmanager.service.nodePort | int | `30903` | | +| kube-prometheus-stack.alertmanager.service.type | string | `"NodePort"` | | +| kube-prometheus-stack.global.rbac.pspEnabled | bool | `false` | | +| kube-prometheus-stack.grafana."grafana.ini".panels.disable_sanitize_html | bool | `true` | | +| kube-prometheus-stack.grafana.adminPassword | string | `"admin"` | | +| kube-prometheus-stack.grafana.defaultDashboardsEnabled | bool | `true` | | +| kube-prometheus-stack.grafana.enabled | bool | `true` | | +| kube-prometheus-stack.grafana.persistence.accessModes[0] | string | `"ReadWriteOnce"` | | +| kube-prometheus-stack.grafana.persistence.enabled | bool | `true` | | +| kube-prometheus-stack.grafana.persistence.size | string | `"1Gi"` | | +| kube-prometheus-stack.grafana.persistence.storageClassName | string | `"openebs-hostpath"` | | +| kube-prometheus-stack.grafana.plugins[0] | string | `"grafana-polystat-panel"` | | +| kube-prometheus-stack.grafana.plugins[1] | string | `"snuids-trafficlights-panel"` | | +| kube-prometheus-stack.grafana.rbac.pspEnabled | bool | `false` | | +| kube-prometheus-stack.grafana.service.nodePort | int | `32515` | | +| kube-prometheus-stack.grafana.service.type | string | `"NodePort"` | | +| kube-prometheus-stack.grafana.sidecar.dashboards.enabled | bool | `true` | | +| kube-prometheus-stack.grafana.sidecar.dashboards.label | string | `"grafana_dashboard"` | | +| kube-prometheus-stack.install | bool | `true` | | +| kube-prometheus-stack.kube-state-metrics.podSecurityPolicy.enabled | bool | `false` | | +| kube-prometheus-stack.prometheus-node-exporter.extraArgs[0] | string | `"--collector.filesystem.mount-points-exclude=^/(dev|proc|sys|var/lib/docker/.+)($|/)"` | | +| kube-prometheus-stack.prometheus-node-exporter.extraArgs[1] | string | `"--collector.filesystem.fs-types-exclude=^(tmpfs|autofs|binfmt_misc|cgroup|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|mqueue|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|sysfs|tracefs)$"` | | +| kube-prometheus-stack.prometheus-node-exporter.extraArgs[2] | string | `"--collector.diskstats.device-exclude=^(ram|loop|fd|sr|(h|s|v|xv)d[a-z]+|nvme\\d+n\\d+p|nvme\\d+c\\d+n)\\d+$"` | | +| kube-prometheus-stack.prometheus-node-exporter.rbac.pspEnabled | bool | `false` | | +| kube-prometheus-stack.prometheus-node-exporter.securityContext.fsGroup | int | `65534` | | +| kube-prometheus-stack.prometheus-node-exporter.securityContext.runAsGroup | int | `0` | | +| kube-prometheus-stack.prometheus-node-exporter.securityContext.runAsNonRoot | bool | `false` | | +| kube-prometheus-stack.prometheus-node-exporter.securityContext.runAsUser | int | `0` | | +| kube-prometheus-stack.prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues | bool | `false` | | +| kube-prometheus-stack.prometheus.prometheusSpec.replicas | int | `1` | | +| kube-prometheus-stack.prometheus.prometheusSpec.ruleSelectorNilUsesHelmValues | bool | `false` | | +| kube-prometheus-stack.prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues | bool | `false` | | +| kube-prometheus-stack.prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.metadata.name | string | `"openebs-prometheus-pv"` | | +| kube-prometheus-stack.prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.spec.accessModes[0] | string | `"ReadWriteOnce"` | | +| kube-prometheus-stack.prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.spec.resources.requests.storage | string | `"1Gi"` | | +| kube-prometheus-stack.prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.spec.storageClassName | string | `"openebs-hostpath"` | | +| kube-prometheus-stack.prometheus.service.nodePort | int | `32514` | | +| kube-prometheus-stack.prometheus.service.type | string | `"NodePort"` | | +| kube-prometheus-stack.prometheusOperator.enabled | bool | `true` | | +| localpv-provisioner.analytics.enabled | bool | `true` | | +| localpv-provisioner.enabled | bool | `true` | | +| localpv-provisioner.hostpathClass.enabled | bool | `true` | Enable default hostpath localpv StorageClass. | +| localpv-provisioner.hostpathClass.name | string | `"openebs-hostpath"` | | +| nameOverride | string | `""` | | +| namespaceOverride | string | `""` | | +| node-problem-detector.extraVolumeMounts[0].mountPath | string | `"/dev/kmsg"` | | +| node-problem-detector.extraVolumeMounts[0].name | string | `"kmsg"` | | +| node-problem-detector.extraVolumeMounts[0].readOnly | bool | `true` | | +| node-problem-detector.extraVolumes[0].hostPath.path | string | `"/dev/kmsg"` | | +| node-problem-detector.extraVolumes[0].name | string | `"kmsg"` | | +| node-problem-detector.install | bool | `false` | | +| node-problem-detector.metrics.serviceMonitor.enabled | bool | `true` | | +| openebsMonitoringAddon.lvmLocalPV.alertRules.enabled | bool | `true` | | +| openebsMonitoringAddon.lvmLocalPV.dashboards.enabled | bool | `true` | | +| openebsMonitoringAddon.lvmLocalPV.enabled | bool | `true` | | +| openebsMonitoringAddon.lvmLocalPV.serviceMonitor.enabled | bool | `true` | | +| openebsMonitoringAddon.lvmLocalPV.serviceMonitor.endpoints.path | string | `"/metrics"` | | +| openebsMonitoringAddon.lvmLocalPV.serviceMonitor.endpoints.port | string | `"metrics"` | | +| openebsMonitoringAddon.lvmLocalPV.serviceMonitor.namespaceSelector.any | bool | `true` | | +| openebsMonitoringAddon.lvmLocalPV.serviceMonitor.selector.matchLabels.name | string | `"openebs-lvm-node"` | | +| openebsMonitoringAddon.mayastor.dashboards.enabled | bool | `true` | | +| openebsMonitoringAddon.mayastor.enabled | bool | `true` | | +| openebsMonitoringAddon.mayastor.serviceMonitor.enabled | bool | `true` | | +| openebsMonitoringAddon.mayastor.serviceMonitor.endpoints.path | string | `"/metrics"` | | +| openebsMonitoringAddon.mayastor.serviceMonitor.endpoints.port | string | `"metrics"` | | +| openebsMonitoringAddon.mayastor.serviceMonitor.namespaceSelector.any | bool | `true` | | +| openebsMonitoringAddon.mayastor.serviceMonitor.selector.matchLabels.app | string | `"metrics-exporter-io-engine"` | | +| openebsMonitoringAddon.npd.alertRules.enabled | bool | `false` | | +| openebsMonitoringAddon.npd.dashboards.enabled | bool | `false` | | +| openebsMonitoringAddon.npd.enabled | bool | `false` | | +| openebsMonitoringAddon.volume.alertRules.enabled | bool | `true` | | +| openebsMonitoringAddon.volume.enabled | bool | `true` | | +| openebsMonitoringAddon.zfsLocalPV.dashboards.enabled | bool | `true` | | +| openebsMonitoringAddon.zfsLocalPV.enabled | bool | `true` | | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs vv1.11.0](https://github.com/norwoodj/helm-docs/releases/vv1.11.0) diff --git a/nix/README.md b/nix/README.md new file mode 100644 index 0000000..16c309e --- /dev/null +++ b/nix/README.md @@ -0,0 +1,14 @@ +## Overview + +These are a collection of packages we need, or packages where we +want to control the exact version(s) of. + +The packages are imported through the `nix-shell` automatically. + +## nix-shell + +Build environment including all test and debug dependencies. +It can be run with two arguments: + +* `--arg norust true`: to use your own rust toolchain. +* `--arg devrustup true`: to use rustup. diff --git a/nix/lib/rust.nix b/nix/lib/rust.nix new file mode 100644 index 0000000..53bc49f --- /dev/null +++ b/nix/lib/rust.nix @@ -0,0 +1,31 @@ +{ sources ? import ../sources.nix }: +let + pkgs = + import sources.nixpkgs { overlays = [ (import sources.rust-overlay) ]; }; + makeRustTarget = platform: pkgs.rust.toRustTargetSpec platform; + static_target = makeRustTarget pkgs.pkgsStatic.stdenv.hostPlatform; +in +rec { + inherit makeRustTarget; + rust_default = { override ? { } }: rec { + nightly_pkg = pkgs.rust-bin.nightly."2023-10-05"; + stable_pkg = pkgs.rust-bin.stable."1.72.1"; + + nightly = nightly_pkg.default.override (override); + stable = stable_pkg.default.override (override); + + nightly_src = nightly_pkg.rust-src; + release_src = stable_pkg.rust-src; + }; + default = rust_default { }; + default_src = rust_default { + override = { extensions = [ "rust-src" ]; }; + }; + static = { target ? makeRustTarget pkgs.pkgsStatic.stdenv.hostPlatform }: rust_default { + override = { targets = [ "${target}" ]; }; + }; + hostStatic = rust_default { override = { targets = [ "${makeRustTarget pkgs.pkgsStatic.stdenv.hostPlatform}" ]; }; }; + windows_cross = rust_default { + override = { targets = [ "${pkgs.rust.toRustTargetSpec pkgs.pkgsCross.mingwW64.hostPlatform}" ]; }; + }; +} diff --git a/nix/lib/sourcer.nix b/nix/lib/sourcer.nix new file mode 100644 index 0000000..d3d80d5 --- /dev/null +++ b/nix/lib/sourcer.nix @@ -0,0 +1,24 @@ +{ lib, stdenv, git, sourcer, tag ? "" }: +let + whitelistSource = src: allowedPrefixes: + builtins.path { + filter = (path: type: + (lib.any + (allowedPrefix: + (lib.hasPrefix (toString (src + "/${allowedPrefix}")) path) || + (type == "directory" && lib.hasPrefix path (toString (src + "/${allowedPrefix}"))) + ) + allowedPrefixes) + ## Remove unwanted files, example: + # && path != (toString (src + "/utils/dependencies/scripts/release.sh")) + ); + path = src; + name = "puls8"; + }; +in +{ + inherit whitelistSource; + + git-src = whitelistSource ../../. [ ".git" ]; + repo-org = whitelistSource ../../mayastor-extensions/dependencies/control-plane/utils/dependencies/scripts [ "git-org-name.sh" ]; +} diff --git a/nix/overlay.nix b/nix/overlay.nix new file mode 100644 index 0000000..0ed5810 --- /dev/null +++ b/nix/overlay.nix @@ -0,0 +1,4 @@ +{}: +self: super: { + sourcer = super.callPackage ./lib/sourcer.nix { }; +} diff --git a/nix/sources.json b/nix/sources.json new file mode 100644 index 0000000..d0c3385 --- /dev/null +++ b/nix/sources.json @@ -0,0 +1,50 @@ +{ + "naersk": { + "branch": "master", + "description": "Build rust crates in Nix. No configuration, no code generation, no IFD. Sandbox friendly. [maintainer: @nmattia]", + "homepage": "", + "owner": "nix-community", + "repo": "naersk", + "rev": "d9a33d69a9c421d64c8d925428864e93be895dcc", + "sha256": "1lhz5haibfnbxwir61mhymxfqfgs2q1nb4rk88va8bpv6j2zlpbv", + "type": "tarball", + "url": "https://github.com/nix-community/naersk/archive/d9a33d69a9c421d64c8d925428864e93be895dcc.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "niv": { + "branch": "master", + "description": "Easy dependency management for Nix projects", + "homepage": "https://github.com/nmattia/niv", + "owner": "nmattia", + "repo": "niv", + "rev": "914aba08a26cb10538b84d00d6cfb01c9776d80c", + "sha256": "0gx316gc7prjay5b0cr13x4zc2pdbiwxkfkpjvrlb2rml80lm4pm", + "type": "tarball", + "url": "https://github.com/nmattia/niv/archive/914aba08a26cb10538b84d00d6cfb01c9776d80c.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "nixpkgs": { + "branch": "release-22.11", + "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", + "homepage": "https://github.com/NixOS/nixpkgs", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", + "sha256": "1xi53rlslcprybsvrmipm69ypd3g3hr7wkxvzc73ag8296yclyll", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "rust-overlay": { + "branch": "master", + "description": "Pure and reproducible nix overlay for binary distributed rust toolchains", + "homepage": "", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "c0df7f2a856b5ff27a3ce314f6d7aacf5fda546f", + "sha256": "0hm2yznc083bys92h6zrx5lsar5nqphx1h27p7pxz4x7hmilxpsy", + "type": "tarball", + "url": "https://github.com/oxalica/rust-overlay/archive/c0df7f2a856b5ff27a3ce314f6d7aacf5fda546f.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + } +} diff --git a/nix/sources.nix b/nix/sources.nix new file mode 100644 index 0000000..8f50fc8 --- /dev/null +++ b/nix/sources.nix @@ -0,0 +1,144 @@ +# This file has been generated by Niv. +let + # + # The fetchers. fetch_ fetches specs of type . + # + + fetch_file = pkgs: spec: + if spec.builtin or true then + builtins_fetchurl { inherit (spec) url sha256; } + else + pkgs.fetchurl { inherit (spec) url sha256; }; + + fetch_tarball = pkgs: spec: + if spec.builtin or true then + builtins_fetchTarball { inherit (spec) url sha256; } + else + pkgs.fetchzip { inherit (spec) url sha256; }; + + fetch_git = spec: + builtins.fetchGit { + url = spec.repo; + inherit (spec) rev ref; + }; + + fetch_builtin-tarball = spec: + builtins.trace '' + WARNING: + The niv type "builtin-tarball" will soon be deprecated. You should + instead use `builtin = true`. + + $ niv modify -a type=tarball -a builtin=true + '' + builtins_fetchTarball + { inherit (spec) url sha256; }; + + fetch_builtin-url = spec: + builtins.trace '' + WARNING: + The niv type "builtin-url" will soon be deprecated. You should + instead use `builtin = true`. + + $ niv modify -a type=file -a builtin=true + '' + (builtins_fetchurl { inherit (spec) url sha256; }); + + # + # Various helpers + # + + # The set of packages used when specs are fetched using non-builtins. + mkPkgs = sources: + let + sourcesNixpkgs = + import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) + { }; + hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; + hasThisAsNixpkgsPath = == ./.; + in + if builtins.hasAttr "nixpkgs" sources then + sourcesNixpkgs + else if hasNixpkgsPath && !hasThisAsNixpkgsPath then + import { } + else + abort '' + Please specify either (through -I or NIX_PATH=nixpkgs=...) or + add a package called "nixpkgs" to your sources.json. + ''; + + # The actual fetching function. + fetch = pkgs: name: spec: + + if !builtins.hasAttr "type" spec then + abort "ERROR: niv spec ${name} does not have a 'type' attribute" + else if spec.type == "file" then + fetch_file pkgs spec + else if spec.type == "tarball" then + fetch_tarball pkgs spec + else if spec.type == "git" then + fetch_git spec + else if spec.type == "builtin-tarball" then + fetch_builtin-tarball spec + else if spec.type == "builtin-url" then + fetch_builtin-url spec + else + abort + "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; + + # Ports of functions for older nix versions + + # a Nix version of mapAttrs if the built-in doesn't exist + mapAttrs = builtins.mapAttrs or (f: set: + with builtins; + listToAttrs (map + (attr: { + name = attr; + value = f attr set.${attr}; + }) + (attrNames set))); + + # fetchTarball version that is compatible between all the versions of Nix + builtins_fetchTarball = { url, sha256 }@attrs: + let inherit (builtins) lessThan nixVersion fetchTarball; + in + if lessThan nixVersion "1.12" then + fetchTarball { inherit url; } + else + fetchTarball attrs; + + # fetchurl version that is compatible between all the versions of Nix + builtins_fetchurl = { url, sha256 }@attrs: + let inherit (builtins) lessThan nixVersion fetchurl; + in + if lessThan nixVersion "1.12" then + fetchurl { inherit url; } + else + fetchurl attrs; + + # Create the final "sources" from the config + mkSources = config: + mapAttrs + (name: spec: + if builtins.hasAttr "outPath" spec then + abort + "The values in sources.json should not have an 'outPath' attribute" + else + spec // { outPath = fetch config.pkgs name spec; }) + config.sources; + + # The "config" used by the fetchers + mkConfig = + { sourcesFile ? ./sources.json + , sources ? builtins.fromJSON (builtins.readFile sourcesFile) + , pkgs ? mkPkgs sources + }: rec { + # The sources, i.e. the attribute set of spec name to spec + inherit sources; + + # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers + inherit pkgs; + }; +in +mkSources (mkConfig { }) // { + __functor = _: settings: mkSources (mkConfig settings); +} diff --git a/scripts/generate-readme.sh b/scripts/generate-readme.sh new file mode 100755 index 0000000..65cbb43 --- /dev/null +++ b/scripts/generate-readme.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +SCRIPTDIR=$(dirname "$0") +ROOTDIR="$(realpath $SCRIPTDIR/..)" +CHART_DIR="$ROOTDIR/deploy/charts" +README="README.md" +SKIP_GIT=${SKIP_GIT:-} + +set -euo pipefail + +helm-docs -c "$ROOTDIR" -g "$CHART_DIR" -o $README + + +if [ -z "$SKIP_GIT" ]; then + git diff --exit-code "$CHART_DIR/$README" +fi diff --git a/scripts/shell.nix b/scripts/shell.nix new file mode 100644 index 0000000..bc228e1 --- /dev/null +++ b/scripts/shell.nix @@ -0,0 +1,21 @@ +{}: +let + sources = import ../nix/sources.nix; + pkgs = import sources.nixpkgs { + overlays = [ (_: _: { inherit sources; }) (import ../nix/overlay.nix { }) ]; + }; +in +with pkgs; +let +in +mkShell { + name = "helm-scripts-shell"; + buildInputs = [ + coreutils + git + helm-docs + kubernetes-helm-wrapped + semver-tool + yq-go + ]; +}