diff --git a/modules/common/logging/hw-mac-retrieve.nix b/modules/common/logging/hw-mac-retrieve.nix index 82cc8863cf..0f674edbc3 100644 --- a/modules/common/logging/hw-mac-retrieve.nix +++ b/modules/common/logging/hw-mac-retrieve.nix @@ -1,5 +1,6 @@ # Copyright 2022-2024 TII (SSRC) and the Ghaf contributors # SPDX-License-Identifier: Apache-2.0 +{ hostConfig }: { config, lib, @@ -28,7 +29,11 @@ in # TODO: Remove hw-mac.service and replace with givc rpc later systemd.services."hw-mac" = { description = "Retrieve MAC address from net-vm"; - wantedBy = [ "alloy.service" ]; + wantedBy = + if hostConfig.ghaf.virtualization.microvm.guivm.enable then + [ "ewwbar.service" ] + else + [ "alloy.service" ]; requires = [ "network-online.target" ]; serviceConfig = { Type = "oneshot"; @@ -36,7 +41,7 @@ in # Make sure we can ssh before we retrieve mac address ExecStartPre = "${sshCommand} ls"; ExecStart = '' - ${pkgs.bash}/bin/bash -c "echo -n $(${sshCommand} ${macCommand}) > ${macAddressPath}" + ${pkgs.bash}/bin/bash -c "echo -n $(${sshCommand} ${macCommand}) > ${macAddressPath} " ''; Restart = "on-failure"; RestartSec = "1"; diff --git a/modules/microvm/virtualization/microvm/adminvm.nix b/modules/microvm/virtualization/microvm/adminvm.nix index 9e235a9ca1..4088a17df3 100644 --- a/modules/microvm/virtualization/microvm/adminvm.nix +++ b/modules/microvm/virtualization/microvm/adminvm.nix @@ -22,7 +22,7 @@ let internalIP = 10; }) # We need to retrieve mac address and start log aggregator - ../../../common/logging/hw-mac-retrieve.nix + (import ../../../common/logging/hw-mac-retrieve.nix { hostConfig = config; }) ../../../common/logging/logs-aggregator.nix ./common/storagevm.nix ( diff --git a/modules/microvm/virtualization/microvm/guivm.nix b/modules/microvm/virtualization/microvm/guivm.nix index 9dd1759d57..a79b00fb8b 100644 --- a/modules/microvm/virtualization/microvm/guivm.nix +++ b/modules/microvm/virtualization/microvm/guivm.nix @@ -11,6 +11,7 @@ let vmName = "gui-vm"; macAddress = "02:00:00:02:02:02"; inherit (import ../../../../lib/launcher.nix { inherit pkgs lib; }) rmDesktopEntries; + hostConfig = config; guivmBaseConfiguration = { imports = [ inputs.impermanence.nixosModules.impermanence @@ -29,6 +30,9 @@ let # To push logs to central location ../../../common/logging/client.nix + + (import ../../../common/logging/hw-mac-retrieve.nix { hostConfig = config; }) + ( { lib, pkgs, ... }: let @@ -106,6 +110,7 @@ let # Logging client configuration logging.client.enable = config.ghaf.logging.client.enable; logging.client.endpoint = config.ghaf.logging.client.endpoint; + logging.identifierFilePath = "/tmp/MACAddress"; storagevm = { enable = true; name = "guivm"; @@ -199,7 +204,20 @@ let pkgs.eww pkgs.wlr-randr ] - ++ [ pkgs.ctrl-panel ] + ++ [ + pkgs.ctrl-panel + (pkgs.writeShellApplication { + name = "github-config"; + text = '' + mkdir -p "$HOME"/.config/ctrl-panel + cat > "$HOME"/.config/ctrl-panel/config.toml << EOF + token = "${cfg.githubToken}" + owner = "${cfg.githubOwner}" + repo = "${cfg.githubRepo}" + EOF + ''; + }) + ] ++ (lib.optional ( config.ghaf.profiles.debug.enable && config.ghaf.virtualization.microvm.idsvm.mitmproxy.enable ) pkgs.mitmweb-ui) @@ -212,6 +230,7 @@ let sessionVariables = { XDG_PICTURES_DIR = "$HOME/Pictures"; XDG_VIDEOS_DIR = "$HOME/Videos"; + GITHUB_CONFIG = "$HOME/.config/ctrl-panel/config.toml"; }; }; @@ -358,6 +377,25 @@ in ); default = [ ]; }; + + githubOwner = lib.mkOption { + type = lib.types.str; + description = '' + Github owner account of the bug reporter issue + ''; + }; + githubRepo = lib.mkOption { + type = lib.types.str; + description = '' + Github repo of the bug reporter issue + ''; + }; + githubToken = lib.mkOption { + type = lib.types.str; + description = '' + Personal token of the bug reporter Github account + ''; + }; }; config = lib.mkIf cfg.enable { diff --git a/modules/reference/profiles/laptop-x86.nix b/modules/reference/profiles/laptop-x86.nix index 0d97c423d9..708375f67f 100644 --- a/modules/reference/profiles/laptop-x86.nix +++ b/modules/reference/profiles/laptop-x86.nix @@ -95,6 +95,9 @@ in guivm = { enable = true; extraModules = cfg.guivmExtraModules; + githubToken = "xxxxxxxxxxxxxxxxxxxx"; + githubOwner = "yyyyy"; + githubRepo = "zzzzzz"; }; audiovm = {