Skip to content

Commit

Permalink
Modules: Define the basic module structure
Browse files Browse the repository at this point in the history
Signed-off-by: Brian McGillion <[email protected]>
  • Loading branch information
brianmcgillion committed Dec 10, 2023
1 parent dda6b6a commit d492808
Show file tree
Hide file tree
Showing 52 changed files with 410 additions and 257 deletions.
9 changes: 9 additions & 0 deletions TODO.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#+title: Todo

* List of tasks

** Refactoring
*** hardware/Nvidia
- Can this go upstream [[file:modules/hardware/nvidia-jetson-orin/pci-passthrough-agx-test.patch][passthrough patch]]
- Can this go upstream [[file:modules/hardware/nvidia-jetson-orin/pci-passthrough-nx-test.patch][nx passthrough]]
- Does format-module need to be exposed see comments in target.
8 changes: 2 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,14 @@
];

imports = [
./hydrajobs.nix
./modules
./nix
./packages
./targets
./hydrajobs.nix
./templates
];

#TODO Fix this
#flake.nixosModules = with lib;
# mapAttrs (_: import)
# (flattenTree (rakeLeaves ./modules));

flake.lib = lib;
};
}
18 changes: 18 additions & 0 deletions modules/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2022-2023 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
#
_: {
flake.nixosModules = {
development = import ./development;
framework = import ./framework;
graphics = import ./graphics;
hardware = import ./hardware;
host = import ./host;
installer = import ./installer;
profiles = import ./profiles;
programs = import ./programs;
users = import ./users;
virtualisation = import ./virtualization;
windows-launcher = import ./windows-launcher;
};
}
10 changes: 10 additions & 0 deletions modules/development/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2022-2023 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
_: {
imports = [
./debug-tools.nix
./nix.nix
./ssh.nix
./usb-serial.nix
];
}
1 change: 1 addition & 0 deletions modules/development/nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ in
enable = mkEnableOption "Target Nix config options";
};

# TODO setup the channels to properly support e.g. nix-shell and repl
config = mkIf cfg.enable {
nix.settings.experimental-features = ["nix-command" "flakes"];
nix.extraOptions = ''
Expand Down
8 changes: 8 additions & 0 deletions modules/framework/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2022-2023 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
_: {
imports = [
./version.nix
./launchers.nix
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
echo "${lib.ghaf-version}"
'';
in {
#TODO this has not module setup
environment.systemPackages = [
ghafVersion
];
Expand Down
10 changes: 8 additions & 2 deletions modules/graphics/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ in {
imports = [
./weston.nix
./labwc.nix
./weston.ini.nix
./fonts.nix
./gnome.nix
];

Expand All @@ -33,5 +31,13 @@ in {
ghaf.graphics.weston.enable = cfg.displayManager == "weston";
ghaf.graphics.gnome.enable = cfg.displayManager == "gnome";
ghaf.graphics.labwc.enable = cfg.displayManager == "labwc";

ghaf.graphics.fonts.packages = with pkgs; [
fira-code
hack-font
];

# Install a modern terminal
environment.systemPackages = [pkgs.kitty];
};
}
17 changes: 0 additions & 17 deletions modules/graphics/fonts.nix

This file was deleted.

88 changes: 0 additions & 88 deletions modules/graphics/weston.ini.nix

This file was deleted.

74 changes: 74 additions & 0 deletions modules/graphics/weston.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,62 @@
...
}: let
cfg = config.ghaf.graphics.weston;
mkLauncher = {
path,
icon,
}: ''
[launcher]
path=${path}
icon=${icon}
'';

#
# Generate launchers to be used in weston.ini
# Type: mkLaunchers :: [{path, icon}] -> string

mkLaunchers = lib.concatMapStrings mkLauncher;

defaultLauncher = [
# Keep weston-terminal launcher always enabled explicitly since if someone adds
# a launcher on the panel, the launcher will replace weston-terminal launcher.
{
path = "${pkgs.weston}/bin/weston-terminal";
icon = "${pkgs.weston}/share/weston/icon_terminal.png";
}
];
in {
imports = [
./window-manager.nix
];

options.ghaf.graphics.weston = {
enable = lib.mkEnableOption "weston";

launchers = mkOption {
description = "Weston application launchers to show in launch bar";
default = [];
type = with types;
listOf
(submodule {
options.path = mkOption {
description = "Path to the executable to be launched";
type = path;
};
options.icon = mkOption {
description = "Path of the icon";
type = path;
};
});
};

# TODO Is thus needed here as it is already in Graphics high level
enableDemoApplications = mkEnableOption "some applications for demoing";
};

config = lib.mkIf cfg.enable {
ghaf.graphics.window-manager-common.enable = true;
ghaf.graphics.weston.launchers = defaultLauncher;

environment.systemPackages = with pkgs; [
weston
Expand Down Expand Up @@ -73,5 +118,34 @@ in {
};
wantedBy = ["default.target"];
};

environment.etc."xdg/weston/weston.ini" = {
text =
''
# Disable screen locking
[core]
idle-time=0
[shell]
locking=false
background-image=${../../assets/wallpaper.png}
background-type=scale-crop
num-workspaces=2
# Set the keyboard layout for weston to US by default
[keyboard]
keymap_layout=us,fi
# Enable Hack font for weston-terminal
[terminal]
font=Hack
font-size=16
''
+ mkLaunchers cfg.launchers;

# The UNIX file mode bits
mode = "0644";
};
};
}
16 changes: 16 additions & 0 deletions modules/hardware/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2022-2023 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
_: {
imports = [
./definition.nix
./nvidia-jetson-orin
./polarfire
./x86_64-linux
];
# flake.nixosModules.hardware = {
# definition = import ./definition.nix;
# nvidia-jetson-orin = import ./nvidia-jetson-orin;
# polarfire = import ./polarfire;
# x86_64-linux = import ./x86_64-linux;
# };
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@
}: let
cfg = config.ghaf.hardware.nvidia.orin.agx;
in {
options.ghaf.hardware.nvidia.orin.agx.enableNetvmWlanPCIPassthrough =
lib.mkEnableOption
"WLAN card PCI passthrough to NetVM";
imports = [
./pci-passthrough-common.nix
];

options.ghaf.hardware.nvidia.orin.agx = {
enableNetvmWlanPCIPassthrough = lib.mkEnableOption "WLAN card PCI passthrough to NetVM";
};

config = lib.mkIf cfg.enableNetvmWlanPCIPassthrough {
# Orin AGX WLAN card PCI passthrough
#
# TODO this needs to be guarded behind a (! isHostOnly) for the Vm stuff
ghaf.hardware.nvidia.orin.enablePCIPassthroughCommon = true;

ghaf.virtualization.microvm.netvm.extraModules = [
Expand Down
12 changes: 5 additions & 7 deletions modules/hardware/nvidia-jetson-orin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
# Top-level module entry point for the Orin family of chips
{
imports = [
./partition-template.nix
../../boot/systemd-boot-dtb.nix
./jetson-orin.nix

./pci-passthrough-common.nix
#TODO do the pci pass throughs need to be exposed here
# They can be included in the Jetson-orin and the namespace
# will be available to the user
./agx-netvm-wlan-pci-passthrough.nix
./format-module.nix
./jetson-orin.nix
./nx-netvm-ethernet-pci-passthrough.nix

./ota-utils-fix.nix
];
}
14 changes: 13 additions & 1 deletion modules/hardware/nvidia-jetson-orin/format-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,21 @@
# nixos-generators flake input as an argument.
#
{
lib,
config,
...
}: let
cgf = config.ghaf.hardware.nvidia.orin;
in {
imports = [
./sdimage.nix
];

formatAttr = "sdImage";
# TODO this is default requirement
# so enabled at the top level of the orin being enabled

# TODO However, should this be exposed raw like this?
config = lib.mkIf cfg.enable {
formatAttr = "sdImage";
};
}
Loading

0 comments on commit d492808

Please sign in to comment.