-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.envrc
More file actions
52 lines (45 loc) · 1.67 KB
/
.envrc
File metadata and controls
52 lines (45 loc) · 1.67 KB
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
#!/usr/bin/env bash
# shellcheck shell=bash
source_up
export VAULT_ADDR=https://pki.devnw.com
export NIXPKGS_ALLOW_UNFREE=1
export FLAKE_PATH=.#
export FLAKE_ARGS='--impure --accept-flake-config'
# obtain a GitHub token
if [ -z "$GITHUB_TOKEN" ]; then
# GITHUB_TOKEN is not set, try to fetch it via GitHub CLI
if [ -x "$(command -v gh)" ]; then
echo "Fetching GitHub token via GitHub CLI..."
GITHUB_TOKEN="$(gh auth token)"
export GITHUB_TOKEN
else
echo "Error: GITHUB_TOKEN is not set and GitHub CLI is not installed."
echo "Please either export GITHUB_TOKEN or install GitHub CLI (https://cli.github.com/) and try again."
exit 1
fi
else
echo "Using pre-existing GITHUB_TOKEN environment variable."
fi
vault login -no-print -method=github token="$GITHUB_TOKEN"
OPENAI_API_KEY="$(vault kv get -mount=secret -field=token /dev/openai/actions-primary)"
export OPENAI_API_KEY
CACHIX_AUTH_TOKEN="$(vault kv get -mount=secret -field=token /cicd/gh/cachix)"
export CACHIX_AUTH_TOKEN
# check for nix
if [ -x "$(command -v nix)" ]; then
echo "Nix is installed, proceeding with Nix configuration..."
else
echo "Nix is not installed, skipping Nix configuration"
echo "Please install Nix and try again."
echo "bash <(curl -L https://nixos.org/nix/install)"
exit 1
fi
export NIX_CONFIG="experimental-features = nix-command flakes
access-tokens = github.com=${GITHUB_TOKEN}"
# check for cachix
if [ ! -x "$(command -v cachix)" ]; then
nix-env -iA cachix -f https://cachix.org/api/v1/install
fi
echo "Cachix is installed, proceeding with Cachix configuration..."
cachix use oss-devnw
use flake $FLAKE_PATH $FLAKE_ARGS