Files
nix-stuff/common/shell/container-aliases.nix
Shelvacu ce7346e7ea stuff
2025-05-22 18:48:45 -07:00

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"
'')
];
};
}