Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
nix-env "default nix expression" / "active nix expression" / top-level
_nix_build_defexpr () {
local -a result
local -a queue=($1)
setopt local_options null_glob
while [[ ${#queue} > 0 ]]; do
local current=$queue[1]
shift queue
if [[ -e $current/default.nix ]]; then
result+=($current)
else
queue+=($current/*)
fi
done
local nix_expr="{\n"
for p in $result; do
nix_expr+="$(basename $p) = import $p {};"
nix_expr+="\n"
done
nix_expr+="}"
echo $nix_expr
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment