48 lines
1.4 KiB
Nix
48 lines
1.4 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}: let
|
|
inherit (lib.strings) concatStringsSep;
|
|
inherit (lib.lists) forEach;
|
|
|
|
inherit (builtins) attrNames;
|
|
|
|
inherit (pkgs) writeShellScriptBin;
|
|
|
|
containerNames = attrNames config.containers;
|
|
|
|
vaccumSize = "50M";
|
|
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}
|
|
''));
|
|
}
|