ne
This commit is contained in:
parent
793ef6ca6f
commit
07801d65b2
pkgs/mk-nspawn-setup
profiles
users/pbsds/home/profiles
@ -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
|
||||
|
||||
|
@ -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)"
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
}
|
||||
|
@ -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'';
|
||||
|
Loading…
x
Reference in New Issue
Block a user