33 lines
732 B
Nix
33 lines
732 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" ''
|
|
min_args $# 2
|
|
if [[ $UID != 0 ]]; then
|
|
exec /run/wrappers/bin/sudo "$0" "$@"
|
|
fi
|
|
container="$1"
|
|
shift
|
|
exec ${lib.getExe pkgs.nixos-container} run "$1" -- "$@"
|
|
'')
|
|
(writeScriptBin "ncrl" ''
|
|
exact_args $# 1
|
|
if [[ $UID != 0 ]]; then
|
|
exec /run/wrappers/bin/sudo "$0" "$@"
|
|
fi
|
|
exec ${lib.getExe pkgs.nixos-container} root-login "$1"
|
|
'')
|
|
];
|
|
};
|
|
}
|