diff --git a/pkgs/mk-nspawn-setup/setup-nspawn.sh b/pkgs/mk-nspawn-setup/setup-nspawn.sh index 10d6b1b..82a425e 100644 --- a/pkgs/mk-nspawn-setup/setup-nspawn.sh +++ b/pkgs/mk-nspawn-setup/setup-nspawn.sh @@ -6,19 +6,19 @@ NSPAWN_NAME=nixos-@hostname@ TARBALL=./nixos-@hostname@.tar.xz test $(id -u) -eq 0 || { - >&2 echo you must run this as root + echo >&2 you must run this as root exit 1 } if ! >/dev/null command -v systemd-nspawn; then - >&2 echo "systemd-nspawn" not found in PATH - >&2 echo consider installing 'systemd-container' + echo >&2 "systemd-nspawn" not found in PATH + echo >&2 consider installing 'systemd-container' exit 1 fi if ! >/dev/null command -v machinectl; then - >&2 echo "machinectl" not found in PATH - >&2 echo consider installing 'systemd-container' + echo >&2 "machinectl" not found in PATH + echo >&2 consider installing 'systemd-container' exit 1 fi diff --git a/profiles/domeneshop-dyndns.nix b/profiles/domeneshop-dyndns.nix index 180bffc..ea30de2 100644 --- a/profiles/domeneshop-dyndns.nix +++ b/profiles/domeneshop-dyndns.nix @@ -38,11 +38,11 @@ in runtimeInputs = with pkgs; [ curl iproute2 jq ]; text = '' test -s /run/secrets/domeneshop/token || { - >&2 echo "ERROR: /run/secrets/domeneshop/token not found!" + echo >&2 "ERROR: /run/secrets/domeneshop/token not found!" exit 1 } test -s /run/secrets/domeneshop/secret || { - >&2 echo "ERROR: /run/secrets/domeneshop/secret not found!" + echo >&2 "ERROR: /run/secrets/domeneshop/secret not found!" exit 1 } DOMENESHOP_TOKEN="$( cat /run/secrets/domeneshop/token)" diff --git a/profiles/http/docs/default.nix b/profiles/http/docs/default.nix index c5a0418..5e9b36f 100644 --- a/profiles/http/docs/default.nix +++ b/profiles/http/docs/default.nix @@ -33,7 +33,7 @@ let time rsync -r --chmod +rw --copy-links ${root}/ . test ! -e pagefind || { - >&2 echo 'ERROR: `root` input has `pagefind` already in it!' + echo >&2 'ERROR: `root` input has `pagefind` already in it!' false } diff --git a/users/pbsds/home/profiles/bashrc.d/destore.sh b/users/pbsds/home/profiles/bashrc.d/destore.sh index f1a437a..9b4102a 100644 --- a/users/pbsds/home/profiles/bashrc.d/destore.sh +++ b/users/pbsds/home/profiles/bashrc.d/destore.sh @@ -4,7 +4,7 @@ destore() { if test ! -w "$(dirname $(realpath --no-symlinks $dst))" ; then MAYBESUDO="sudo" sudo true || { - >&2 echo "ERROR: could not destore '$dst' due to lack of sudo" + echo >&2 "ERROR: could not destore '$dst' due to lack of sudo" break } fi diff --git a/users/pbsds/home/profiles/bashrc.d/nix-shell.sh b/users/pbsds/home/profiles/bashrc.d/nix-shell.sh index ef03ae0..1824acb 100644 --- a/users/pbsds/home/profiles/bashrc.d/nix-shell.sh +++ b/users/pbsds/home/profiles/bashrc.d/nix-shell.sh @@ -1,4 +1,5 @@ -_ns() { +# TODO: nom +_ns_ohk2aaDu() { local is_dev=$1; shift # "true" or "false" if $is_dev; then local arg_suffix="^*" @@ -6,6 +7,7 @@ _ns() { local arg_suffix="" fi local args=() + local pkg for pkg in "$@"; do if [[ "$pkg" = -- ]]; then break @@ -25,7 +27,7 @@ _ns() { cmd=("${cmd[@]:1}") if [[ ${#cmd[@]} -gt 0 ]]; then ( - _ns false "${args[@]}" + _ns_ohk2aaDu false "${args[@]}" set -x "${cmd[@]}" ) @@ -33,13 +35,14 @@ _ns() { fi # echo current shell - # >&2 echo -n + exec nix shell - >&2 echo -n + ns + # TODO: deduplicate repeats, 'x^*' should replace 'x' + # echo >&2 -n + exec nix shell + echo >&2 -n + ns if [[ -v _PREVIOUS_NS_ARGS ]]; then - >&2 echo -n " ${_PREVIOUS_NS_ARGS:-}" + echo >&2 -n " ${_PREVIOUS_NS_ARGS:-}" fi >&2 printf " %q" "${args[@]}" - >&2 echo + echo >&2 if [[ "${#args[@]}" -eq 0 ]]; then return @@ -135,5 +138,24 @@ _ns() { fi } -ns() { _ns false "$@"; } -nd() { _ns true "$@"; } +ns() { _ns_ohk2aaDu false "$@"; } +nd() { _ns_ohk2aaDu true "$@"; } + +# TODO: some way to "pop"? +# TODO: support empty args with nix-search + +# enter +ne() { + local pkg="$1" + if [[ -z "$pkg" ]]; then + return + fi + if [[ ! "$pkg" =~ ^.*[#:/].*$ ]]; then + pkg=nixpkgs#"${pkg}" + fi + + ns "$@" + storepath="$(nix --extra-experimental-features "nix-command flakes" build --impure "$pkg" --print-out-paths --no-link)" + printf >&2 "+ cd %q\n" "$storepath" + cd "$storepath" +} diff --git a/users/pbsds/home/profiles/shell.nix b/users/pbsds/home/profiles/shell.nix index acd10fb..698f346 100644 --- a/users/pbsds/home/profiles/shell.nix +++ b/users/pbsds/home/profiles/shell.nix @@ -130,7 +130,9 @@ in home.shellAliases.fda = "fd --no-ignore --hidden"; home.shellAliases.afd = "fd --no-ignore --hidden"; - home.shellAliases.nlocate = "nix-locate --top-level --regex"; # via nix-index-with-full-db + # via nix-index-with-full-db + home.shellAliases.nlocate = "nix-locate --top-level --regex"; + home.shellAliases.nlocateo = mkArgsAlias ''nix-locate --top-level --regex "$@" | tr -s ' ' | cut -d' ' -f4''; home.shellAliases.inom = mkArgsAlias ''nom "$@" --system i686-linux -j0''; home.shellAliases.inix = mkArgsAlias ''nix "$@" --system i686-linux -j0'';