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)
|
||||
├── flake.nix
|
||||
│ └── inputs.usda-vision (flake input)
|
||||
│ ├── inputs.usda-vision (flake input)
|
||||
│ └── inputs.ragenix (for secrets)
|
||||
└── nixos-systems/
|
||||
└── inventory.nix
|
||||
└── imports usda-dash-config/default.nix (external module)
|
||||
└── receives usda-vision packages as parameter
|
||||
└── imports default.nix (accesses inputs directly)
|
||||
```
|
||||
|
||||
## 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
|
||||
{
|
||||
@@ -27,58 +27,40 @@ In your `~/athenix/flake.nix`, add usda-vision as an input:
|
||||
|
||||
# Add usda-vision flake
|
||||
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";
|
||||
};
|
||||
|
||||
# Your other inputs...
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, usda-vision, ... }: {
|
||||
outputs = { self, nixpkgs, usda-vision, ragenix, ... }@inputs: {
|
||||
# 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:
|
||||
|
||||
### Approach A: Using specialArgs (Recommended)
|
||||
Make inputs available to all modules via specialArgs:
|
||||
|
||||
```nix
|
||||
outputs = { self, nixpkgs, usda-vision, ... }: {
|
||||
nixosConfigurations.usda-dash = nixpkgs.lib.nixosSystem {
|
||||
outputs = { self, nixpkgs, ... }@inputs: {
|
||||
nixosConfigurations.proxmox-usda-dash = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
|
||||
specialArgs = {
|
||||
# Pass usda-vision packages to all modules
|
||||
usda-vision-packages = usda-vision.packages.x86_64-linux;
|
||||
};
|
||||
# Make inputs available to all modules
|
||||
specialArgs = { inherit inputs; };
|
||||
|
||||
modules = [
|
||||
# Your modules...
|
||||
];
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### 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...
|
||||
ragenix.nixosModules.default
|
||||
./nixos-systems/inventory.nix
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -86,20 +68,20 @@ outputs = { self, nixpkgs, usda-vision, ... }: {
|
||||
|
||||
## 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
|
||||
# In your athenix flake or secrets configuration
|
||||
# In your athenix configuration (e.g., inventory.nix)
|
||||
{
|
||||
age.secrets.usda-vision-env = {
|
||||
file = ./secrets/usda-vision/env.age; # Encrypted with ragenix in athenix
|
||||
file = ./secrets/usda-vision/env.age;
|
||||
mode = "0644";
|
||||
owner = "root";
|
||||
group = "root";
|
||||
};
|
||||
|
||||
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";
|
||||
owner = "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
|
||||
{ config, usda-vision-packages, ... }:
|
||||
# In inventory.nix
|
||||
{ config, inputs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
# Import the usda-dash-config module, passing packages and secret paths
|
||||
(import /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...
|
||||
# Just import directly - no parameters needed!
|
||||
/path/to/usda-dash-config/default.nix
|
||||
];
|
||||
|
||||
# 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
|
||||
{ config, usda-vision-packages, ... }:
|
||||
{ config, inputs, ... }:
|
||||
|
||||
{
|
||||
nix-lxc = {
|
||||
devices = {
|
||||
"usda-dash" =
|
||||
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;
|
||||
};
|
||||
};
|
||||
let
|
||||
usda-dash-config = builtins.fetchGit {
|
||||
url = "https://git.factory.uga.edu/MODEL/usda-dash-config.git";
|
||||
rev = "commit-hash";
|
||||
};
|
||||
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
|
||||
|
||||
```nix
|
||||
{ config, pkgs, usda-vision-packages, ... }:
|
||||
{ config, pkgs, inputs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
# Import usda-dash-config, passing the packages and secret file paths
|
||||
(import /home/engr-ugaif/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;
|
||||
})
|
||||
# Simply import - it accesses inputs.usda-vision automatically
|
||||
/path/to/usda-dash-config/default.nix
|
||||
];
|
||||
|
||||
# Configure secrets (managed by ragenix in athenix)
|
||||
age.secrets.usda-vision-env = {
|
||||
file = ./secrets/usda-vision/env.age; # Store encrypted secrets in athenix
|
||||
file = ./secrets/usda-vision/env.age;
|
||||
mode = "0644";
|
||||
};
|
||||
|
||||
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";
|
||||
};
|
||||
|
||||
# The usda-dash services are now configured and will use the ragenix-managed secrets
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user