nix/: Exile remote nix scripts into nix/scripts.nix, update deps
Change-Id: I51ae917fb1e57375a84224f1da3d5df7b173e5bf
This commit is contained in:
parent
5e7e4d4e48
commit
a341c2a5b5
|
@ -0,0 +1,70 @@
|
|||
# An overlay for custom scripts
|
||||
final: prev: {
|
||||
# Run a local docker-based minikube cluster. minikube config controlled with $MINIKUBE_ARGS
|
||||
# Minimum requirements:
|
||||
# * User can use Docker
|
||||
# * Docker supports BuildKit
|
||||
whcluster = final.writeShellScriptBin "whcluster" ''
|
||||
set -e
|
||||
default_minikube_args="--cpus=10 --memory=10gb --disk-size=200gb"
|
||||
export MINIKUBE_ARGS=''${MINIKUBE_ARGS:-$default_minikube_args}
|
||||
${final.minikube}/bin/minikube start $MINIKUBE_ARGS
|
||||
${final.whinotify}/bin/whinotify
|
||||
${final.whkube}/bin/whkube
|
||||
'';
|
||||
|
||||
# Change current kubectl context to the wormhole namespace
|
||||
whkube = final.writeShellScriptBin "whkube" ''${final.kubectl}/bin/kubectl config set-context --current --namespace=wormhole'';
|
||||
|
||||
# Run tilt on the local cluster. Takes guardian count as argument.
|
||||
whtilt = final.writeShellScriptBin "whtilt" ''
|
||||
n_guardians=''${1:-5}
|
||||
echo "Starting Tilt with $n_guardians guardians"
|
||||
${final.killall}/bin/killall tilt
|
||||
${final.tilt}/bin/tilt up --update-mode exec -- --num=$n_guardians
|
||||
'';
|
||||
|
||||
# increase sysctl value for inotify watch count to sufficient level
|
||||
whinotify = final.writeShellScriptBin "whinotify" ''
|
||||
${final.minikube}/bin/minikube ssh 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p'
|
||||
'';
|
||||
|
||||
# one-stop-shop for setting up a cluster on a remote machine and
|
||||
# running tilt on it. MINIKUBE_ARGS defaults expect the remote to be
|
||||
# beefy.
|
||||
#
|
||||
# Usage: whremote <remote-machine>
|
||||
#
|
||||
# Minimum remote machine requirements:
|
||||
# * Can run whcluster (see above)
|
||||
# * Remote user has a working nix installation (single/multi user)
|
||||
#
|
||||
# Remote machine nice-to-haves:
|
||||
# * You have passwordless/cached session access to the remote -
|
||||
# * The remote is more powerful than your local machine. If not, use whcluster + whtilt locally instead.
|
||||
whremote = final.writeShellScriptBin "whremote" ''
|
||||
set -x
|
||||
set -e
|
||||
remote_machine=$1
|
||||
|
||||
# Use Mutagen to watch local repo and sync it with remote_machine's ~/wormhole
|
||||
${final.mutagen}/bin/mutagen sync terminate whremote-sync || true
|
||||
${final.mutagen}/bin/mutagen sync create -n whremote-sync . $remote_machine:~/wormhole
|
||||
${final.mutagen}/bin/mutagen sync flush whremote-sync
|
||||
|
||||
# Use larger cpu-count and memory values on the remote
|
||||
export MINIKUBE_ARGS=''${MINIKUBE_ARGS:='--cpus=30 --memory=110g --disk-size=1000gb'}
|
||||
|
||||
# Set up/update the remote minikube cluster with whcluster
|
||||
ssh $remote_machine \
|
||||
". ~/.bash_profile; . ~/.zprofile; . ~/.profile; \
|
||||
cd wormhole && \
|
||||
nix-shell --option sandbox false --command ' MINIKUBE_ARGS=\"$MINIKUBE_ARGS\" whcluster'"
|
||||
|
||||
# Run tilt using whtilt on the remote and forward its default port to localhost
|
||||
ssh -L 10350:127.0.0.1:10350 $remote_machine \
|
||||
". ~/.bash_profile; . ~/.zprofile; . ~/.profile; \
|
||||
cd wormhole && \
|
||||
nix-shell --option sandbox false --command 'whtilt $WH_GUARDIAN_COUNT'"
|
||||
'';
|
||||
}
|
|
@ -17,34 +17,22 @@
|
|||
"homepage": "https://github.com/nmattia/niv",
|
||||
"owner": "nmattia",
|
||||
"repo": "niv",
|
||||
"rev": "af958e8057f345ee1aca714c1247ef3ba1c15f5e",
|
||||
"sha256": "1qjavxabbrsh73yck5dcq8jggvh3r2jkbr6b5nlz5d9yrqm9255n",
|
||||
"rev": "e0ca65c81a2d7a4d82a189f1e23a48d59ad42070",
|
||||
"sha256": "1pq9nh1d8nn3xvbdny8fafzw87mj7gsmp6pxkdl65w2g18rmcmzx",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nmattia/niv/archive/af958e8057f345ee1aca714c1247ef3ba1c15f5e.tar.gz",
|
||||
"url": "https://github.com/nmattia/niv/archive/e0ca65c81a2d7a4d82a189f1e23a48d59ad42070.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs": {
|
||||
"branch": "release-20.09",
|
||||
"branch": "release-21.05",
|
||||
"description": "Nix Packages collection",
|
||||
"homepage": "",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a1643da0480d7716e76c79654b2591dfacbf2931",
|
||||
"sha256": "1bvivv5dj6qvc5kyf2f0s84s5hqh8ry0i5ly9c9qsw4s9svl9yb1",
|
||||
"rev": "0d85f682c5fb9b6e1319b584d3fc247ed9c8082e",
|
||||
"sha256": "01dackjly32miy0pfk4szg4mvcn3xg329im7zah6fjsw94b8h4s6",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/a1643da0480d7716e76c79654b2591dfacbf2931.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs-mozilla": {
|
||||
"branch": "master",
|
||||
"description": "mozilla related nixpkgs (extends nixos/nixpkgs repo)",
|
||||
"homepage": "",
|
||||
"owner": "mozilla",
|
||||
"repo": "nixpkgs-mozilla",
|
||||
"rev": "8c007b60731c07dd7a052cce508de3bb1ae849b4",
|
||||
"sha256": "1zybp62zz0h077zm2zmqs2wcg3whg6jqaah9hcl1gv4x8af4zhs6",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/mozilla/nixpkgs-mozilla/archive/8c007b60731c07dd7a052cce508de3bb1ae849b4.tar.gz",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/0d85f682c5fb9b6e1319b584d3fc247ed9c8082e.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"rust-overlay": {
|
||||
|
|
55
shell.nix
55
shell.nix
|
@ -4,60 +4,12 @@
|
|||
, rust-olay ? import sources.rust-overlay
|
||||
}:
|
||||
let
|
||||
tilt-olay = self: super: {
|
||||
tilt184 = self.tilt.overrideAttrs (
|
||||
oldAttrs: {
|
||||
version = "0.18.4";
|
||||
src = self.fetchFromGitHub {
|
||||
owner = "tilt-dev";
|
||||
repo = oldAttrs.pname;
|
||||
rev = "v0.18.4";
|
||||
sha256 = null;
|
||||
};
|
||||
buildFlagsArray = [ "-ldflags=-X main.version=0.18.4" ];
|
||||
}
|
||||
);
|
||||
};
|
||||
scripts-olay = self: super: {
|
||||
whcluster = self.writeShellScriptBin "whcluster" ''
|
||||
set -e
|
||||
default_minikube_args="--cpus=10 --memory=10gb --disk-size=200gb"
|
||||
export MINIKUBE_ARGS=''${MINIKUBE_ARGS:-$default_minikube_args}
|
||||
${self.minikube}/bin/minikube start $MINIKUBE_ARGS
|
||||
${self.minikube}/bin/minikube ssh 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p'
|
||||
${self.whkube}/bin/whkube
|
||||
'';
|
||||
whkube = self.writeShellScriptBin "whkube" ''${self.kubectl}/bin/kubectl config set-context --current --namespace=wormhole'';
|
||||
whtilt = self.writeShellScriptBin "whtilt" ''
|
||||
echo "Starting Tilt with ''${1:=5} guardians"
|
||||
${self.tilt184}/bin/tilt up --update-mode exec -- --num=$1
|
||||
'';
|
||||
whinotify = self.writeShellScriptBin "whinotify" ''
|
||||
${self.minikube}/bin/minikube ssh 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p'
|
||||
'';
|
||||
# stan-work config
|
||||
whsw = self.writeShellScriptBin "whsw" ''
|
||||
${pkgs.mutagen}/bin/mutagen sync terminate whsw-sync || true
|
||||
${pkgs.mutagen}/bin/mutagen sync create -n whsw-sync . stan-work:~/wormhole
|
||||
${pkgs.mutagen}/bin/mutagen sync flush whsw-sync
|
||||
export MINIKUBE_ARGS='--cpus=30 --memory=110g --disk-size=1000gb'
|
||||
ssh stan-work \
|
||||
". ~/.zprofile && \
|
||||
cd wormhole && \
|
||||
nix-shell --command ' MINIKUBE_ARGS=\"$MINIKUBE_ARGS\" whcluster && \
|
||||
killall tilt || true'"
|
||||
ssh -L 10350:127.0.0.1:10350 stan-work \
|
||||
"cd wormhole && \
|
||||
source ~/.zprofile && \
|
||||
nix-shell shell.nix --command 'whtilt $WH_GUARDIAN_COUNT'"
|
||||
'';
|
||||
};
|
||||
scripts-olay = import ./nix/scripts.nix;
|
||||
cargo2nix-olay = import "${cargo2nix}/overlay";
|
||||
pkgs = import nixpkgs {
|
||||
overlays = [
|
||||
# cargo2nix-olay
|
||||
rust-olay
|
||||
tilt-olay
|
||||
scripts-olay
|
||||
];
|
||||
};
|
||||
|
@ -72,6 +24,7 @@ pkgs.mkShell {
|
|||
gopls
|
||||
hidapi
|
||||
libudev
|
||||
niv
|
||||
openssl
|
||||
pkgconfig
|
||||
protobuf
|
||||
|
@ -79,7 +32,7 @@ pkgs.mkShell {
|
|||
whinotify
|
||||
whkube
|
||||
whtilt
|
||||
whsw
|
||||
whremote
|
||||
# (
|
||||
# rust-bin.stable."1.51.0".default.override {
|
||||
# extensions = [
|
||||
|
@ -91,7 +44,7 @@ pkgs.mkShell {
|
|||
# Provided on Fedora:
|
||||
kubectl
|
||||
minikube
|
||||
tilt184
|
||||
tilt
|
||||
# xargo
|
||||
]
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue