stuff
This commit is contained in:
@@ -15,18 +15,14 @@ in
|
||||
vacu.packages = [
|
||||
(script "ncrun" ''
|
||||
svl_min_args $# 2
|
||||
if [[ $EUID != 0 ]]; then
|
||||
exec /run/wrappers/bin/sudo "$0" "$@"
|
||||
fi
|
||||
svl_auto_sudo
|
||||
container="$1"
|
||||
shift
|
||||
exec ${lib.getExe pkgs.nixos-container} run "$container" -- "$@"
|
||||
'')
|
||||
(script "ncrl" ''
|
||||
svl_exact_args $# 1
|
||||
if [[ $EUID != 0 ]]; then
|
||||
exec /run/wrappers/bin/sudo "$0" "$@"
|
||||
fi
|
||||
svl_auto_sudo
|
||||
exec ${lib.getExe pkgs.nixos-container} root-login "$1"
|
||||
'')
|
||||
];
|
||||
|
@@ -48,7 +48,7 @@ in
|
||||
printf "%d" "$ret"
|
||||
return "$ret"
|
||||
}
|
||||
if [ $UID = 0 ]; then
|
||||
if [[ $EUID == 0 ]]; then
|
||||
PS1=${lib.escapeShellArg (default_ps1 true)}
|
||||
else
|
||||
PS1=${lib.escapeShellArg (default_ps1 false)}
|
||||
|
@@ -129,10 +129,16 @@ if _shellvaculib_debug_enabled; then
|
||||
"${cmd[@]}" || true
|
||||
fi
|
||||
|
||||
if [[ -z ${_shellvaculib_arg0_canonicalized-} ]]; then
|
||||
declare -a _shellvaculib_script_args
|
||||
declare _shellvaculib_arg0 _shellvaculib_arg0_canonicalized _shellvaculib_initialized
|
||||
|
||||
if [[ ${_shellvaculib_initialized-} != 1 ]]; then
|
||||
_shellvaculib_arg0="$0"
|
||||
_shellvaculib_script_args=("$@")
|
||||
if ! _shellvaculib_arg0_canonicalized="$(realpath -- "$0")"; then
|
||||
svl_eprintln "warn: could not get realpath of \$0: $0"
|
||||
fi
|
||||
_shellvaculib_initialized=1
|
||||
else
|
||||
_shellvaculib_debug_print "warn: shellvaculib re-sourced"
|
||||
fi
|
||||
@@ -268,7 +274,7 @@ svl_assert_probably_in_script_dir() {
|
||||
}
|
||||
|
||||
svl_assert_root() {
|
||||
if [[ -n ${EUID:-} ]]; then
|
||||
if [[ -z ${EUID:-} ]]; then
|
||||
svl_throw '$EUID unset!?'
|
||||
fi
|
||||
if [[ $EUID != 0 ]]; then
|
||||
@@ -277,6 +283,21 @@ svl_assert_root() {
|
||||
return 0
|
||||
}
|
||||
|
||||
svl_auto_sudo() {
|
||||
if [[ -z ${EUID:-} ]]; then
|
||||
svl_throw '$EUID unset!?'
|
||||
fi
|
||||
if [[ $EUID == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
if [[ ${SHELLVACULIB_IN_AUTO_SUDO:-} == 1 ]]; then
|
||||
svl_throw 'svl_auto_sudo: already inside auto-sudo and failed :('
|
||||
fi
|
||||
declare sudo_path
|
||||
sudo_path="$(command -v sudo)"
|
||||
SHELLVACULIB_IN_AUTO_SUDO=1 exec "$sudo_path" -e SHELLVACULIB_IN_AUTO_SUDO "$_shellvaculib_arg0" "${_shellvaculib_script_args[@]}"
|
||||
}
|
||||
|
||||
# svl_in_array {needle} {*haystack...}
|
||||
# false (return code 1) when haystack is empty
|
||||
svl_in_array() {
|
||||
|
@@ -12,7 +12,8 @@ let
|
||||
seagate_ironwolf
|
||||
];
|
||||
raidPartitions = map (s: s + "-part2") nvmeDevices;
|
||||
md_dev = "/dev/disk/by-id/md-name-prophecy-root-crypt";
|
||||
md_name = "prophecy-root-crypt";
|
||||
md_dev = "/dev/disk/by-id/md-name-${md_name}";
|
||||
in
|
||||
{
|
||||
boot.initrd.availableKernelModules = [
|
||||
@@ -30,7 +31,7 @@ in
|
||||
boot.swraid.enable = true;
|
||||
boot.swraid.mdadmConf = ''
|
||||
DEVICE ${lib.concatStringsSep " " raidPartitions}
|
||||
ARRAY ${md_dev} metadata=1.2 UUID=9edfd1b4:0fb7fd0d:4f390f6d:3d176ddf
|
||||
ARRAY ${md_name} metadata=1.2 UUID=9edfd1b4:0fb7fd0d:4f390f6d:3d176ddf
|
||||
AUTO -all
|
||||
PROGRAM ${pkgs.coreutils}/bin/echo
|
||||
'';
|
||||
|
Reference in New Issue
Block a user