Skip to content

Commit

Permalink
FMO-69: Update fmo-tool with DDP and DPF fixes
Browse files Browse the repository at this point in the history
- Create fmo-tool service for default config
- Add dynamic-device-passthrough and dynamic-portforwarding services
- Add fmo-tool package
- Add vhotplug package for dynamic-device-passthrough
- Add psk distribution service to dockervm

Signed-off-by: Anh Huy Bui <[email protected]>
  • Loading branch information
buianhhuy96 committed Oct 28, 2024
1 parent 924946c commit d9b45f9
Show file tree
Hide file tree
Showing 22 changed files with 593 additions and 53 deletions.
21 changes: 9 additions & 12 deletions config-processor-hardware.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
self,
lib,
ghafOS,
}: {
sysconf,
}:
}: sysconf:
let
inherit (import ./utils {inherit lib self ghafOS;}) updateAttrs updateHostConfig addCustomLaunchers addSystemPackages importvm;

targetconf = if lib.hasAttr "extend" sysconf
then updateAttrs false (import (lib.path.append ./hardware sysconf.extend) ).sysconf sysconf
else sysconf;
inherit (import ./utils {inherit lib self ghafOS;})
updateAttrs updateHostConfig addCustomLaunchers addSystemPackages importvm generateFMOToolConfig;

targetconf = sysconf;
name = targetconf.name;
system = "x86_64-linux";

Expand Down Expand Up @@ -47,10 +43,11 @@ let
];
}
]
++ (addCustomLaunchers targetconf.launchers)
++ (addSystemPackages targetconf.systemPackages)
++ (importvm targetconf.vms)
++ (updateHostConfig targetconf)
++ (addCustomLaunchers targetconf.launchers)
++ (addSystemPackages targetconf.systemPackages)
++ (importvm targetconf.vms)
++ (updateHostConfig targetconf)
++ (generateFMOToolConfig targetconf)
++ (if lib.hasAttr "extraModules" targetconf then targetconf.extraModules else []);
};
in {
Expand Down
9 changes: 2 additions & 7 deletions config-processor-installers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@
self,
lib,
ghafOS,
}: {
sysconf,
}:
}: sysconf:
let
inherit (import ./utils {inherit lib self ghafOS;}) updateAttrs addSystemPackages;

oss = sysconf.oss;
oss_list_name = "installer_os_list";
oss_list_path = "/etc/${oss_list_name}";

installerconf = if lib.hasAttr "extend" sysconf
then updateAttrs false (import (lib.path.append ./installers sysconf.extend) ).sysconf sysconf
else sysconf;

installerconf = sysconf;

installerApp = inst_app: let
installers = (builtins.removeAttrs inst_app ["name"]) //
Expand Down
31 changes: 17 additions & 14 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
outputs = inputs @ {ghafOS, self, ...}: let
# Retrieve inputs from Ghaf
nixpkgs = ghafOS.inputs.nixpkgs;
flake-utils = ghafOS.inputs.flake-utils;
flake-parts = ghafOS.inputs.flake-parts;
systems = with flake-utils.lib.system; [
x86_64-linux
];

lib = nixpkgs.lib.extend (final: _prev: {
ghaf = import "${ghafOS}/lib" {
Expand All @@ -34,10 +30,24 @@
};
});

hwConfigs = [
(import ./hardware/fmo-os-rugged-laptop-7330.nix)
(import ./hardware/fmo-os-rugged-laptop-7330-public.nix)
(import ./hardware/fmo-os-rugged-tablet-7230.nix)
(import ./hardware/fmo-os-rugged-tablet-7230-public.nix)
];
instConfigs = [
(import ./installers/fmo-os-installer.nix)
(import ./installers/fmo-os-installer-public.nix)
];
updateAttrs = (import ./utils/updateAttrs.nix).updateAttrs;
inheritConfig = confPath: { sysconf }: if lib.hasAttr "extend" sysconf
then updateAttrs false (import (lib.path.append confPath sysconf.extend) ).sysconf sysconf
else sysconf;
generateHwConfig = import ./config-processor-hardware.nix {inherit ghafOS self lib;};
generateInstConfig = import ./config-processor-installers.nix {inherit ghafOS self lib;};

in

flake-parts.lib.mkFlake
{
inherit inputs;
Expand All @@ -53,15 +63,8 @@
imports = [
./hydrajobs/flake-module.nix
./modules/flake-module.nix
] ++ map generateHwConfig [
(import ./hardware/fmo-os-rugged-laptop-7330.nix)
(import ./hardware/fmo-os-rugged-laptop-7330-public.nix)
(import ./hardware/fmo-os-rugged-tablet-7230.nix)
(import ./hardware/fmo-os-rugged-tablet-7230-public.nix)
] ++ map generateInstConfig [
(import ./installers/fmo-os-installer.nix)
(import ./installers/fmo-os-installer-public.nix)
];
] ++ map generateHwConfig (map (conf: inheritConfig ./hardware conf) hwConfigs)
++ map generateInstConfig (map (conf: inheritConfig ./installers conf) instConfigs);

flake.lib = lib;
};
Expand Down
59 changes: 54 additions & 5 deletions hardware/fmo-os-rugged-laptop-7330.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
name = "fmo-os-rugged-laptop-7330";
ipaddr = "192.168.101.2";
defaultgw = "192.168.101.1";
release = "v1.0.0a";

fmo-system = {
RAversion = "v0.8.4";
};

systemPackages = [
"vim"
Expand Down Expand Up @@ -36,8 +41,20 @@

services = {
fmo-psk-distribution-service-host = {
enable = true;
};
enable = true;
}; # fmo-psk-distribution-service-host
fmo-dynamic-portforwarding-service-host = {
enable = true;
config-paths = {
netvm = "/var/netvm/netconf/dpf.config";
};
}; # services.dynamic-portforwarding-service
fmo-dynamic-device-passthrough-service-host = {
enable = true;
}; # services.dynamic-device-passthrough-service-host
fmo-config = {
enable = true;
}; # services.fmo-config
registration-agent-laptop = {
enable = true;
}; # services.registration-agent-laptop
Expand Down Expand Up @@ -100,12 +117,13 @@

fmo-psk-distribution-service-vm = {
enable = true;
};
}; # services.fmo-psk-distribution-service-vm

portforwarding-service = {
dynamic-portforwarding-service = {
enable = true;
ipaddress = "192.168.100.12";
ipaddress-path = "/etc/NetworkManager/system-connections/ip-address";
config-path = "/etc/NetworkManager/system-connections/dpf.config";
configuration = [
{
dip = "192.168.101.11";
Expand Down Expand Up @@ -143,8 +161,20 @@
sport = "7423";
proto = "tcp";
}
{
dip = "192.168.101.11";
dport = "123";
sport = "123";
proto = "udp";
}
{
dip = "192.168.101.11";
dport = "123";
sport = "123";
proto = "tcp";
}
];
}; # services.portforwarding-service;
}; # services.dynamic-portforwarding-service
}; # services

microvm = {
Expand Down Expand Up @@ -287,13 +317,32 @@
proto = "virtiofs";
socket = "fogdata.sock";
}
{
tag = "ssh-public-key";
source = "/run/ssh-public-key";
mountPoint = "/run/ssh-public-key";
}
]; # microvm.shares
};# microvm
fileSystems."/run/ssh-public-key".options = ["ro"];
services = {
fmo-hostname-service = {
enable = true;
hostname-path = "/var/lib/fogdata/hostname";
}; # services.fmo-hostnam-service
fmo-psk-distribution-service-vm = {
enable = true;
}; # services.fmo-psk-distribution-service-vm
fmo-dynamic-device-passthrough = {
enable = true;
devices = [
{
bus = "usb";
vendorid = "1546";
productid = "01a9";
}
];
}; # services.fmo-dynamic-device-passthrough
fmo-dci = {
enable = true;
compose-path = "/var/lib/fogdata/docker-compose.yml";
Expand Down
55 changes: 52 additions & 3 deletions hardware/fmo-os-rugged-tablet-7230.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
name = "fmo-os-rugged-tablet-7230";
ipaddr = "192.168.101.2";
defaultgw = "192.168.101.1";
release = "v1.0.0a";

fmo-system = {
RAversion = "v0.8.4";
};

systemPackages = [
"vim"
Expand Down Expand Up @@ -36,8 +41,20 @@

services = {
fmo-psk-distribution-service-host = {
enable = true;
enable = true;
}; # services.fmo-psk-distribution-service-host
fmo-dynamic-portforwarding-service-host = {
enable = true;
config-paths = {
netvm = "/var/netvm/netconf/dpf.config";
};
}; # services.dynamic-portforwarding-service
fmo-dynamic-device-passthrough-service-host = {
enable = true;
}; # services.dynamic-device-passthrough-service-host
fmo-config = {
enable = true;
}; # services.fmo-config
registration-agent-laptop = {
enable = true;
}; # services.registration-agent-laptop
Expand Down Expand Up @@ -100,12 +117,13 @@

fmo-psk-distribution-service-vm = {
enable = true;
};
}; # services.fmo-psk-distribution-service-vm

portforwarding-service = {
dynamic-portforwarding-service = {
enable = true;
ipaddress = "192.168.100.12";
ipaddress-path = "/etc/NetworkManager/system-connections/ip-address";
config-path = "/etc/NetworkManager/system-connections/dpf.config";
configuration = [
{
dip = "192.168.101.11";
Expand Down Expand Up @@ -143,6 +161,18 @@
sport = "7423";
proto = "tcp";
}
{
dip = "192.168.101.11";
dport = "123";
sport = "123";
proto = "udp";
}
{
dip = "192.168.101.11";
dport = "123";
sport = "123";
proto = "tcp";
}
];
}; # services.portforwarding-service;
}; # services
Expand Down Expand Up @@ -268,13 +298,32 @@
proto = "virtiofs";
socket = "fogdata.sock";
}
{
tag = "ssh-public-key";
source = "/run/ssh-public-key";
mountPoint = "/run/ssh-public-key";
}
]; # microvm.shares
};# microvm
fileSystems."/run/ssh-public-key".options = ["ro"];
services = {
fmo-hostname-service = {
enable = true;
hostname-path = "/var/lib/fogdata/hostname";
}; # services.fmo-hostnam-service
fmo-psk-distribution-service-vm = {
enable = true;
}; # services.fmo-psk-distribution-service-vm
fmo-dynamic-device-passthrough = {
enable = true;
devices = [
{
bus = "usb";
vendorid = "1546";
productid = "01a9";
}
];
}; # services.fmo-dynamic-device-passthrough
fmo-dci = {
enable = true;
compose-path = "/var/lib/fogdata/docker-compose.yml";
Expand Down
24 changes: 17 additions & 7 deletions modules/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,28 @@
#
{inputs, ...}: {
flake.nixosModules = {
# Common fmo services/ultilities
fmo-common.imports = [
inputs.ghafOS.nixosModules.common
./packages
../utils/write-to-file
];

# fmo services/ultilities that runs only on host
fmo-host.imports = [
inputs.ghafOS.nixosModules.hw-x86_64-generic
inputs.ghafOS.nixosModules.host
inputs.ghafOS.nixosModules.desktop
./fmo-services/host-services.nix
./profiles/x86.nix
./desktop
];

# fmo services/ultilities that runs only on VMs
fmo-vm.imports = [
./fmo-services/vm-services.nix
];

microvm.imports = [
inputs.ghafOS.inputs.microvm.nixosModules.host
(import "${inputs.ghafOS}/modules/microvm/networking.nix")
Expand All @@ -20,14 +35,9 @@
# JIRA: FMO-43 for monitoring this issue.
(import "${inputs.ghafOS}/modules/microvm/virtualization/microvm/audiovm.nix")
];
fmo-common.imports = [
inputs.ghafOS.nixosModules.common
./packages
./fmo-services
../utils/write-to-file
];
installer.imports = [
./installers
./fmo-services/registration-agent-laptop
];
};
}
}
Loading

0 comments on commit d9b45f9

Please sign in to comment.