ljkasdjklasdjklasdljk

This commit is contained in:
2025-06-10 11:33:32 +02:00
parent c97fe0ebbf
commit cec1405980

View File

@@ -210,6 +210,11 @@ instantiate-packages +$attrpaths="":
test -n "${attrpaths:-}" || set -- $(just _some_packages)
attrpaths=("$@")
export NIXPKGS_ALLOW_UNFREE=1
if gum confirm "Allow insecure?"; then
export NIXPKGS_ALLOW_INSECURE=1
fi
readarray -td $'\n' systems < <( just _some_systems )
for system in "${systems[@]}"; do
just _instantiate_packages "$system" "${attrpaths[@]}"
@@ -288,6 +293,10 @@ build-packages *$attrpaths:
[[ "$#" -gt 0 ]]
export JUST_SYSTEM="$(just _a_system)"
[[ -n "$JUST_SYSTEM" ]]
export NIXPKGS_ALLOW_UNFREE=1
if gum confirm "Allow insecure?"; then
export NIXPKGS_ALLOW_INSECURE=1
fi
if [[ -z "${_JUST_NIX_BUILD_ARGS:-}" ]]; then
_JUST_NIX_BUILD_ARGS="$(gum choose --no-limit -- "-j0" "--check" | tr '\n' ' ')"
export _JUST_NIX_BUILD_ARGS
@@ -307,13 +316,13 @@ __build_packages $system $outdir +$attrpaths:
test -z "${_JUST_NIX_INSTANTIATE_ARGS:-}" || echo >&2 "_JUST_NIX_INSTANTIATE_ARGS = $_JUST_NIX_INSTANTIATE_ARGS"
test -d "$outdir" && {
rm -rf "$outdir"/.gcroot
rm -rf "$outdir"/_views
rm -rf "$outdir"/.views
fd . "$outdir" --type l -X rm -v
fd \\\.log$ "$outdir" --type f -X rm -v
}
declare -a attrpaths=("${@:3}")
mkdir -p "$outdir/.gcroot"
mkdir -p "$outdir/_views/"{succeeded,failed}
mkdir -p "$outdir/.views/"{succeeded,failed}
export _JUST_NIX_INSTANTIATE_CACHE=$(mktemp -d)
export NOTFOUNDDIR="$(mktemp -d)"; touch "$NOTFOUNDDIR"/no-eval
# set -x
@@ -324,12 +333,11 @@ __build_packages $system $outdir +$attrpaths:
worker() {
local attrpath="$1"
local dst="$outdir/$attrpath"
local dst2a="$outdir/_views/succeeded/$attrpath"
local dst2b="$outdir/_views/failed/$attrpath"
local dst2a="$outdir/.views/succeeded/$attrpath"
local dst2b="$outdir/.views/failed/$attrpath"
local gcroot="$outdir/.gcroot/$attrpath" # workaround since .drv!dev will always append "-dev" to --out-path
local drvpath=$( just _instantiate_packages "$system" "$attrpath" )
set -x
# NIXPKGS_ALLOW_UNFREE=1 nix-build . -A "$attrpath" --system "$system" ${_JUST_NIX_INSTANTIATE_ARGS:-} -j0 --option builders "" --option substitute false -o "$dst" >&/dev/null
if [[ -n "$drvpath" ]]; then
local inStoreDrvPath # eww, why doesn't the !output syntax work for out of store symlinks?
if [[ "$drvpath" =~ '!' ]]; then
@@ -337,9 +345,6 @@ __build_packages $system $outdir +$attrpaths:
else
inStoreDrvPath="$(realpath "$drvpath")"
fi
# NIXPKGS_ALLOW_UNFREE=1 nix-build "$drvpath" -j0 --option builders "" --option substitute false --out-link "$dst" >&/dev/null
# NIXPKGS_ALLOW_UNFREE=1 nix-build "$drvpath" -j0 --option builders "" --option substitute false --out-link "$gcroot" >&/dev/null
#nix-build "$drvpath" -j0 --option builders "" --option substitute false --out-link "$gcroot" >&/dev/null ||:
nice -n5 nix-build "$inStoreDrvPath" -j0 --option builders "" --option substitute false --out-link "$gcroot" >&/dev/null ||:
if [[ "$drvpath" =~ '!' ]]; then
# :(
@@ -357,13 +362,13 @@ __build_packages $system $outdir +$attrpaths:
ln -sr "$dst".log "$dst2a".log
else
if [[ -z "$drvpath" ]]; then
ln -sr "$NOTFOUNDDIR"/no-eval "$dst"
ln -sr "$NOTFOUNDDIR"/no-eval "$dst2b"
NIXPKGS_ALLOW_UNFREE=1 NIXPKGS_ALLOW_INSECURE=1 nice -n5 nix-instantiate . -A "$attrpath" >& "$dst.log" # a third time...
ln -s "$NOTFOUNDDIR"/no-eval "$dst"
ln -s "$NOTFOUNDDIR"/no-eval "$dst2b"
nice -n5 nix-instantiate . -A "$attrpath" >& "$dst.log" # a third time...
ln -sr "$dst".log "$dst2b".log
else
ln -sr /build-failure-"$attrpath" "$dst"
ln -sr /build-failure-"$attrpath" "$dst2b"
ln -s /build-failure-"$attrpath" "$dst"
ln -s /build-failure-"$attrpath" "$dst2b"
nice -n5 nix log --option substituters "" ".#$attrpath" --system "$system" ${_JUST_NIX_INSTANTIATE_ARGS:-} > "$dst".log 2>/dev/null ||:
ln -sr "$dst".log "$dst2b".log
fi
@@ -532,14 +537,21 @@ push-new-pr:
if gum confirm --default=no "Test merging into upstream branches?"; then
just test-merge || gum confirm --default=no "Continue?"
fi
# TODO: can i retrieve what the upstream tracking base is for the current branch/worktree?
declare base
base="$(just _a_upstream_release_branch "Base?" | cut -d/ -f2-)"
[[ -n "$base" ]]
declare title
title="$(just _a_commit_title ||:)"
if [[ "$base" != "master" && "$base" != "staging" && "$base" != staging-next ]]; then
title="[$base] $title"
fi
title="$(gum input --placeholder="foobar: did a thing" --value="$title" ||:)"
$GIT -c push.autoSetupRemote=true push origin
if [[ -n "$title" ]]; then
gh pr create --title="$title"
gh pr create --base="$base" --title="$title"
else
gh pr create
gh pr create --base="$base"
fi
# === speed worktrees ===
@@ -728,7 +740,7 @@ remote-branch $remote_ref=`just _a_remote_branch origin | cut -d/ -f2-`:
cd "$(just _new_worktree "$@")"; exec just _enter_interactive_shell
@_a_wt_type:
gum choose feat fix init bump doc migrate drop tmp
gum choose feat fix init bump doc migrate backport drop tmp
@_a_wt_name:
gum input --placeholder="Branch name?"
@@ -762,15 +774,28 @@ _mk_worktree $name $dir $base="upstream/master" $onto="":
$GIT pull --rebase "$remote" "$branch"
[[ -z "$onto" ]] || just rebase-onto HEAD "$onto"
cherry-pick-commits-here *commits:
#!/usr/bin/env -S bash -euo pipefail -x
declare -a commits=("$@")
[[ "${#commits[@]}" -gt 0 ]] || readarray -td $'\n' commits <<<"$( cd "$invokedir"; GIT_LOG_ALL=1 just _some_commits | tac )"
[[ "${#commits[@]}" -gt 0 && -n "${commits[*]}" ]]
if gum confirm 'Use -x? Will append a line that says "(cherry picked from commit ...)"'; then
commits=(-x "${commits[@]}")
fi
git cherry-pick "${commits[@]}"
cherry-pick-commits-into-new-worktree *commits:
#!/usr/bin/env -S bash -euo pipefail
declare -a commits=("$@")
[[ "${#commits[@]}" -gt 0 ]] || readarray -td $'\n' commits <<<"$( cd "$invokedir"; just _some_commits )"
[[ "${#commits[@]}" -gt 0 ]]
[[ "${#commits[@]}" -gt 0 ]] || readarray -td $'\n' commits <<<"$( cd "$invokedir"; just _some_commits | tac )"
[[ "${#commits[@]}" -gt 0 && -n "${commits[*]}" ]]
proposed_name="$(
git -C "$invokedir" show --oneline --no-patch "${commits[0]}" |
cut -d' ' -f2- | cut -d: -f1 | rev | cut -d. -f1 | rev
)"
if gum confirm 'Use -x? Will append a line that says "(cherry picked from commit ...)"'; then
commits=(-x "${commits[@]}")
fi
cd "$(
just _new_worktree "$(just _a_wt_type)" "$(gum input --placeholder="Branch name?" --value="$proposed_name")"
)"
@@ -1195,17 +1220,23 @@ _a_commit *extra_revs:
#!/usr/bin/env -S bash -euo pipefail
[[ -n "${JUST_COMMIT:-}" ]] && { head -n1 <<<"$JUST_COMMIT"; exit 0; } ||:
# TODO: check if in a nixpkgs git repo
extra_args=()
[[ -z "${GIT_LOG_ALL:-}" ]] || extra_args+=(--all)
{
[[ $# -eq 0 ]] || printf "%s\n" "$@";
cd "$invokedir"; $GIT log --oneline -n800;
} | gum filter --placeholder "Pick commit..." --height 10 | cut -d' ' -f1 | grep .
cd "$invokedir"; nice -n5 $GIT log --oneline "${extra_args[@]}" || :
} | fzf --reverse --header="Pick commit..." | cut -d' ' -f1 | grep .
_some_commits:
_some_commits *extra_revs:
#!/usr/bin/env -S bash -euo pipefail
[[ -n "${JUST_COMMIT:-}" ]] && { cat <<<"$JUST_COMMIT"; exit 0; } ||:
# TODO: check if in a git repo
#cd "$invokedir"; $GIT log --oneline -n800 | gum filter --placeholder "Pick commit..." --height 10 --no-limit | cut -d' ' -f1
cd "$invokedir"; $GIT log --oneline -n800 | fzf --layout=reverse --multi | cut -d' ' -f1
# TODO: check if in a nixpkgs git repo
extra_args=()
[[ -z "${GIT_LOG_ALL:-}" ]] || extra_args+=(--all)
{
[[ $# -eq 0 ]] || printf "%s\n" "$@";
cd "$invokedir"; nice -n5 $GIT log --oneline "${extra_args[@]}";
} | fzf --reverse --header="Pick commit..." --multi | cut -d' ' -f1 | grep .
@_a_commit_title:
cd "$invokedir"; rev="$(just _a_commit)" || exit $?; [[ -n "$rev" ]] && git log --format="%s" -n1 "$rev" | grep .