Skip to content

Commit

Permalink
Add MAC address sharing for GUIVM
Browse files Browse the repository at this point in the history
Add report page into control panel

MAC address shared with GUIVM
Report page is added into settings of control panel
Github configuration is added to submit a report

Signed-off-by: Berk Arslan <[email protected]>
  • Loading branch information
Nerox9 committed Dec 13, 2024
1 parent 6ac9d7e commit 397a76a
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 8 deletions.
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
};

ctrl-panel = {
url = "github:tiiuae/ghaf-ctrl-panel/5ca381ba51c05cf370299056f6e377cd6003283f";
url = "github:tiiuae/ghaf-ctrl-panel/ef4b843c975030a8156390e3aa6f5536da0ad5c9";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
Expand Down
7 changes: 5 additions & 2 deletions modules/common/logging/hw-mac-retrieve.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@ 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 = [
"alloy.service"
"multi-user.target"
];
requires = [ "network-online.target" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
# 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";
Expand Down
1 change: 1 addition & 0 deletions modules/common/services/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
./yubikey.nix
./bluetooth.nix
./disks.nix
./github.nix
];
}
68 changes: 68 additions & 0 deletions modules/common/services/github.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
{
config,
lib,
pkgs,
...
}:
let
cfg = config.ghaf.services.github;
inherit (lib)
mkIf
mkEnableOption
mkOption
types
;
in
{
options.ghaf.services.github = {
enable = mkEnableOption "Github configurations";
owner = mkOption {
type = types.str;
description = ''
Github owner account of the bug reporter issue
'';
};
repo = mkOption {
type = types.str;
description = ''
Github repo of the bug reporter issue
'';
};
token = mkOption {
type = types.str;
description = ''
Personal token of the bug reporter Github account
'';
};
};

config = mkIf cfg.enable {

systemd.user.services."github-config" =
let
configScript = pkgs.writeShellScriptBin "github-config" ''
mkdir -p "$HOME"/.config/ctrl-panel
cat > "$HOME"/.config/ctrl-panel/config.toml << EOF
token = "${cfg.token}"
owner = "${cfg.owner}"
repo = "${cfg.repo}"
EOF
'';
in
{
enable = true;
description = "Generate Github configuration file for Ghaf Control Panel";
path = [ configScript ];
wantedBy = [ "ewwbar.service" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
StandardOutput = "journal";
StandardError = "journal";
ExecStart = "${configScript}/bin/github-config";
};
};
};
}
19 changes: 18 additions & 1 deletion modules/microvm/virtualization/microvm/guivm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ let

# To push logs to central location
../../../common/logging/client.nix

../../../common/logging/hw-mac-retrieve.nix

(
{ lib, pkgs, ... }:
let
Expand Down Expand Up @@ -103,9 +106,20 @@ let
withHardenedConfigs = true;
};
givc.guivm.enable = true;

# Logging client configuration
logging.client.enable = config.ghaf.logging.client.enable;
logging.client.endpoint = config.ghaf.logging.client.endpoint;
# TODO: Remove when the GIVC sharing is implemented for MAC address
logging.identifierFilePath = "/tmp/MACAddress";
# Enable github service for control panel bug report
services.github = {
enable = true;
token = "xxxxxxxxxxxxxxxxxxxx";
owner = "yyyyy";
repo = "zzzzzz";
};

storagevm = {
enable = true;
name = "guivm";
Expand Down Expand Up @@ -199,7 +213,9 @@ let
pkgs.eww
pkgs.wlr-randr
]
++ [ pkgs.ctrl-panel ]
++ [
pkgs.ctrl-panel
]
++ (lib.optional (
config.ghaf.profiles.debug.enable && config.ghaf.virtualization.microvm.idsvm.mitmproxy.enable
) pkgs.mitmweb-ui)
Expand All @@ -212,6 +228,7 @@ let
sessionVariables = {
XDG_PICTURES_DIR = "$HOME/Pictures";
XDG_VIDEOS_DIR = "$HOME/Videos";
GITHUB_CONFIG = "$HOME/.config/ctrl-panel/config.toml";
};
};

Expand Down

0 comments on commit 397a76a

Please sign in to comment.