2023-09-18 03:56:58 +01:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit (lib.strings) concatStringsSep;
|
|
|
|
inherit (lib.lists) forEach;
|
|
|
|
|
|
|
|
inherit (builtins) attrNames;
|
|
|
|
|
|
|
|
inherit (pkgs) writeShellScriptBin;
|
|
|
|
|
|
|
|
containerNames = attrNames config.containers;
|
|
|
|
|
2023-09-19 22:30:02 +01:00
|
|
|
vaccumSize = "50M";
|
2023-09-18 03:56:58 +01:00
|
|
|
in {
|
|
|
|
environment.systemPackages =
|
|
|
|
[
|
|
|
|
(writeShellScriptBin "journalctl-vaccum-all" ''
|
|
|
|
journalctl --vacuum-size=${vaccumSize}
|
|
|
|
${concatStringsSep "\n" (forEach containerNames (name: ''
|
|
|
|
journalctl --vacuum-size=${vaccumSize} --root /var/lib/nixos-containers/${name}
|
|
|
|
''))}
|
|
|
|
'')
|
|
|
|
(writeShellScriptBin "systemctl-list-failed-all" ''
|
|
|
|
echo "Host: "
|
|
|
|
systemctl --failed
|
|
|
|
${concatStringsSep "\n" (forEach containerNames (name: ''
|
|
|
|
echo "Container: ${name}"
|
|
|
|
systemctl -M ${name} --failed
|
|
|
|
''))}
|
|
|
|
'')
|
|
|
|
]
|
|
|
|
++ forEach containerNames (name: (writeShellScriptBin "journalctl-vaccum-${name}" ''
|
|
|
|
journalctl --vacuum-size=${vaccumSize} --root /var/lib/nixos-containers/${name}
|
|
|
|
''))
|
|
|
|
++ forEach containerNames (name: (writeShellScriptBin "systemctl-container-${name}" ''
|
|
|
|
systemctl -M ${name} "$@"
|
|
|
|
''))
|
|
|
|
++ forEach containerNames (name: (writeShellScriptBin "journalctl-container-${name}" ''
|
|
|
|
journalctl -M ${name} "$@"
|
|
|
|
''))
|
|
|
|
++ forEach containerNames (name: (writeShellScriptBin "shell-enter-${name}" ''
|
|
|
|
machinectl shell ${name}
|
|
|
|
''));
|
|
|
|
}
|