Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FMO-81: Merge fmo-os images into fmo-os-x86_64 #92

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

buianhhuy96
Copy link
Collaborator

@buianhhuy96 buianhhuy96 commented Dec 9, 2024

  • Create x86_64-devices containing pci device map and rugged-devices.nix for pci info of rugged devices
  • Create systemd service to write pci device paths into config file for microvm
  • Map touch device in sway via a script
  • Clean up tablet and laptop config file
  • Build targets are:
    • fmo-os-x86_64-rugged-devices-debug / fmo-os-x86_64-rugged-devices-release
    • fmo-os-x86_64-public-rugged-devices-debug / fmo-os-x86_64-public-rugged-devices-release
    • fmo-os-installer-debug / fmo-os-installer-release
    • fmo-os-installer-public-debug / fmo-os-installer-public-releas

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably here we need to rename this file to show that it is related to Latitude 7230 Rugged Extreme Tablet and Latitude 7330 Rugged Extreme, otherwise it is too common name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I choose a general name is that: If we like to see FMO-OS as a general operating system, we can make it work that way by adding more devices manually, or even automatically using ghaf hardware-scan script.
For example, I'm thinking of a device called VM when I build it as a (QEMU) VM development target.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this exact configurations will work only on rugged devices, not for any x86, or any other. QEMU targets may be added here, due to they will be used for debug purposes for rugged devices. But if someone will add ARM-NVIDIA target where they will need to put it? If name is so general it looks like it should be put here.. But I think it would be better to put it to arm-nvidia-projectname-device-info.nix

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also it is a good idea to put device-info as folder (or subfolder of hardware folder), just to not mix different types of files

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can rename it into x86_64-device-info.nix or put it inside a folder like x86_64-device-info, which one would you suggest?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to use something like: hardware/device-info/fmo-os-rugged-devices.nix

Copy link
Collaborator Author

@buianhhuy96 buianhhuy96 Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I think I get where we misunderstood. The idea of mine was to create FMO-OS as a very general operating system, and completely independent of hardware. This device-info.nix is the only place where device becomes something related.
For example, I want to use FMO-OS on Lenovo X1 Carbon Gen 11, I add this into the file:

"LENOVO_MT_21HM_BU_Think_FM_ThinkPad X1 Carbon Gen 11 21HM006EMX" = {
touchDevices = [
];
pciDevices = {
netvm = [
"0000:00:14.3"
];
dockervm = [];
};
};

As long as the device is x86_64, which's indicated in the name fmo-os-x86_64.nix, it can run FMO-OS, fully functional. I tested on my X1 Carbon, would need more devices to confirm but for now, it works on all devices that I have

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FMO-OS it self is not general purpose system, as like GHAF, and even if it may be used so -- those build are pretty specific for FMO drone usage. If some one needs to make something different they probably need to rework pretty much of things: VMs, services, devices -- it would pretty different build with different build name and I would prefer to have it fully dedicated from rugged build

@@ -8,6 +8,8 @@
addSystemPackages = (packages: [({pkgs, ...}:{environment.systemPackages = map (app: pkgs.${app}) packages;})]);

addCustomLaunchers = (launchers: [{ghaf.graphics.app-launchers.enabled-launchers = launchers;}]);

addHardwareInfo = (deviceFile: [{device.hardwareInfo.configJson = builtins.toJSON (import ../hardware/${deviceFile});}]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How that will work if someone would wish to add a new target without device-info.nix or add devices by declaring them in hardware description file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that. But then I chose this because

  • for now, we only work on 2 devices.
  • Nix format is easier to manage than JSON format
    We may add more devices "statically" in device-info.nix before building. As you may know, this file is not really in the system; only its content is read as a string.

But if you prefer it to be a writable JSON file on the FMO system, I can make it work that way. Then, users can add new devices at their will.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It slightly not the same what I meant, I'm totally agree with nix approach instead of JSON, but will it work if I remove deviceFile = "device-info.nix"; from hardware description file?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just tried and it fails

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point, in that case, I think I can change the path to hardcoded path (import ../hardware/device-info.nix)

deviceFile = "device-info.nix"; lets us know the file name that inside hardware/ then append to ../hardware/device-info.nix

I did this just in case any other platform, not x86 would not be the same as x86

Copy link
Collaborator Author

@buianhhuy96 buianhhuy96 Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really get it, how can it make everything to be rewritten?
It only indicates which pci-devices to be passed through to which VM. Other VM's configuration is not related at all. The idea was that FMO can be understood as Windows OS, while device-info.nix is for example, wifi driver to be downloaded and installed.
We can make the device info to be imported implicitly to the system, therefore wouldn't need deviceFile in fmo-os-x86_64.nix

We put FMO-related configuration in the fmo-os-x86_64.nix
and hardware-specific (pci-devices) in device-info.nix

So unless we need to change the pci that's passed to this VM to other VM, the device-info.nix should not be touched at all.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I told you if we remove deviceFile = "device-info.nix"; from hardware description file it fails to build at all. Because now it has been made as mandatory field

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean I can rewrite it, to make it imported, implicitly. For example, by hardcoded the file path/name to the config.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then this implicit file need to have nothing. Can we just use default empty structure if user did not add deviceFile at all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rewrite it into a device in target name
For example, build
fmo-os-x86_64-rugged-devices-debug

then the part rugged-devices will indicate the which device(s) to be loaded along with FMO-OS.
And also, please check below comments because this code is outdated

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably that file also needs to be renamed to show relations to rugged devices

flake.nix Outdated
@@ -34,11 +34,12 @@
};
});

devices = {
rugged-devices = (import ./hardware/x86_64-devices/rugged-devices.nix);
Copy link
Collaborator Author

@buianhhuy96 buianhhuy96 Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add new devices here, and when we do that, there will be new targets for those devices

@@ -43,6 +44,7 @@ let
];
}
]
++ (addHardwareInfo devices.${device})
Copy link
Collaborator Author

@buianhhuy96 buianhhuy96 Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The device has now become a variable that is included in the target name.
See line 18 and 57 and commit message

- Create device-info folder containing pci device map and rugged-devices.nix for pci info of rugged devices
- Create systemd service to write pci device paths into config file for microvm
- Map touch device in sway via a script
- Clean up tablet and laptop config file
- Build targets are:
  + fmo-os-rugged-devices-debug / fmo-os-rugged-devices-release
  + fmo-os-rugged-devices-public-debug / fmo-os-rugged-devices-public-release
  + fmo-os-installer-debug / fmo-os-installer-release
  + fmo-os-installer-public-debug / fmo-os-installer-public-release

Signed-off-by: Anh Huy Bui <[email protected]>
Copy link
Collaborator

@jsvapiav jsvapiav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Ship it!

@buianhhuy96 buianhhuy96 merged commit 7e7ed91 into main Dec 12, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants