fix: Use usda-vision from flake inputs when loaded with athenix
This commit is contained in:
@@ -7,16 +7,16 @@ This guide shows how to properly integrate the usda-vision flake and usda-dash-c
|
|||||||
```
|
```
|
||||||
athenix/ (main flake)
|
athenix/ (main flake)
|
||||||
├── flake.nix
|
├── flake.nix
|
||||||
│ └── inputs.usda-vision (flake input)
|
│ ├── inputs.usda-vision (flake input)
|
||||||
|
│ └── inputs.ragenix (for secrets)
|
||||||
└── nixos-systems/
|
└── nixos-systems/
|
||||||
└── inventory.nix
|
└── inventory.nix
|
||||||
└── imports usda-dash-config/default.nix (external module)
|
└── imports default.nix (accesses inputs directly)
|
||||||
└── receives usda-vision packages as parameter
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Step 1: Add usda-vision as a flake input in athenix
|
## Step 1: Add required flake inputs in athenix
|
||||||
|
|
||||||
In your `~/athenix/flake.nix`, add usda-vision as an input:
|
In your `~/athenix/flake.nix`, add usda-vision and ragenix as inputs:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
@@ -27,58 +27,40 @@ In your `~/athenix/flake.nix`, add usda-vision as an input:
|
|||||||
|
|
||||||
# Add usda-vision flake
|
# Add usda-vision flake
|
||||||
usda-vision = {
|
usda-vision = {
|
||||||
url = "path:/path/to/usda-dash-config/usda-vision";
|
url = "git+https://git.factory.uga.edu/MODEL/usda-vision.git";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Ragenix for secrets management
|
||||||
|
ragenix = {
|
||||||
|
url = "github:yaxitech/ragenix";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Your other inputs...
|
# Your other inputs...
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, usda-vision, ... }: {
|
outputs = { self, nixpkgs, usda-vision, ragenix, ... }@inputs: {
|
||||||
# Your outputs...
|
# Your outputs...
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Step 2: Make packages available to NixOS modules
|
## Step 2: Pass inputs to NixOS modules
|
||||||
|
|
||||||
In your athenix flake outputs, ensure the usda-vision packages are available to your NixOS configurations. There are two approaches:
|
Make inputs available to all modules via specialArgs:
|
||||||
|
|
||||||
### Approach A: Using specialArgs (Recommended)
|
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
outputs = { self, nixpkgs, usda-vision, ... }: {
|
outputs = { self, nixpkgs, ... }@inputs: {
|
||||||
nixosConfigurations.usda-dash = nixpkgs.lib.nixosSystem {
|
nixosConfigurations.proxmox-usda-dash = nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
|
|
||||||
specialArgs = {
|
# Make inputs available to all modules
|
||||||
# Pass usda-vision packages to all modules
|
specialArgs = { inherit inputs; };
|
||||||
usda-vision-packages = usda-vision.packages.x86_64-linux;
|
|
||||||
};
|
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
# Your modules...
|
ragenix.nixosModules.default
|
||||||
];
|
./nixos-systems/inventory.nix
|
||||||
};
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Approach B: Using _module.args
|
|
||||||
|
|
||||||
```nix
|
|
||||||
outputs = { self, nixpkgs, usda-vision, ... }: {
|
|
||||||
nixosConfigurations.usda-dash = nixpkgs.lib.nixosSystem {
|
|
||||||
system = "x86_64-linux";
|
|
||||||
|
|
||||||
modules = [
|
|
||||||
# Make packages available as module args
|
|
||||||
{
|
|
||||||
_module.args = {
|
|
||||||
usda-vision-packages = usda-vision.packages.x86_64-linux;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
# Your other modules...
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -86,20 +68,20 @@ outputs = { self, nixpkgs, usda-vision, ... }: {
|
|||||||
|
|
||||||
## Step 3: Configure secrets with ragenix in athenix
|
## Step 3: Configure secrets with ragenix in athenix
|
||||||
|
|
||||||
Secrets are managed by ragenix in the athenix flake, not in this flake. Configure your secrets in athenix:
|
Secrets are managed by ragenix in the athenix flake:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
# In your athenix flake or secrets configuration
|
# In your athenix configuration (e.g., inventory.nix)
|
||||||
{
|
{
|
||||||
age.secrets.usda-vision-env = {
|
age.secrets.usda-vision-env = {
|
||||||
file = ./secrets/usda-vision/env.age; # Encrypted with ragenix in athenix
|
file = ./secrets/usda-vision/env.age;
|
||||||
mode = "0644";
|
mode = "0644";
|
||||||
owner = "root";
|
owner = "root";
|
||||||
group = "root";
|
group = "root";
|
||||||
};
|
};
|
||||||
|
|
||||||
age.secrets.usda-vision-azure-env = {
|
age.secrets.usda-vision-azure-env = {
|
||||||
file = ./secrets/usda-vision/azure-env.age; # Encrypted with ragenix in athenix
|
file = ./secrets/usda-vision/azure-env.age;
|
||||||
mode = "0644";
|
mode = "0644";
|
||||||
owner = "root";
|
owner = "root";
|
||||||
group = "root";
|
group = "root";
|
||||||
@@ -107,50 +89,43 @@ Secrets are managed by ragenix in the athenix flake, not in this flake. Configur
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Step 4: Import usda-dash-config in inventory.nix
|
## Step 4: Import usda-dash-config module
|
||||||
|
|
||||||
In your `nixos-systems/inventory.nix` (or wherever you import external modules):
|
Simply import the default.nix - it will access inputs and age secrets automatically:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ config, usda-vision-packages, ... }:
|
# In inventory.nix
|
||||||
|
{ config, inputs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
# Import the usda-dash-config module, passing packages and secret paths
|
# Just import directly - no parameters needed!
|
||||||
(import /path/to/usda-dash-config/default.nix {
|
/path/to/usda-dash-config/default.nix
|
||||||
inherit usda-vision-packages;
|
|
||||||
envFile = config.age.secrets.usda-vision-env.path;
|
|
||||||
azureEnvFile = config.age.secrets.usda-vision-azure-env.path;
|
|
||||||
})
|
|
||||||
|
|
||||||
# Your other imports...
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Configure secrets (shown above)
|
||||||
|
age.secrets.usda-vision-env = {
|
||||||
|
file = ./secrets/usda-vision/env.age;
|
||||||
|
mode = "0644";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Or if using nix-lxc devices pattern:
|
Or using fetchGit:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ config, usda-vision-packages, ... }:
|
{ config, inputs, ... }:
|
||||||
|
|
||||||
{
|
let
|
||||||
nix-lxc = {
|
usda-dash-config = builtins.fetchGit {
|
||||||
devices = {
|
url = "https://git.factory.uga.edu/MODEL/usda-dash-config.git";
|
||||||
"usda-dash" =
|
rev = "commit-hash";
|
||||||
let
|
|
||||||
usda-dash-config = builtins.fetchGit {
|
|
||||||
url = "https://git.factory.uga.edu/MODEL/usda-dash-config.git";
|
|
||||||
rev = "commit-hash";
|
|
||||||
submodules = true;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
import "${usda-dash-config}/default.nix" {
|
|
||||||
inherit usda-vision-packages;
|
|
||||||
envFile = config.age.secrets.usda-vision-env.path;
|
|
||||||
azureEnvFile = config.age.secrets.usda-vision-azure-env.path;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
"${usda-dash-config}/default.nix"
|
||||||
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -197,30 +172,24 @@ Here's a complete example of how it all fits together:
|
|||||||
### ~/athenix/nixos-systems/inventory.nix
|
### ~/athenix/nixos-systems/inventory.nix
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ config, pkgs, usda-vision-packages, ... }:
|
{ config, pkgs, inputs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
# Import usda-dash-config, passing the packages and secret file paths
|
# Simply import - it accesses inputs.usda-vision automatically
|
||||||
(import /home/engr-ugaif/usda-dash-config/default.nix {
|
/path/to/usda-dash-config/default.nix
|
||||||
inherit usda-vision-packages;
|
|
||||||
envFile = config.age.secrets.usda-vision-env.path;
|
|
||||||
azureEnvFile = config.age.secrets.usda-vision-azure-env.path;
|
|
||||||
})
|
|
||||||
];
|
];
|
||||||
|
|
||||||
# Configure secrets (managed by ragenix in athenix)
|
# Configure secrets (managed by ragenix in athenix)
|
||||||
age.secrets.usda-vision-env = {
|
age.secrets.usda-vision-env = {
|
||||||
file = ./secrets/usda-vision/env.age; # Store encrypted secrets in athenix
|
file = ./secrets/usda-vision/env.age;
|
||||||
mode = "0644";
|
mode = "0644";
|
||||||
};
|
};
|
||||||
|
|
||||||
age.secrets.usda-vision-azure-env = {
|
age.secrets.usda-vision-azure-env = {
|
||||||
file = ./secrets/usda-vision/azure-env.age; # Azure OAuth config
|
file = ./secrets/usda-vision/azure-env.age;
|
||||||
mode = "0644";
|
mode = "0644";
|
||||||
};
|
};
|
||||||
|
|
||||||
# The usda-dash services are now configured and will use the ragenix-managed secrets
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
86
default.nix
86
default.nix
@@ -1,69 +1,53 @@
|
|||||||
{ usda-vision-packages ? null
|
|
||||||
, envFile ? null
|
|
||||||
, azureEnvFile ? null
|
|
||||||
, ...
|
|
||||||
}:
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# USDA Dashboard External System Module
|
# USDA Dashboard External System Module
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# External system configuration for usda-dash
|
# External system configuration for usda-dash
|
||||||
# This module can be referenced from nixos-systems/inventory.nix using:
|
|
||||||
#
|
|
||||||
# nix-lxc = {
|
|
||||||
# devices = {
|
|
||||||
# "usda-dash" = builtins.fetchGit {
|
|
||||||
# url = "https://git.factory.uga.edu/MODEL/usda-dash-config.git";
|
|
||||||
# rev = "commit-hash";
|
|
||||||
# submodules = true; # REQUIRED for usda-vision submodule
|
|
||||||
# };
|
|
||||||
# };
|
|
||||||
# };
|
|
||||||
#
|
|
||||||
# IMPORTANT: For LXC containers running Docker, the Proxmox LXC must be configured with:
|
|
||||||
# - Features: nesting=1, keyctl=1
|
|
||||||
# - Unprivileged: no (or privileged: yes)
|
|
||||||
# Edit the container config in Proxmox: /etc/pve/lxc/<VMID>.conf
|
|
||||||
# Add: features: nesting=1,keyctl=1
|
|
||||||
#
|
#
|
||||||
# USAGE FROM ATHENIX:
|
# USAGE FROM ATHENIX:
|
||||||
#
|
#
|
||||||
# 1. Add usda-vision as a flake input in athenix/flake.nix:
|
# 1. Add required flake inputs in athenix/flake.nix:
|
||||||
#
|
#
|
||||||
# inputs.usda-vision = {
|
# inputs = {
|
||||||
# url = "path:/path/to/usda-dash-config/usda-vision";
|
# usda-vision = {
|
||||||
# inputs.nixpkgs.follows = "nixpkgs";
|
# url = "git+https://git.factory.uga.edu/MODEL/usda-vision.git";
|
||||||
|
# inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
# };
|
||||||
|
# ragenix = {
|
||||||
|
# url = "github:yaxitech/ragenix";
|
||||||
|
# inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
# };
|
||||||
# };
|
# };
|
||||||
#
|
#
|
||||||
# 2. In inventory.nix, pass the usda-vision packages and ragenix-managed secrets:
|
# 2. Pass inputs to modules via specialArgs:
|
||||||
#
|
#
|
||||||
# imports = [
|
# nixosConfigurations.proxmox-usda-dash = nixpkgs.lib.nixosSystem {
|
||||||
# (import /path/to/usda-dash-config/default.nix {
|
# specialArgs = { inherit inputs; };
|
||||||
# usda-vision-packages = inputs.usda-vision.packages.${system};
|
# modules = [
|
||||||
# envFile = config.age.secrets.usda-vision-env.path;
|
# ./path/to/usda-dash-config/default.nix
|
||||||
# azureEnvFile = config.age.secrets.usda-vision-azure-env.path;
|
# ];
|
||||||
# })
|
# };
|
||||||
# ];
|
#
|
||||||
|
# 3. Configure secrets in your athenix configuration:
|
||||||
|
#
|
||||||
|
# age.secrets.usda-vision-env = {
|
||||||
|
# file = ./secrets/usda-vision/env.age;
|
||||||
|
# };
|
||||||
|
|
||||||
{
|
{ config
|
||||||
config,
|
, lib
|
||||||
lib,
|
, pkgs
|
||||||
pkgs,
|
, inputs
|
||||||
...
|
, ...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
# Get packages from the parameter passed by athenix
|
# Get packages from flake inputs
|
||||||
# Fallback to local callPackage if not provided (for standalone testing)
|
camera-sdk = inputs.usda-vision.packages.${pkgs.system}.camera-sdk;
|
||||||
camera-sdk =
|
usda-vision-app = inputs.usda-vision.packages.${pkgs.system}.usda-vision;
|
||||||
if usda-vision-packages != null
|
|
||||||
then usda-vision-packages.camera-sdk
|
# Get secret paths from age configuration (if configured)
|
||||||
else pkgs.callPackage ./usda-vision/camera-sdk.nix {};
|
envFile = config.age.secrets.usda-vision-env.path or null;
|
||||||
|
azureEnvFile = config.age.secrets.usda-vision-azure-env.path or null;
|
||||||
usda-vision-app =
|
|
||||||
if usda-vision-packages != null
|
|
||||||
then usda-vision-packages.usda-vision
|
|
||||||
else pkgs.callPackage ./usda-vision/package.nix {};
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user