Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pshirshov committed Oct 29, 2024
1 parent eb72cd6 commit 25d06cd
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
#!/usr/bin/env bash

set -e

self="$(realpath "$0")"
path="$(dirname "$self")"
echo "Working in $path"
cd "$path"
export LANG="C.UTF-8"

(for e in "$@"; do [[ "$e" == "nix" ]] && exit 0; done) && NIXIFY=1 || NIXIFY=0

if [[ "$NIXIFY" == 1 && -z "${IN_NIX_SHELL+x}" ]]; then
echo "Restarting in Nix..."
set -x
nix flake lock
nix flake metadata
exec nix develop \
--ignore-environment \
--keep CI_BRANCH \
--keep CI_COMMIT \
--keep CI_BRANCH_TAG \
--keep CI_PULL_REQUEST \
--keep CI_BUILD_UNIQ_SUFFIX \
--keep CI \
--keep HOME \
--command bash "$self" "$@"
fi
function nixify() {
read -r -a args <<< "$(grep -v '^\s*$' .keep.env | sed "s/^/--keep /;s/$/ /" | tr '\n' ' ')"

set -x
cd "$path"
if [[ -z "${IN_NIX_SHELL+x}" ]]; then
echo "Restarting in Nix..."
set -x
nix flake lock
nix flake metadata
exec nix develop \
--ignore-environment \
--keep HOME \
--keep CI_BRANCH \
--keep CI_COMMIT \
--keep CI_BRANCH_TAG \
--keep CI_PULL_REQUEST \
--keep CI_BUILD_UNIQ_SUFFIX \
--keep CI \
"${args[@]}" \
--command bash "$self" "$@"
fi
}

for i in "$@"
do
case $i in
nix) ;;
nix) shift && nixify "$@" ;;
env) exec bash -norc ;;
*) "./devops/$i.sh" ;;
esac
Expand Down

0 comments on commit 25d06cd

Please sign in to comment.