39 lines
932 B
Nix
39 lines
932 B
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
inherit (pkgs) writeScriptBin;
|
|
in
|
|
{
|
|
options.vacu.shell.containerAliases = lib.mkEnableOption "container aliases";
|
|
config = lib.mkIf config.vacu.shell.containerAliases {
|
|
vacu.packages = [
|
|
(writeScriptBin "ncrun" ''
|
|
if (( "$#" < 2 )); then
|
|
echo "need at least two args [container] and [command]" >&2
|
|
exit 1
|
|
fi
|
|
if [[ $UID != 0 ]]; then
|
|
exec /run/wrappers/bin/sudo "$0" "$@"
|
|
fi
|
|
container="$1"
|
|
shift
|
|
exec ${lib.getExe pkgs.nixos-container} run "$1" -- "$@"
|
|
'')
|
|
(writeScriptBin "ncrl" ''
|
|
if (( "$#" != 1 )); then
|
|
echo "need exactly one arg: [container]" >&2
|
|
exit 1
|
|
fi
|
|
if [[ $UID != 0 ]]; then
|
|
exec /run/wrappers/bin/sudo "$0" "$@"
|
|
fi
|
|
exec ${lib.getExe pkgs.nixos-container} root-login "$1"
|
|
'')
|
|
];
|
|
};
|
|
}
|