add scripts for treewide mainProgram
This commit is contained in:
parent
64317ab657
commit
64ff01e6f0
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
PACKAGE_PATH=$1
|
||||||
|
PACKAGE_NAME=$1
|
||||||
|
|
||||||
|
if [ -f $1 ]; then
|
||||||
|
PACKAGE_NAME=$(dirname $PACKAGE_NAME)
|
||||||
|
else
|
||||||
|
PACKAGE_PATH="${PACKAGE_PATH%%/}/default.nix"
|
||||||
|
fi
|
||||||
|
|
||||||
|
PACKAGE_NAME="${PACKAGE_NAME%/}"
|
||||||
|
PACKAGE_NAME="${PACKAGE_NAME##*/}"
|
||||||
|
|
||||||
|
NVIM_CLIPBOARD="mainProgram = \"$PACKAGE_NAME\";" nvim $PACKAGE_PATH
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#!nix-shell -i bash -p bash ripgrep nix
|
||||||
|
|
||||||
|
FILES_WITHOUT_MAINPROGRAM=$(rg --case-sensitive --files-without-match "mainProgram" -g 'default.nix' .)
|
||||||
|
|
||||||
|
trap "exit 0" SIGINT
|
||||||
|
|
||||||
|
for FILE in $FILES_WITHOUT_MAINPROGRAM; do
|
||||||
|
PACKAGE=$(dirname "$FILE" | sed 's|^./||')
|
||||||
|
echo "Building: $PACKAGE"
|
||||||
|
|
||||||
|
NIXPKGS_ALLOW_UNFREE=1 nix build ".#$PACKAGE" --impure || continue
|
||||||
|
|
||||||
|
if [ "$(find result/bin | wc -w)" == 1 ]; then
|
||||||
|
echo "$PACKAGE: $(ls result/bin)" >> packages.txt
|
||||||
|
elif [ "$(find result-bin/bin | wc -w)" == 1 ]; then
|
||||||
|
echo "$PACKAGE: $(ls result-bin/bin)" >> packages.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm result* || true
|
||||||
|
done
|
|
@ -0,0 +1,12 @@
|
||||||
|
local function paste_buf()
|
||||||
|
local content = os.getenv("NVIM_CLIPBOARD")
|
||||||
|
|
||||||
|
local line = vim.api.nvim_get_current_line()
|
||||||
|
local indent = string.match(line, " +")
|
||||||
|
|
||||||
|
vim.fn.setreg("a", indent .. content)
|
||||||
|
vim.cmd("put a")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Use ';' to insert paste_buf
|
||||||
|
vim.keymap.set('n', ';', paste_buf)
|
|
@ -0,0 +1,47 @@
|
||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#!nix-shell -i bash -p bash ripgrep nix
|
||||||
|
|
||||||
|
if [ "$1" == "head" ]; then
|
||||||
|
ADDED_MAINPROGRAMS=$(git diff-tree --no-commit-id --name-only -r HEAD)
|
||||||
|
elif [ "$1" == "wip" ]; then
|
||||||
|
ADDED_MAINPROGRAMS=$(git diff --name-only --cached)
|
||||||
|
else
|
||||||
|
echo "USAGE: $0 [ head | wip ]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
trap "exit 0" SIGINT
|
||||||
|
|
||||||
|
TOTAL_COUNT=$(echo $ADDED_MAINPROGRAMS | wc -w)
|
||||||
|
COUNTER=0
|
||||||
|
for FILE in $ADDED_MAINPROGRAMS; do
|
||||||
|
PACKAGE_PATH=$(dirname "$FILE")
|
||||||
|
PACKAGE="${PACKAGE_PATH%/}"
|
||||||
|
PACKAGE="${PACKAGE##*/}"
|
||||||
|
|
||||||
|
COUNTER=$((COUNTER + 1))
|
||||||
|
|
||||||
|
echo "($COUNTER/$TOTAL_COUNT) Verifying mainProgram of: $PACKAGE"
|
||||||
|
|
||||||
|
NIXPKGS_ALLOW_UNFREE=1 nix build ".#$PACKAGE" --option builders '' --impure || {
|
||||||
|
echo "$PACKAGE" >> missing_main_program.txt && continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MAIN_PROGRAM=$(rg "mainProgram = \"(.+?)\";" --replace "\$1" --only-matching --no-line-number "$FILE" | xargs)
|
||||||
|
|
||||||
|
echo "mainProgram: $PACKAGE"
|
||||||
|
if ! {
|
||||||
|
{
|
||||||
|
[ -d "result/bin" ] && [ "$(ls result/bin | xargs)" == "$MAIN_PROGRAM" ];
|
||||||
|
} || {
|
||||||
|
[ -d "result-bin/bin" ] && [ "$(ls result-bin/bin | xargs)" == "$MAIN_PROGRAM" ];
|
||||||
|
};
|
||||||
|
}; then
|
||||||
|
echo "mainProgram doesn't match contents:"
|
||||||
|
ls result/bin 2>/dev/null || true
|
||||||
|
ls result-bin/bin 2>/dev/null || true
|
||||||
|
echo "$PACKAGE" >> missing_main_program.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm result* || true
|
||||||
|
done
|
Loading…
Reference in New Issue