Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ jobs:
fi
- name: Build the Modules for ${{ matrix.nixOpts.tag }}
run: nix -L flake check ${{ matrix.nixOpts.flag }}
- name: Build the NixOS installer for Nvidia Jetson Orin Nano devices
run: nix -L build .#packages.x86_64-linux.jetsonOrinNanoInstaller
- name: Upload the installer as artifact
uses: actions/upload-artifact@v6
with:
name: nvidia-jetson-orin-nano-nixos-${{ github.sha }}
path: result/iso/nixos-minimal-*.iso
retention-days: 7
if-no-files-found: error
- name: Export Nix Store
if: always()
run: |
Expand Down
36 changes: 18 additions & 18 deletions flake.lock

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

47 changes: 47 additions & 0 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# A `nixpkgs.lib` compatible lib must be provided.
{ lib }:

let
self = {
/**
Applies the function `fn` on the direct children directories of `dir`.
*/
mapDirs =
fn: dir:
let
dirs = builtins.map (name: fn (dir + "/${name}")) (
builtins.attrNames (lib.filterAttrs (_name: type: type == "directory") (builtins.readDir dir))
);
in
dirs;

/**
Given a directory where children are structured by vendors and *thing*,
returns an attribute set with combined `"${vendor}-${thing}"` names,
and values representing that subdirectory.
*/
getVendorsModules =
dir:
builtins.listToAttrs (
builtins.concatLists (
self.mapDirs (
vendorDir:
let
vendor = builtins.baseNameOf vendorDir;
in
self.mapDirs (
thingDir:
let
thing = builtins.baseNameOf thingDir;
in
{
name = "${vendor}-${thing}";
value = thingDir;
}
) vendorDir
) dir
)
);
};
in
self
1 change: 1 addition & 0 deletions modules/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
hardware = import ./hardware;
profiles = import ./profiles;
vms = import ./vms.nix;
}
5 changes: 5 additions & 0 deletions modules/hardware/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
imports = [
./devices
];
}
41 changes: 41 additions & 0 deletions modules/hardware/devices/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{ config, lib, ... }@moduleArgs:

let
cfg = config.ctrl-os.hardware;
inherit (import ../../../lib { inherit lib; })
getVendorsModules
;
deviceModules = getVendorsModules ./.;
devices = builtins.attrNames deviceModules;
in
{
options.ctrl-os.hardware.device = lib.mkOption {
type = with lib.types; nullOr (enum devices);
description = "Selects a hardware device profile to use by device name.";
default = null;
};

imports = builtins.attrValues (
builtins.mapAttrs (
device: dir:
let
cfgOrFn = import dir;
appliedConfig =
let
config = cfgOrFn moduleArgs;
in
if config ? config then config else { inherit config; };
cond = lib.mkIf (cfg.device == device);
in
if builtins.isAttrs cfgOrFn then
{
config = cond (cfgOrFn);
}
else
appliedConfig
// {
config = cond appliedConfig.config;
}
) deviceModules
);
}
12 changes: 12 additions & 0 deletions modules/hardware/devices/nvidia/jetson-orin-nano-super/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
nixpkgs.hostPlatform = "aarch64-linux";

boot.initrd.availableKernelModules = [
# Enable PCIe support at boot time
"phy_tegra194_p2u"
"pcie_tegra194"
# Enable USB support for USB Boot
"xhci-tegra"
"phy-tegra-xusb"
];
}
12 changes: 11 additions & 1 deletion packages/flakeModule.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ withSystem, inputs, ... }:
{
withSystem,
inputs,
self,
...
}:
{ }
//
inputs.nixpkgs.lib.optionalAttrs
Expand All @@ -20,6 +25,11 @@
perSystem =
{ pkgs, ... }:
{
legacyPackages = {
hardware = import ./hardware {
inherit pkgs self;
};
};
packages = import ./default.nix { inherit pkgs; };
};
}
Loading
Loading