-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(monitoring): adding nix package and readme generator
Signed-off-by: Abhilash Shetty <abhilash.shetty@datacore.com>
- Loading branch information
1 parent
8ee3f91
commit d05a8eb
Showing
9 changed files
with
419 additions
and
133 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}" ]; }; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{}: | ||
self: super: { | ||
sourcer = super.callPackage ./lib/sourcer.nix { }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/<owner>/<repo>/archive/<rev>.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/<owner>/<repo>/archive/<rev>.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/<owner>/<repo>/archive/<rev>.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/<owner>/<repo>/archive/<rev>.tar.gz" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
# This file has been generated by Niv. | ||
let | ||
# | ||
# The fetchers. fetch_<type> fetches specs of type <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 <package> -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 <package> -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 = <nixpkgs> == ./.; | ||
in | ||
if builtins.hasAttr "nixpkgs" sources then | ||
sourcesNixpkgs | ||
else if hasNixpkgsPath && !hasThisAsNixpkgsPath then | ||
import <nixpkgs> { } | ||
else | ||
abort '' | ||
Please specify either <nixpkgs> (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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
]; | ||
} |