From bb8d06ee7f40dae99d2ec1ae2f733398264e4d71 Mon Sep 17 00:00:00 2001 From: ChUrl Date: Thu, 25 May 2023 00:14:39 +0200 Subject: [PATCH] Generate containers file for rofi --- config/rofi/menus/containers.txt | 6 ------ config/rofi/menus/systemd-podman.fish | 2 +- config/rofi/menus/vpn.fish | 2 +- home/modules/rofi/default.nix | 2 ++ system/modules/containers/default.nix | 9 ++++++++- 5 files changed, 12 insertions(+), 9 deletions(-) delete mode 100644 config/rofi/menus/containers.txt diff --git a/config/rofi/menus/containers.txt b/config/rofi/menus/containers.txt deleted file mode 100644 index 51a2b425..00000000 --- a/config/rofi/menus/containers.txt +++ /dev/null @@ -1,6 +0,0 @@ -jellyfin -sonarr -radarr -hydra -sabnzbd -homeassistant diff --git a/config/rofi/menus/systemd-podman.fish b/config/rofi/menus/systemd-podman.fish index 9c67f322..57fd80f8 100755 --- a/config/rofi/menus/systemd-podman.fish +++ b/config/rofi/menus/systemd-podman.fish @@ -1,7 +1,7 @@ #!/usr/bin/env fish # User chooses service, running services are marked in green -set SERVICES (cat ~/NixFlake/config/rofi/menus/containers.txt) # TODO: This file should probably be generated by nix? +set SERVICES (cat /etc/rofi-containers) set PROMPT "" for SERVICE in $SERVICES set SERVICE_RUNNING "$(systemctl list-units podman-$SERVICE.service | grep podman-$SERVICE.service)" diff --git a/config/rofi/menus/vpn.fish b/config/rofi/menus/vpn.fish index 561788ca..4b339d05 100755 --- a/config/rofi/menus/vpn.fish +++ b/config/rofi/menus/vpn.fish @@ -1,7 +1,7 @@ #!/usr/bin/env fish # User chooses VPN server, running servers are marked in green -set SERVERS (cat /etc/rofi-vpns) # TODO: This file should probably be generated by nix? +set SERVERS (cat /etc/rofi-vpns) set PROMPT "" for SERVER in $SERVERS set SERVER_RUNNING "$(systemctl list-units $SERVER.service | grep $SERVER.service)" diff --git a/home/modules/rofi/default.nix b/home/modules/rofi/default.nix index 843bc7a8..724cd548 100644 --- a/home/modules/rofi/default.nix +++ b/home/modules/rofi/default.nix @@ -1,3 +1,5 @@ +# TODO: Need some kind of menu generator API that is integrated with hyprland hotkeys +# VPN and Container modules should use this rofi module to enable their menus then { config, nixosConfig, diff --git a/system/modules/containers/default.nix b/system/modules/containers/default.nix index b090d33c..0cc77af6 100644 --- a/system/modules/containers/default.nix +++ b/system/modules/containers/default.nix @@ -14,7 +14,7 @@ with mylib.modules; let in { options.modules.containers = import ./options.nix {inherit lib mylib;}; - config = mkIf cfg.enable { + config = mkIf cfg.enable rec { virtualisation.oci-containers.containers = { # Home Automation homeassistant = mkIf cfg.homeassistant.enable (mkOciContainer { @@ -96,5 +96,12 @@ in { netdns = "10.2.0.1"; }); }; + + environment.etc."rofi-containers".text = let + containers-list = attrNames virtualisation.oci-containers.containers; + containers-filtered = filter (c: cfg.${c}.enable) containers-list; + containers = concatStringsSep "\n" containers-filtered; + in + containers; }; }