Compare commits
5 Commits
main
...
d39e9ee253
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d39e9ee253 | ||
|
|
6bf939a305 | ||
|
|
97358a6aee | ||
|
|
854882cbb9 | ||
|
|
acbc7518e8 |
@@ -26,23 +26,18 @@ jobs:
|
|||||||
format-check:
|
format-check:
|
||||||
name: Format Check
|
name: Format Check
|
||||||
runs-on: [self-hosted, nix-builder]
|
runs-on: [self-hosted, nix-builder]
|
||||||
timeout-minutes: 5
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
timeout-minutes: 3
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
nix fmt **/*.nix
|
||||||
echo "Checking code formatting..."
|
if ! git diff --quiet; then
|
||||||
output=$(nix fmt **/*.nix 2>&1)
|
|
||||||
if [ -n "$output" ]; then
|
|
||||||
echo "::error::Code is not formatted. Please run 'nix fmt **/*.nix' locally."
|
echo "::error::Code is not formatted. Please run 'nix fmt **/*.nix' locally."
|
||||||
echo "$output"
|
git diff
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "All files are properly formatted"
|
|
||||||
|
|
||||||
eval-configs:
|
eval-configs:
|
||||||
name: Evaluate Key Configurations
|
name: Evaluate Key Configurations
|
||||||
@@ -84,39 +79,3 @@ jobs:
|
|||||||
echo "Evaluating artifact ${{ matrix.artifact }}"
|
echo "Evaluating artifact ${{ matrix.artifact }}"
|
||||||
nix eval .#${{ matrix.artifact }}.drvPath \
|
nix eval .#${{ matrix.artifact }}.drvPath \
|
||||||
--show-trace
|
--show-trace
|
||||||
|
|
||||||
build-docs:
|
|
||||||
name: Build and Publish Documentation
|
|
||||||
runs-on: [self-hosted, nix-builder]
|
|
||||||
needs: [flake-check]
|
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Build documentation
|
|
||||||
run: |
|
|
||||||
echo "Building Athenix documentation"
|
|
||||||
nix build .#docs --print-build-logs
|
|
||||||
|
|
||||||
- name: Clone wiki repository
|
|
||||||
run: |
|
|
||||||
git clone git@factory.uga.edu:UGA-Innovation-Factory/athenix.wiki.git wiki
|
|
||||||
cd wiki
|
|
||||||
git config user.name "Athenix CI"
|
|
||||||
git config user.email "ci@athenix.factory.uga.edu"
|
|
||||||
|
|
||||||
- name: Update wiki with documentation
|
|
||||||
run: |
|
|
||||||
# Copy documentation to wiki
|
|
||||||
cp -r result/* wiki/
|
|
||||||
|
|
||||||
# Commit and push changes
|
|
||||||
cd wiki
|
|
||||||
git add .
|
|
||||||
if git diff --staged --quiet; then
|
|
||||||
echo "No documentation changes to commit"
|
|
||||||
else
|
|
||||||
git commit -m "Update documentation from commit ${{ github.sha }}"
|
|
||||||
git push
|
|
||||||
fi
|
|
||||||
|
|||||||
34
.github/workflows/docs.yml
vendored
34
.github/workflows/docs.yml
vendored
@@ -1,34 +0,0 @@
|
|||||||
name: Build Documentation
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-docs:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: DeterminateSystems/nix-installer-action@main
|
|
||||||
|
|
||||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
|
||||||
|
|
||||||
- name: Build documentation
|
|
||||||
run: |
|
|
||||||
nix build .#docs
|
|
||||||
nix build .#athenix-options
|
|
||||||
|
|
||||||
- name: Upload documentation
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: athenix-docs
|
|
||||||
path: result/
|
|
||||||
|
|
||||||
- name: Deploy to GitHub Pages
|
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
uses: peaceiris/actions-gh-pages@v4
|
|
||||||
with:
|
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
publish_dir: ./result
|
|
||||||
18
.nixd.json
18
.nixd.json
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"eval": {
|
|
||||||
"target": {
|
|
||||||
"installable": ".#nixosConfigurations.nix-desktop1.options"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"formatting": {
|
|
||||||
"command": ["nixfmt"]
|
|
||||||
},
|
|
||||||
"options": {
|
|
||||||
"nixos": {
|
|
||||||
"expr": "(builtins.getFlake \"/home/engr-ugaif/athenix\").nixosConfigurations.nix-desktop1.options"
|
|
||||||
},
|
|
||||||
"home-manager": {
|
|
||||||
"expr": "(builtins.getFlake \"/home/engr-ugaif/athenix\").nixosConfigurations.nix-desktop1.config.home-manager.users.engr-ugaif.options"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
57
flake.lock
generated
57
flake.lock
generated
@@ -239,24 +239,6 @@
|
|||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems_4"
|
"systems": "systems_4"
|
||||||
},
|
},
|
||||||
"locked": {
|
|
||||||
"lastModified": 1731533236,
|
|
||||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-utils_4": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems_5"
|
|
||||||
},
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681202837,
|
"lastModified": 1681202837,
|
||||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||||
@@ -654,7 +636,6 @@
|
|||||||
"nixos-wsl": "nixos-wsl",
|
"nixos-wsl": "nixos-wsl",
|
||||||
"nixpkgs": "nixpkgs_2",
|
"nixpkgs": "nixpkgs_2",
|
||||||
"nixpkgs-old-kernel": "nixpkgs-old-kernel",
|
"nixpkgs-old-kernel": "nixpkgs-old-kernel",
|
||||||
"usda-vision": "usda-vision",
|
|
||||||
"vscode-server": "vscode-server"
|
"vscode-server": "vscode-server"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -739,21 +720,6 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems_5": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"treefmt-nix": {
|
"treefmt-nix": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
@@ -776,30 +742,9 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"usda-vision": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils_3",
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1769814438,
|
|
||||||
"narHash": "sha256-DEZrmqpqbrd996W5p1r4GA1C8Jmo31n3N642ccS0deY=",
|
|
||||||
"ref": "refs/heads/main",
|
|
||||||
"rev": "78bfcf02612817a2cee1edbf92deeac9bf657613",
|
|
||||||
"revCount": 126,
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://git.factory.uga.edu/MODEL/usda-vision.git"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://git.factory.uga.edu/MODEL/usda-vision.git"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"vscode-server": {
|
"vscode-server": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils_4",
|
"flake-utils": "flake-utils_3",
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
]
|
]
|
||||||
|
|||||||
10
flake.nix
10
flake.nix
@@ -59,16 +59,10 @@
|
|||||||
url = "github:nix-community/NixOS-WSL/main";
|
url = "github:nix-community/NixOS-WSL/main";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
# USDA Vision Dashboard application
|
|
||||||
usda-vision = {
|
|
||||||
url = "git+https://git.factory.uga.edu/MODEL/usda-vision.git";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
inputs@{ self, flake-parts, ... }:
|
inputs@{ flake-parts, ... }:
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
# Support all common systems
|
# Support all common systems
|
||||||
systems = [
|
systems = [
|
||||||
@@ -86,10 +80,8 @@
|
|||||||
./parts/nixos-modules.nix
|
./parts/nixos-modules.nix
|
||||||
./parts/packages.nix
|
./parts/packages.nix
|
||||||
./parts/templates.nix
|
./parts/templates.nix
|
||||||
./parts/docs.nix
|
|
||||||
./inventory.nix
|
./inventory.nix
|
||||||
./users.nix
|
./users.nix
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,60 +5,44 @@
|
|||||||
# - Bootloader configuration (systemd-boot with Plymouth)
|
# - Bootloader configuration (systemd-boot with Plymouth)
|
||||||
# - Timezone and locale settings
|
# - Timezone and locale settings
|
||||||
# - Systemd sleep configuration
|
# - Systemd sleep configuration
|
||||||
#
|
|
||||||
# Only applies to:
|
|
||||||
# - Linux systems (not Darwin/macOS)
|
|
||||||
# - Systems with actual boot hardware (not containers/WSL)
|
|
||||||
|
|
||||||
|
{ config, lib, ... }:
|
||||||
{
|
{
|
||||||
config,
|
boot = {
|
||||||
lib,
|
loader.systemd-boot.enable = lib.mkDefault true;
|
||||||
pkgs,
|
loader.efi.canTouchEfiVariables = lib.mkDefault true;
|
||||||
...
|
plymouth.enable = lib.mkDefault true;
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
# Enable "Silent boot"
|
||||||
# Check if this is a bootable system (not container, not WSL)
|
consoleLogLevel = 3;
|
||||||
isBootable = !(config.boot.isContainer or false) && (pkgs.stdenv.isLinux);
|
initrd.verbose = false;
|
||||||
in
|
|
||||||
{
|
|
||||||
config = lib.mkIf isBootable {
|
|
||||||
boot = {
|
|
||||||
loader.systemd-boot.enable = lib.mkDefault true;
|
|
||||||
loader.efi.canTouchEfiVariables = lib.mkDefault true;
|
|
||||||
plymouth.enable = lib.mkDefault true;
|
|
||||||
|
|
||||||
# Enable "Silent boot"
|
# Hide the OS choice for bootloaders.
|
||||||
consoleLogLevel = 3;
|
# It's still possible to open the bootloader list by pressing any key
|
||||||
initrd.verbose = false;
|
# It will just not appear on screen unless a key is pressed
|
||||||
|
loader.timeout = lib.mkDefault 0;
|
||||||
# Hide the OS choice for bootloaders.
|
|
||||||
# It's still possible to open the bootloader list by pressing any key
|
|
||||||
# It will just not appear on screen unless a key is pressed
|
|
||||||
loader.timeout = lib.mkDefault 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Set your time zone.
|
|
||||||
time.timeZone = "America/New_York";
|
|
||||||
|
|
||||||
# Select internationalisation properties.
|
|
||||||
i18n.defaultLocale = "en_US.UTF-8";
|
|
||||||
|
|
||||||
i18n.extraLocaleSettings = {
|
|
||||||
LC_ADDRESS = "en_US.UTF-8";
|
|
||||||
LC_IDENTIFICATION = "en_US.UTF-8";
|
|
||||||
LC_MEASUREMENT = "en_US.UTF-8";
|
|
||||||
LC_MONETARY = "en_US.UTF-8";
|
|
||||||
LC_NAME = "en_US.UTF-8";
|
|
||||||
LC_NUMERIC = "en_US.UTF-8";
|
|
||||||
LC_PAPER = "en_US.UTF-8";
|
|
||||||
LC_TELEPHONE = "en_US.UTF-8";
|
|
||||||
LC_TIME = "en_US.UTF-8";
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.sleep.extraConfig = ''
|
|
||||||
SuspendState=freeze
|
|
||||||
HibernateDelaySec=2h
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Set your time zone.
|
||||||
|
time.timeZone = "America/New_York";
|
||||||
|
|
||||||
|
# Select internationalisation properties.
|
||||||
|
i18n.defaultLocale = "en_US.UTF-8";
|
||||||
|
|
||||||
|
i18n.extraLocaleSettings = {
|
||||||
|
LC_ADDRESS = "en_US.UTF-8";
|
||||||
|
LC_IDENTIFICATION = "en_US.UTF-8";
|
||||||
|
LC_MEASUREMENT = "en_US.UTF-8";
|
||||||
|
LC_MONETARY = "en_US.UTF-8";
|
||||||
|
LC_NAME = "en_US.UTF-8";
|
||||||
|
LC_NUMERIC = "en_US.UTF-8";
|
||||||
|
LC_PAPER = "en_US.UTF-8";
|
||||||
|
LC_TELEPHONE = "en_US.UTF-8";
|
||||||
|
LC_TIME = "en_US.UTF-8";
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.sleep.extraConfig = ''
|
||||||
|
SuspendState=freeze
|
||||||
|
HibernateDelaySec=2h
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
157
fleet/common.nix
157
fleet/common.nix
@@ -5,150 +5,19 @@
|
|||||||
# It is automatically imported by the fleet generator for every host.
|
# It is automatically imported by the fleet generator for every host.
|
||||||
|
|
||||||
{
|
{
|
||||||
|
inputs,
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
inputs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
|
||||||
# Import all hardware modules so they're available for enabling
|
|
||||||
hwTypes = import ../hw { inherit inputs; };
|
|
||||||
hwModules = lib.attrValues hwTypes;
|
|
||||||
|
|
||||||
# User account submodule definition
|
|
||||||
userSubmodule = lib.types.submodule {
|
|
||||||
options = {
|
|
||||||
enable = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Whether this user account is enabled on this system.";
|
|
||||||
};
|
|
||||||
isNormalUser = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
description = "Whether this is a normal user account (vs system user).";
|
|
||||||
};
|
|
||||||
description = lib.mkOption {
|
|
||||||
type = lib.types.nullOr lib.types.str;
|
|
||||||
default = null;
|
|
||||||
description = "Full name or description of the user (GECOS field).";
|
|
||||||
example = "John Doe";
|
|
||||||
};
|
|
||||||
extraGroups = lib.mkOption {
|
|
||||||
type = lib.types.listOf lib.types.str;
|
|
||||||
default = [ ];
|
|
||||||
description = "Additional groups for the user (wheel, docker, etc.).";
|
|
||||||
};
|
|
||||||
hashedPassword = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "!";
|
|
||||||
description = "Hashed password for the user account. Default '!' means locked.";
|
|
||||||
};
|
|
||||||
extraPackages = lib.mkOption {
|
|
||||||
type = lib.types.listOf lib.types.package;
|
|
||||||
default = [ ];
|
|
||||||
description = "Additional system packages available to this user.";
|
|
||||||
};
|
|
||||||
excludePackages = lib.mkOption {
|
|
||||||
type = lib.types.listOf lib.types.package;
|
|
||||||
default = [ ];
|
|
||||||
description = "System packages to exclude for this user.";
|
|
||||||
};
|
|
||||||
homePackages = lib.mkOption {
|
|
||||||
type = lib.types.listOf lib.types.package;
|
|
||||||
default = [ ];
|
|
||||||
description = "Packages to install in the user's home-manager profile.";
|
|
||||||
};
|
|
||||||
extraImports = lib.mkOption {
|
|
||||||
type = lib.types.listOf lib.types.path;
|
|
||||||
default = [ ];
|
|
||||||
description = "Additional home-manager modules to import for this user.";
|
|
||||||
};
|
|
||||||
external = lib.mkOption {
|
|
||||||
type = lib.types.nullOr (
|
|
||||||
lib.types.oneOf [
|
|
||||||
lib.types.path
|
|
||||||
(lib.types.submodule {
|
|
||||||
options = {
|
|
||||||
url = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Git repository URL to fetch user configuration from.";
|
|
||||||
};
|
|
||||||
rev = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Git commit hash, tag, or branch to fetch.";
|
|
||||||
};
|
|
||||||
submodules = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Whether to fetch Git submodules.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
})
|
|
||||||
]
|
|
||||||
);
|
|
||||||
default = null;
|
|
||||||
description = "External dotfiles repository (user.nix + optional nixos.nix).";
|
|
||||||
};
|
|
||||||
opensshKeys = lib.mkOption {
|
|
||||||
type = lib.types.listOf lib.types.str;
|
|
||||||
default = [ ];
|
|
||||||
description = "SSH public keys for the user (authorized_keys).";
|
|
||||||
};
|
|
||||||
shell = lib.mkOption {
|
|
||||||
type = lib.types.nullOr (
|
|
||||||
lib.types.enum [
|
|
||||||
"bash"
|
|
||||||
"zsh"
|
|
||||||
"fish"
|
|
||||||
"tcsh"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
default = "bash";
|
|
||||||
description = "Default shell for the user.";
|
|
||||||
};
|
|
||||||
editor = lib.mkOption {
|
|
||||||
type = lib.types.nullOr (
|
|
||||||
lib.types.enum [
|
|
||||||
"vim"
|
|
||||||
"neovim"
|
|
||||||
"emacs"
|
|
||||||
"nano"
|
|
||||||
"code"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
default = "neovim";
|
|
||||||
description = "Default text editor for the user (sets EDITOR).";
|
|
||||||
};
|
|
||||||
useZshTheme = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
description = "Whether to apply the system Zsh theme (Oh My Posh).";
|
|
||||||
};
|
|
||||||
useNvimPlugins = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
description = "Whether to apply the system Neovim configuration.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./fs.nix
|
./fs.nix
|
||||||
./boot.nix
|
./boot.nix
|
||||||
./user-config.nix
|
./user-config.nix
|
||||||
|
./fleet-option.nix
|
||||||
../sw
|
../sw
|
||||||
inputs.vscode-server.nixosModules.default
|
];
|
||||||
inputs.nixos-wsl.nixosModules.default
|
|
||||||
]
|
|
||||||
++ hwModules;
|
|
||||||
|
|
||||||
options.athenix.users = lib.mkOption {
|
|
||||||
type = lib.types.attrsOf userSubmodule;
|
|
||||||
default = { };
|
|
||||||
description = "User accounts configuration. Set enable=true for users that should exist on this system.";
|
|
||||||
};
|
|
||||||
|
|
||||||
options.athenix = {
|
options.athenix = {
|
||||||
forUser = lib.mkOption {
|
forUser = lib.mkOption {
|
||||||
@@ -156,28 +25,14 @@ in
|
|||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Convenience option to configure a host for a specific user.
|
Convenience option to configure a host for a specific user.
|
||||||
|
Automatically enables the user (sets athenix.users.username.enable = true).
|
||||||
When set, automatically:
|
Value should be a username from athenix.users.accounts.
|
||||||
- Enables the user account (athenix.users.<username>.enable = true)
|
|
||||||
- Sets as default WSL user (on WSL systems)
|
|
||||||
|
|
||||||
The username must exist in athenix.users (defined in users.nix).
|
|
||||||
'';
|
'';
|
||||||
example = "engr-ugaif";
|
|
||||||
};
|
};
|
||||||
host.useHostPrefix = lib.mkOption {
|
host.useHostPrefix = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = ''
|
description = "Whether to prepend the host prefix to the hostname (used in inventory and hosts/default.nix).";
|
||||||
Whether to prepend the hardware type prefix to the hostname.
|
|
||||||
|
|
||||||
When true:
|
|
||||||
- "nix-laptop" with device "1" → hostname "nix-laptop1"
|
|
||||||
- "nix-wsl" with device "alice" → hostname "nix-wsl-alice"
|
|
||||||
|
|
||||||
When false:
|
|
||||||
- Device name becomes the full hostname (useful for custom names)
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
inputs,
|
inputs,
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
self ? null,
|
|
||||||
users ? { },
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@@ -20,6 +18,8 @@ let
|
|||||||
# Import fleet-option.nix (defines athenix.fleet) and inventory.nix (sets values)
|
# Import fleet-option.nix (defines athenix.fleet) and inventory.nix (sets values)
|
||||||
# We use a minimal module here to avoid circular dependencies from common.nix's imports
|
# We use a minimal module here to avoid circular dependencies from common.nix's imports
|
||||||
|
|
||||||
|
hostTypes = config.athenix.hwTypes;
|
||||||
|
|
||||||
# Helper to create a single NixOS system configuration
|
# Helper to create a single NixOS system configuration
|
||||||
mkHost =
|
mkHost =
|
||||||
{
|
{
|
||||||
@@ -34,20 +34,8 @@ let
|
|||||||
externalModulePath =
|
externalModulePath =
|
||||||
if externalModuleThunk != null then
|
if externalModuleThunk != null then
|
||||||
let
|
let
|
||||||
# Force evaluation of the thunk
|
# Force evaluation of the thunk (fetchGit, fetchTarball, etc.)
|
||||||
fetchedPath =
|
fetchedPath = externalModuleThunk;
|
||||||
if
|
|
||||||
builtins.isAttrs externalModuleThunk
|
|
||||||
&& externalModuleThunk ? _type
|
|
||||||
&& externalModuleThunk._type == "lazy-fetchGit"
|
|
||||||
then
|
|
||||||
# New format: lazy fetchGit - only execute when needed
|
|
||||||
(builtins.fetchGit {
|
|
||||||
inherit (externalModuleThunk) url rev submodules;
|
|
||||||
}).outPath
|
|
||||||
else
|
|
||||||
# Legacy: pre-fetched derivation or path
|
|
||||||
externalModuleThunk;
|
|
||||||
# Extract outPath from fetchGit/fetchTarball results
|
# Extract outPath from fetchGit/fetchTarball results
|
||||||
extractedPath =
|
extractedPath =
|
||||||
if builtins.isAttrs fetchedPath && fetchedPath ? outPath then fetchedPath.outPath else fetchedPath;
|
if builtins.isAttrs fetchedPath && fetchedPath ? outPath then fetchedPath.outPath else fetchedPath;
|
||||||
@@ -71,19 +59,10 @@ let
|
|||||||
name: user:
|
name: user:
|
||||||
if (user ? external && user.external != null) then
|
if (user ? external && user.external != null) then
|
||||||
let
|
let
|
||||||
# Resolve external path (lazy fetchGit if needed)
|
|
||||||
externalPath =
|
externalPath =
|
||||||
if builtins.isAttrs user.external && user.external ? url && user.external ? rev then
|
if builtins.isAttrs user.external && user.external ? outPath then
|
||||||
# New format: lazy fetchGit
|
|
||||||
(builtins.fetchGit {
|
|
||||||
inherit (user.external) url rev;
|
|
||||||
submodules = user.external.submodules or false;
|
|
||||||
}).outPath
|
|
||||||
else if builtins.isAttrs user.external && user.external ? outPath then
|
|
||||||
# Legacy: pre-fetched
|
|
||||||
user.external.outPath
|
user.external.outPath
|
||||||
else
|
else
|
||||||
# Direct path
|
|
||||||
user.external;
|
user.external;
|
||||||
nixosModulePath = externalPath + "/nixos.nix";
|
nixosModulePath = externalPath + "/nixos.nix";
|
||||||
in
|
in
|
||||||
@@ -121,6 +100,11 @@ let
|
|||||||
}
|
}
|
||||||
) userNixosModulePaths;
|
) userNixosModulePaths;
|
||||||
|
|
||||||
|
# Get the host type module from the hostTypes attribute set
|
||||||
|
typeModule =
|
||||||
|
hostTypes.${hostType}
|
||||||
|
or (throw "Host type '${hostType}' not found. Available types: ${lib.concatStringsSep ", " (lib.attrNames hostTypes)}");
|
||||||
|
|
||||||
# External module from fetchGit/fetchurl
|
# External module from fetchGit/fetchurl
|
||||||
externalPathModule =
|
externalPathModule =
|
||||||
if externalModulePath != null then import externalModulePath { inherit inputs; } else { };
|
if externalModulePath != null then import externalModulePath { inherit inputs; } else { };
|
||||||
@@ -148,35 +132,20 @@ let
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Hardware-specific external modules
|
|
||||||
hwSpecificModules =
|
|
||||||
lib.optional (hostType == "nix-lxc")
|
|
||||||
"${inputs.nixpkgs.legacyPackages.${system}.path}/nixos/modules/virtualisation/proxmox-lxc.nix";
|
|
||||||
|
|
||||||
allModules =
|
allModules =
|
||||||
userNixosModules
|
userNixosModules
|
||||||
++ [
|
++ [
|
||||||
./common.nix
|
./common.nix
|
||||||
|
typeModule
|
||||||
overrideModule
|
overrideModule
|
||||||
{ networking.hostName = hostName; }
|
{ networking.hostName = hostName; }
|
||||||
# Set athenix.host.name for secrets and other modules to use
|
|
||||||
{ athenix.host.name = hostName; }
|
|
||||||
{
|
|
||||||
# Inject user definitions from flake-parts level
|
|
||||||
config.athenix.users = lib.mapAttrs (_: user: lib.mapAttrs (_: lib.mkDefault) user) users;
|
|
||||||
}
|
|
||||||
# Enable the appropriate hardware module based on hostType
|
|
||||||
{ config.athenix.hw.${hostType}.enable = lib.mkDefault true; }
|
|
||||||
]
|
]
|
||||||
++ hwSpecificModules
|
|
||||||
++ lib.optional (externalModulePath != null) externalPathModule;
|
++ lib.optional (externalModulePath != null) externalPathModule;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
system = lib.nixosSystem {
|
system = lib.nixosSystem {
|
||||||
inherit system;
|
inherit system;
|
||||||
specialArgs = {
|
specialArgs = { inherit inputs; };
|
||||||
inputs = if self != null then inputs // { inherit self; } else inputs;
|
|
||||||
};
|
|
||||||
modules = allModules;
|
modules = allModules;
|
||||||
};
|
};
|
||||||
modules = allModules;
|
modules = allModules;
|
||||||
@@ -188,6 +157,8 @@ let
|
|||||||
let
|
let
|
||||||
hostType = config.type or prefix;
|
hostType = config.type or prefix;
|
||||||
system = config.system or "x86_64-linux";
|
system = config.system or "x86_64-linux";
|
||||||
|
devices = config.devices or { };
|
||||||
|
hasCount = config ? count;
|
||||||
|
|
||||||
# Helper to generate hostname from prefix and suffix
|
# Helper to generate hostname from prefix and suffix
|
||||||
# Numbers get no dash: "nix-surface1", "nix-surface2"
|
# Numbers get no dash: "nix-surface1", "nix-surface2"
|
||||||
@@ -228,24 +199,8 @@ let
|
|||||||
# Check if deviceConfig has an 'external' field for lazy evaluation
|
# Check if deviceConfig has an 'external' field for lazy evaluation
|
||||||
hasExternalField = builtins.isAttrs deviceConfig && deviceConfig ? external;
|
hasExternalField = builtins.isAttrs deviceConfig && deviceConfig ? external;
|
||||||
|
|
||||||
# Extract external module spec (don't evaluate fetchGit yet!)
|
# Extract external module thunk if present (don't evaluate yet!)
|
||||||
externalModuleThunk =
|
externalModuleThunk = if hasExternalField then deviceConfig.external else null;
|
||||||
if hasExternalField then
|
|
||||||
let
|
|
||||||
ext = deviceConfig.external;
|
|
||||||
in
|
|
||||||
# New format: { url, rev, submodules? } - create lazy fetchGit thunk
|
|
||||||
if builtins.isAttrs ext && ext ? url && ext ? rev then
|
|
||||||
{
|
|
||||||
_type = "lazy-fetchGit";
|
|
||||||
inherit (ext) url rev;
|
|
||||||
submodules = ext.submodules or false;
|
|
||||||
}
|
|
||||||
# Legacy: pre-fetched or path
|
|
||||||
else
|
|
||||||
ext
|
|
||||||
else
|
|
||||||
null;
|
|
||||||
|
|
||||||
# Remove 'external' from config to avoid conflicts
|
# Remove 'external' from config to avoid conflicts
|
||||||
cleanDeviceConfig =
|
cleanDeviceConfig =
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Fleet Option Definition
|
# Fleet Option Definition
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# This module defines the athenix.fleet and athenix.hwTypes options.
|
# This module only defines the athenix.fleet option without any dependencies.
|
||||||
# Self-contained fleet management without dependencies on user configuration.
|
# Used by fleet/default.nix to evaluate inventory data without circular dependencies.
|
||||||
{ inputs, lib, ... }:
|
{ inputs, lib, ... }:
|
||||||
let
|
let
|
||||||
fleetDefinition = lib.mkOption {
|
fleetDefinition = lib.mkOption {
|
||||||
@@ -31,7 +31,7 @@ let
|
|||||||
lib.types.int
|
lib.types.int
|
||||||
(lib.types.attrsOf (
|
(lib.types.attrsOf (
|
||||||
lib.types.submodule (
|
lib.types.submodule (
|
||||||
{ ... }:
|
{ name, ... }:
|
||||||
{
|
{
|
||||||
freeformType = lib.types.attrs;
|
freeformType = lib.types.attrs;
|
||||||
}
|
}
|
||||||
@@ -59,118 +59,66 @@ let
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
# Submodule defining the structure of a user account
|
||||||
# Forward declaration for user options (full definition in user-config.nix)
|
|
||||||
# This allows users.nix to be evaluated at flake level
|
|
||||||
userSubmodule = lib.types.submodule {
|
userSubmodule = lib.types.submodule {
|
||||||
options = {
|
options = {
|
||||||
enable = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Whether this user account is enabled on this system.";
|
|
||||||
};
|
|
||||||
isNormalUser = lib.mkOption {
|
isNormalUser = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Whether this is a normal user account (vs system user).";
|
|
||||||
};
|
};
|
||||||
description = lib.mkOption {
|
description = lib.mkOption {
|
||||||
type = lib.types.nullOr lib.types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
default = null;
|
default = null;
|
||||||
description = "Full name or description of the user (GECOS field).";
|
|
||||||
example = "John Doe";
|
|
||||||
};
|
};
|
||||||
extraGroups = lib.mkOption {
|
extraGroups = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "Additional groups for the user (wheel, docker, etc.).";
|
|
||||||
example = [
|
|
||||||
"wheel"
|
|
||||||
"networkmanager"
|
|
||||||
"docker"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
hashedPassword = lib.mkOption {
|
hashedPassword = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "!";
|
default = "!";
|
||||||
description = ''
|
|
||||||
Hashed password for the user account.
|
|
||||||
Generate with: mkpasswd -m sha-512
|
|
||||||
Default "!" means account is locked (SSH key only).
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
extraPackages = lib.mkOption {
|
extraPackages = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.package;
|
type = lib.types.listOf lib.types.package;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "Additional system packages available to this user.";
|
|
||||||
example = lib.literalExpression "[ pkgs.vim pkgs.git ]";
|
|
||||||
};
|
};
|
||||||
excludePackages = lib.mkOption {
|
excludePackages = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.package;
|
type = lib.types.listOf lib.types.package;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "System packages to exclude for this user.";
|
|
||||||
};
|
};
|
||||||
homePackages = lib.mkOption {
|
homePackages = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.package;
|
type = lib.types.listOf lib.types.package;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "Packages to install in the user's home-manager profile.";
|
|
||||||
example = lib.literalExpression "[ pkgs.firefox pkgs.vscode ]";
|
|
||||||
};
|
};
|
||||||
extraImports = lib.mkOption {
|
extraImports = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.path;
|
type = lib.types.listOf lib.types.path;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "Additional home-manager modules to import for this user.";
|
|
||||||
};
|
};
|
||||||
external = lib.mkOption {
|
external = lib.mkOption {
|
||||||
type = lib.types.nullOr (
|
type = lib.types.nullOr (
|
||||||
lib.types.oneOf [
|
lib.types.oneOf [
|
||||||
lib.types.path
|
lib.types.path
|
||||||
(lib.types.submodule {
|
lib.types.package
|
||||||
options = {
|
lib.types.attrs
|
||||||
url = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Git repository URL to fetch user configuration from.";
|
|
||||||
example = "https://github.com/username/dotfiles";
|
|
||||||
};
|
|
||||||
rev = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "Git commit hash, tag, or branch to fetch.";
|
|
||||||
example = "abc123def456...";
|
|
||||||
};
|
|
||||||
submodules = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Whether to fetch Git submodules.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
})
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
External user configuration module from Git or local path.
|
External user configuration module. Can be:
|
||||||
|
- A path to a local module directory
|
||||||
|
- A fetchGit/fetchTarball result pointing to a repository
|
||||||
|
|
||||||
Can be either:
|
The external module can contain:
|
||||||
- A local path: /path/to/config
|
- user.nix (optional): Sets athenix.users.<name> options AND home-manager config
|
||||||
- A Git repository: { url = "..."; rev = "..."; submodules? = false; }
|
- nixos.nix (optional): System-level NixOS configuration
|
||||||
|
|
||||||
The Git repository is only fetched when the user is actually enabled.
|
Example: builtins.fetchGit { url = "https://github.com/user/dotfiles"; rev = "..."; }
|
||||||
|
|
||||||
Should contain user.nix (user options + home-manager config)
|
|
||||||
and optionally nixos.nix (system-level config).
|
|
||||||
'';
|
'';
|
||||||
example = lib.literalExpression ''
|
|
||||||
{
|
|
||||||
url = "https://github.com/username/dotfiles";
|
|
||||||
rev = "abc123def456789abcdef0123456789abcdef012";
|
|
||||||
submodules = false;
|
|
||||||
}'';
|
|
||||||
};
|
};
|
||||||
opensshKeys = lib.mkOption {
|
opensshKeys = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "SSH public keys for the user (authorized_keys).";
|
description = "List of SSH public keys for the user.";
|
||||||
example = [ "ssh-ed25519 AAAAC3Nza... user@host" ];
|
|
||||||
};
|
};
|
||||||
shell = lib.mkOption {
|
shell = lib.mkOption {
|
||||||
type = lib.types.nullOr (
|
type = lib.types.nullOr (
|
||||||
@@ -182,7 +130,7 @@ let
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
default = "bash";
|
default = "bash";
|
||||||
description = "Default shell for the user.";
|
description = "The shell for this user.";
|
||||||
};
|
};
|
||||||
editor = lib.mkOption {
|
editor = lib.mkOption {
|
||||||
type = lib.types.nullOr (
|
type = lib.types.nullOr (
|
||||||
@@ -195,18 +143,23 @@ let
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
default = "neovim";
|
default = "neovim";
|
||||||
description = "Default text editor for the user (sets EDITOR).";
|
description = "The default editor for this user.";
|
||||||
};
|
};
|
||||||
useZshTheme = lib.mkOption {
|
useZshTheme = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Whether to apply the system Zsh theme (Oh My Posh).";
|
description = "Whether to apply the system Zsh theme.";
|
||||||
};
|
};
|
||||||
useNvimPlugins = lib.mkOption {
|
useNvimPlugins = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Whether to apply the system Neovim configuration.";
|
description = "Whether to apply the system Neovim configuration.";
|
||||||
};
|
};
|
||||||
|
enable = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Whether this user account is enabled on this system.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
@@ -219,6 +172,7 @@ in
|
|||||||
};
|
};
|
||||||
users = lib.mkOption {
|
users = lib.mkOption {
|
||||||
type = lib.types.attrsOf userSubmodule;
|
type = lib.types.attrsOf userSubmodule;
|
||||||
|
default = { };
|
||||||
description = "User accounts configuration. Set enable=true for users that should exist on this system.";
|
description = "User accounts configuration. Set enable=true for users that should exist on this system.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
168
fleet/fs.nix
168
fleet/fs.nix
@@ -4,129 +4,87 @@
|
|||||||
# This module defines:
|
# This module defines:
|
||||||
# - Disko partition layout (EFI, swap, root)
|
# - Disko partition layout (EFI, swap, root)
|
||||||
# - Filesystem options (device, swap size)
|
# - Filesystem options (device, swap size)
|
||||||
#
|
|
||||||
# Only applies to systems with physical disk management needs
|
|
||||||
# (not containers, not WSL, not systems without a configured device)
|
|
||||||
|
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.athenix.host.filesystem;
|
|
||||||
# Only enable disk config if device is set and disko is enabled
|
|
||||||
hasDiskConfig = cfg.device != null && config.disko.enableConfig;
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
options.athenix = {
|
options.athenix = {
|
||||||
host = {
|
host.filesystem = {
|
||||||
name = lib.mkOption {
|
device = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
description = ''
|
default = null;
|
||||||
Fleet-assigned hostname for this system.
|
description = "The main disk device to use for installation.";
|
||||||
Used for secrets discovery and other host-specific configurations.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
filesystem = {
|
useSwap = lib.mkOption {
|
||||||
device = lib.mkOption {
|
type = lib.types.bool;
|
||||||
type = lib.types.nullOr lib.types.str;
|
default = true;
|
||||||
default = null;
|
description = "Whether to create and use a swap partition.";
|
||||||
description = ''
|
};
|
||||||
The main disk device to use for automated partitioning and installation.
|
swapSize = lib.mkOption {
|
||||||
|
type = lib.types.nullOr lib.types.str;
|
||||||
When set, enables disko for declarative disk management with:
|
default = null;
|
||||||
- 1GB EFI boot partition
|
description = "The size of the swap partition.";
|
||||||
- Optional swap partition (see swapSize)
|
|
||||||
- Root partition using remaining space
|
|
||||||
|
|
||||||
Leave null for systems that don't need disk partitioning (containers, WSL).
|
|
||||||
'';
|
|
||||||
example = "/dev/nvme0n1";
|
|
||||||
};
|
|
||||||
useSwap = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
description = ''
|
|
||||||
Whether to create and use a swap partition.
|
|
||||||
Disable for systems with ample RAM or SSDs where swap is undesirable.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
swapSize = lib.mkOption {
|
|
||||||
type = lib.types.nullOr lib.types.str;
|
|
||||||
default = null;
|
|
||||||
description = ''
|
|
||||||
Size of the swap partition (e.g., "16G", "32G").
|
|
||||||
|
|
||||||
Recommended sizes:
|
|
||||||
- 8-16GB for desktops with 16GB+ RAM
|
|
||||||
- 32GB for laptops (enables hibernation)
|
|
||||||
- Match RAM size for systems <8GB RAM
|
|
||||||
'';
|
|
||||||
example = "32G";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkMerge [
|
config = {
|
||||||
{
|
# ========== Disk Partitioning (Disko) ==========
|
||||||
# ========== Disk Partitioning (Disko) ==========
|
disko.enableConfig = lib.mkDefault (config.athenix.host.filesystem.device != null);
|
||||||
disko.enableConfig = lib.mkDefault (cfg.device != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
(lib.mkIf hasDiskConfig {
|
disko.devices = {
|
||||||
disko.devices = {
|
disk.main = {
|
||||||
disk.main = {
|
type = "disk";
|
||||||
type = "disk";
|
device = config.athenix.host.filesystem.device;
|
||||||
device = cfg.device;
|
content = {
|
||||||
content = {
|
type = "gpt";
|
||||||
type = "gpt";
|
partitions = {
|
||||||
partitions = {
|
# EFI System Partition
|
||||||
# EFI System Partition
|
ESP = {
|
||||||
ESP = {
|
name = "ESP";
|
||||||
name = "ESP";
|
label = "BOOT";
|
||||||
label = "BOOT";
|
size = "1G";
|
||||||
size = "1G";
|
type = "EF00";
|
||||||
type = "EF00";
|
content = {
|
||||||
content = {
|
type = "filesystem";
|
||||||
type = "filesystem";
|
format = "vfat";
|
||||||
format = "vfat";
|
mountpoint = "/boot";
|
||||||
mountpoint = "/boot";
|
mountOptions = [ "umask=0077" ];
|
||||||
mountOptions = [ "umask=0077" ];
|
extraArgs = [
|
||||||
extraArgs = [
|
"-n"
|
||||||
"-n"
|
"BOOT"
|
||||||
"BOOT"
|
];
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
# Swap Partition (size configurable per host)
|
# Swap Partition (size configurable per host)
|
||||||
swap = lib.mkIf cfg.useSwap {
|
swap = lib.mkIf config.athenix.host.filesystem.useSwap {
|
||||||
name = "swap";
|
name = "swap";
|
||||||
label = "swap";
|
label = "swap";
|
||||||
size = cfg.swapSize;
|
size = config.athenix.host.filesystem.swapSize;
|
||||||
content = {
|
content = {
|
||||||
type = "swap";
|
type = "swap";
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
# Root Partition (takes remaining space)
|
# Root Partition (takes remaining space)
|
||||||
root = {
|
root = {
|
||||||
name = "root";
|
name = "root";
|
||||||
label = "root";
|
label = "root";
|
||||||
size = "100%";
|
size = "100%";
|
||||||
content = {
|
content = {
|
||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
format = "ext4";
|
format = "ext4";
|
||||||
mountpoint = "/";
|
mountpoint = "/";
|
||||||
extraArgs = [
|
extraArgs = [
|
||||||
"-L"
|
"-L"
|
||||||
"ROOT"
|
"ROOT"
|
||||||
];
|
];
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
})
|
};
|
||||||
];
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,25 +9,18 @@
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
# User Configuration Module
|
# User Configuration Module
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# This module implements user account creation and home-manager setup.
|
# This module defines the schema for user accounts and handles their creation.
|
||||||
# Options are defined in fleet-option.nix for early availability.
|
# It bridges the gap between the data in 'users.nix' and the actual NixOS
|
||||||
|
# and Home Manager configuration.
|
||||||
|
|
||||||
let
|
let
|
||||||
# Helper: Resolve external module path (with lazy Git fetching)
|
# Helper: Resolve external module path from fetchGit/fetchTarball/path
|
||||||
resolveExternalPath =
|
resolveExternalPath =
|
||||||
external:
|
external:
|
||||||
if external == null then
|
if external == null then
|
||||||
null
|
null
|
||||||
# New format: { url, rev, submodules? } - only fetch when needed
|
|
||||||
else if builtins.isAttrs external && external ? url && external ? rev then
|
|
||||||
(builtins.fetchGit {
|
|
||||||
inherit (external) url rev;
|
|
||||||
submodules = external.submodules or false;
|
|
||||||
}).outPath
|
|
||||||
# Legacy: pre-fetched derivation/package
|
|
||||||
else if builtins.isAttrs external && external ? outPath then
|
else if builtins.isAttrs external && external ? outPath then
|
||||||
external.outPath
|
external.outPath
|
||||||
# Direct path
|
|
||||||
else
|
else
|
||||||
external;
|
external;
|
||||||
|
|
||||||
@@ -40,7 +33,6 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
|
|
||||||
# Generate NixOS users
|
# Generate NixOS users
|
||||||
users.users =
|
users.users =
|
||||||
let
|
let
|
||||||
@@ -60,15 +52,23 @@ in
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
isNormalUser = user.isNormalUser;
|
inherit (user) isNormalUser extraGroups hashedPassword;
|
||||||
inherit (user) extraGroups hashedPassword;
|
|
||||||
description = if user.description != null then user.description else lib.mkDefault "";
|
description = if user.description != null then user.description else lib.mkDefault "";
|
||||||
openssh.authorizedKeys.keys = user.opensshKeys;
|
openssh.authorizedKeys.keys = user.opensshKeys;
|
||||||
shell = if user.shell != null then shells.${user.shell} else pkgs.bash;
|
shell = if user.shell != null then shells.${user.shell} else pkgs.bash;
|
||||||
packages = finalPackages ++ [ shell ];
|
packages = finalPackages ++ [ shell ];
|
||||||
|
group = if user.isNormalUser then name else lib.mkDefault "root";
|
||||||
}
|
}
|
||||||
) enabledAccounts;
|
) enabledAccounts;
|
||||||
|
|
||||||
|
# Generate user groups for normal users
|
||||||
|
users.groups =
|
||||||
|
let
|
||||||
|
enabledAccounts = lib.filterAttrs (_: user: user.enable) config.athenix.users;
|
||||||
|
normalUsers = lib.filterAttrs (_: user: user.isNormalUser) enabledAccounts;
|
||||||
|
in
|
||||||
|
lib.mapAttrs (_: _: { }) normalUsers;
|
||||||
|
|
||||||
# Home Manager configs per user
|
# Home Manager configs per user
|
||||||
home-manager = {
|
home-manager = {
|
||||||
useGlobalPkgs = true;
|
useGlobalPkgs = true;
|
||||||
@@ -133,7 +133,7 @@ in
|
|||||||
|
|
||||||
# Always set these required options
|
# Always set these required options
|
||||||
home.username = name;
|
home.username = name;
|
||||||
home.homeDirectory = lib.mkOverride 999 (if name == "root" then "/root" else "/home/${name}");
|
home.homeDirectory = if name == "root" then "/root" else "/home/${name}";
|
||||||
home.stateVersion = "25.11";
|
home.stateVersion = "25.11";
|
||||||
programs.${user.editor} = {
|
programs.${user.editor} = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|||||||
@@ -10,64 +10,41 @@
|
|||||||
modulesPath,
|
modulesPath,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.athenix.hw.nix-desktop;
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
options.athenix.hw.nix-desktop = mkOption {
|
# ========== Boot Configuration ==========
|
||||||
type = types.submodule {
|
|
||||||
options = {
|
|
||||||
enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable desktop workstation hardware configuration.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
default = { };
|
|
||||||
description = "Desktop workstation hardware type configuration.";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
boot.initrd.availableKernelModules = [
|
||||||
|
"xhci_pci" # USB 3.0 support
|
||||||
|
"nvme" # NVMe SSD support
|
||||||
|
"usb_storage" # USB storage devices
|
||||||
|
"sd_mod" # SD card support
|
||||||
|
"sdhci_pci" # SD card host controller
|
||||||
|
];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
boot.kernelParams = [
|
||||||
|
"quiet" # Minimal boot messages
|
||||||
|
"splash" # Show Plymouth boot splash
|
||||||
|
"boot.shell_on_fail" # Emergency shell on boot failure
|
||||||
|
"udev.log_priority=3" # Reduce udev logging
|
||||||
|
"rd.systemd.show_status=auto" # Show systemd status during boot
|
||||||
|
];
|
||||||
|
|
||||||
# ========== Boot Configuration ==========
|
# ========== Filesystem Configuration ==========
|
||||||
|
athenix.host.filesystem.swapSize = lib.mkDefault "16G";
|
||||||
|
athenix.host.filesystem.device = lib.mkDefault "/dev/nvme0n1";
|
||||||
|
athenix.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
||||||
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [
|
# ========== Hardware Configuration ==========
|
||||||
"xhci_pci" # USB 3.0 support
|
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
"nvme" # NVMe SSD support
|
|
||||||
"usb_storage" # USB storage devices
|
|
||||||
"sd_mod" # SD card support
|
|
||||||
"sdhci_pci" # SD card host controller
|
|
||||||
];
|
|
||||||
boot.initrd.kernelModules = [ ];
|
|
||||||
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
|
||||||
boot.extraModulePackages = [ ];
|
|
||||||
boot.kernelParams = [
|
|
||||||
"quiet" # Minimal boot messages
|
|
||||||
"splash" # Show Plymouth boot splash
|
|
||||||
"boot.shell_on_fail" # Emergency shell on boot failure
|
|
||||||
"udev.log_priority=3" # Reduce udev logging
|
|
||||||
"rd.systemd.show_status=auto" # Show systemd status during boot
|
|
||||||
];
|
|
||||||
|
|
||||||
# ========== Filesystem Configuration ==========
|
# ========== Software Profile ==========
|
||||||
athenix.host.filesystem.swapSize = lib.mkDefault "16G";
|
athenix.sw.enable = lib.mkDefault true;
|
||||||
athenix.host.filesystem.device = lib.mkDefault "/dev/nvme0n1";
|
athenix.sw.type = lib.mkDefault "desktop";
|
||||||
athenix.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
|
||||||
|
|
||||||
# ========== Hardware Configuration ==========
|
|
||||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
|
||||||
|
|
||||||
# ========== Software Profile ==========
|
|
||||||
athenix.sw.enable = lib.mkDefault true;
|
|
||||||
athenix.sw.desktop.enable = lib.mkDefault true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,78 +11,56 @@
|
|||||||
modulesPath,
|
modulesPath,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.athenix.hw.nix-ephemeral;
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
options.athenix.hw.nix-ephemeral = mkOption {
|
# ========== Boot Configuration ==========
|
||||||
type = types.submodule {
|
boot.initrd.availableKernelModules = [
|
||||||
options = {
|
"xhci_pci" # USB 3.0 support
|
||||||
enable = mkOption {
|
"nvme" # NVMe support
|
||||||
type = types.bool;
|
"usb_storage" # USB storage devices
|
||||||
default = false;
|
"sd_mod" # SD card support
|
||||||
description = "Enable ephemeral/diskless system hardware configuration.";
|
"sdhci_pci" # SD card host controller
|
||||||
};
|
];
|
||||||
};
|
boot.initrd.kernelModules = [ ];
|
||||||
};
|
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
||||||
default = { };
|
boot.extraModulePackages = [ ];
|
||||||
description = "Ephemeral hardware type configuration.";
|
boot.kernelParams = [
|
||||||
|
"quiet" # Minimal boot messages
|
||||||
|
"splash" # Show Plymouth boot splash
|
||||||
|
"boot.shell_on_fail" # Emergency shell on boot failure
|
||||||
|
"udev.log_priority=3" # Reduce udev logging
|
||||||
|
"rd.systemd.show_status=auto" # Show systemd status during boot
|
||||||
|
];
|
||||||
|
|
||||||
|
# ========== Ephemeral Configuration ==========
|
||||||
|
# No persistent storage - everything runs from RAM
|
||||||
|
athenix.host.filesystem.swapSize = lib.mkForce "0G";
|
||||||
|
athenix.host.filesystem.device = lib.mkForce "/dev/null"; # Dummy device
|
||||||
|
athenix.host.buildMethods = lib.mkDefault [
|
||||||
|
"iso" # Live ISO image
|
||||||
|
"ipxe" # Network boot
|
||||||
|
];
|
||||||
|
|
||||||
|
# Disable disk management for RAM-only systems
|
||||||
|
disko.enableConfig = lib.mkForce false;
|
||||||
|
|
||||||
|
# Define tmpfs root filesystem
|
||||||
|
fileSystems."/" = {
|
||||||
|
device = "none";
|
||||||
|
fsType = "tmpfs";
|
||||||
|
options = [
|
||||||
|
"defaults"
|
||||||
|
"size=50%"
|
||||||
|
"mode=755"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
# ========== Boot Configuration ==========
|
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
boot.initrd.availableKernelModules = [
|
|
||||||
"xhci_pci" # USB 3.0 support
|
|
||||||
"nvme" # NVMe support
|
|
||||||
"usb_storage" # USB storage devices
|
|
||||||
"sd_mod" # SD card support
|
|
||||||
"sdhci_pci" # SD card host controller
|
|
||||||
];
|
|
||||||
boot.initrd.kernelModules = [ ];
|
|
||||||
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
|
||||||
boot.extraModulePackages = [ ];
|
|
||||||
boot.kernelParams = [
|
|
||||||
"quiet" # Minimal boot messages
|
|
||||||
"splash" # Show Plymouth boot splash
|
|
||||||
"boot.shell_on_fail" # Emergency shell on boot failure
|
|
||||||
"udev.log_priority=3" # Reduce udev logging
|
|
||||||
"rd.systemd.show_status=auto" # Show systemd status during boot
|
|
||||||
];
|
|
||||||
|
|
||||||
# ========== Ephemeral Configuration ==========
|
athenix.sw.enable = lib.mkDefault true;
|
||||||
# No persistent storage - everything runs from RAM
|
athenix.sw.type = lib.mkDefault "stateless-kiosk";
|
||||||
athenix.host.filesystem.swapSize = lib.mkForce "0G";
|
|
||||||
athenix.host.filesystem.device = lib.mkForce "/dev/null"; # Dummy device
|
|
||||||
athenix.host.buildMethods = lib.mkDefault [
|
|
||||||
"iso" # Live ISO image
|
|
||||||
"ipxe" # Network boot
|
|
||||||
];
|
|
||||||
|
|
||||||
# Disable disk management for RAM-only systems
|
|
||||||
disko.enableConfig = lib.mkForce false;
|
|
||||||
|
|
||||||
# Define tmpfs root filesystem
|
|
||||||
fileSystems."/" = {
|
|
||||||
device = "none";
|
|
||||||
fsType = "tmpfs";
|
|
||||||
options = [
|
|
||||||
"defaults"
|
|
||||||
"size=50%"
|
|
||||||
"mode=755"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
|
||||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
|
||||||
|
|
||||||
athenix.sw.enable = lib.mkDefault true;
|
|
||||||
athenix.sw.stateless-kiosk.enable = lib.mkDefault true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,76 +10,54 @@
|
|||||||
modulesPath,
|
modulesPath,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.athenix.hw.nix-laptop;
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
options.athenix.hw.nix-laptop = mkOption {
|
# ========== Boot Configuration ==========
|
||||||
type = types.submodule {
|
|
||||||
options = {
|
boot.initrd.availableKernelModules = [
|
||||||
enable = mkOption {
|
"xhci_pci" # USB 3.0 support
|
||||||
type = types.bool;
|
"thunderbolt" # Thunderbolt support
|
||||||
default = false;
|
"nvme" # NVMe SSD support
|
||||||
description = "Enable laptop hardware configuration with power management.";
|
"usb_storage" # USB storage devices
|
||||||
};
|
"sd_mod" # SD card support
|
||||||
};
|
"sdhci_pci" # SD card host controller
|
||||||
|
];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
boot.kernelParams = [
|
||||||
|
"quiet" # Minimal boot messages
|
||||||
|
"splash" # Show Plymouth boot splash
|
||||||
|
"boot.shell_on_fail" # Emergency shell on boot failure
|
||||||
|
"udev.log_priority=3" # Reduce udev logging
|
||||||
|
"rd.systemd.show_status=auto" # Show systemd status during boot
|
||||||
|
"i915.enable_psr=0" # Disable Panel Self Refresh (stability)
|
||||||
|
"i915.enable_dc=0" # Disable display power saving
|
||||||
|
"i915.enable_fbc=0" # Disable framebuffer compression
|
||||||
|
];
|
||||||
|
|
||||||
|
# ========== Hardware Configuration ==========
|
||||||
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
|
|
||||||
|
# ========== Filesystem Configuration ==========
|
||||||
|
athenix.host.filesystem.device = lib.mkDefault "/dev/nvme0n1";
|
||||||
|
athenix.host.filesystem.swapSize = lib.mkDefault "34G"; # Larger swap for hibernation
|
||||||
|
athenix.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
||||||
|
|
||||||
|
# ========== Power Management ==========
|
||||||
|
services.upower.enable = lib.mkDefault true;
|
||||||
|
services.logind.settings = {
|
||||||
|
Login = {
|
||||||
|
HandleLidSwitch = "suspend";
|
||||||
|
HandleLidSwitchExternalPower = "suspend";
|
||||||
|
HandleLidSwitchDocked = "ignore";
|
||||||
};
|
};
|
||||||
default = { };
|
|
||||||
description = "Laptop hardware type configuration.";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
athenix.sw.enable = lib.mkDefault true;
|
||||||
# ========== Boot Configuration ==========
|
athenix.sw.type = lib.mkDefault "desktop";
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [
|
|
||||||
"xhci_pci" # USB 3.0 support
|
|
||||||
"thunderbolt" # Thunderbolt support
|
|
||||||
"nvme" # NVMe SSD support
|
|
||||||
"usb_storage" # USB storage devices
|
|
||||||
"sd_mod" # SD card support
|
|
||||||
"sdhci_pci" # SD card host controller
|
|
||||||
];
|
|
||||||
boot.initrd.kernelModules = [ ];
|
|
||||||
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
|
||||||
boot.extraModulePackages = [ ];
|
|
||||||
boot.kernelParams = [
|
|
||||||
"quiet" # Minimal boot messages
|
|
||||||
"splash" # Show Plymouth boot splash
|
|
||||||
"boot.shell_on_fail" # Emergency shell on boot failure
|
|
||||||
"udev.log_priority=3" # Reduce udev logging
|
|
||||||
"rd.systemd.show_status=auto" # Show systemd status during boot
|
|
||||||
"i915.enable_psr=0" # Disable Panel Self Refresh (stability)
|
|
||||||
"i915.enable_dc=0" # Disable display power saving
|
|
||||||
"i915.enable_fbc=0" # Disable framebuffer compression
|
|
||||||
];
|
|
||||||
|
|
||||||
# ========== Hardware Configuration ==========
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
|
||||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
|
||||||
|
|
||||||
# ========== Filesystem Configuration ==========
|
|
||||||
athenix.host.filesystem.device = lib.mkDefault "/dev/nvme0n1";
|
|
||||||
athenix.host.filesystem.swapSize = lib.mkDefault "34G"; # Larger swap for hibernation
|
|
||||||
athenix.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
|
||||||
|
|
||||||
# ========== Power Management ==========
|
|
||||||
services.upower.enable = lib.mkDefault true;
|
|
||||||
services.logind.settings = {
|
|
||||||
Login = {
|
|
||||||
HandleLidSwitch = "suspend";
|
|
||||||
HandleLidSwitchExternalPower = "suspend";
|
|
||||||
HandleLidSwitchDocked = "ignore";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
athenix.sw.enable = lib.mkDefault true;
|
|
||||||
athenix.sw.desktop.enable = lib.mkDefault true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
100
hw/nix-lxc.nix
100
hw/nix-lxc.nix
@@ -7,73 +7,55 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
modulesPath,
|
||||||
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.athenix.hw.nix-lxc;
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
options.athenix.hw.nix-lxc = mkOption {
|
imports = [
|
||||||
type = types.submodule {
|
inputs.vscode-server.nixosModules.default
|
||||||
options = {
|
"${modulesPath}/virtualisation/proxmox-lxc.nix"
|
||||||
enable = mkOption {
|
];
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable Proxmox LXC container hardware configuration.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
default = { };
|
|
||||||
description = "Proxmox LXC hardware type configuration.";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
# ========== Nix Configuration ==========
|
||||||
# ========== Nix Configuration ==========
|
nix.settings.trusted-users = [
|
||||||
nix.settings.trusted-users = [
|
"root"
|
||||||
"root"
|
"engr-ugaif"
|
||||||
"engr-ugaif"
|
];
|
||||||
];
|
nix.settings.experimental-features = [
|
||||||
nix.settings.experimental-features = [
|
"nix-command"
|
||||||
"nix-command"
|
"flakes"
|
||||||
"flakes"
|
];
|
||||||
];
|
|
||||||
|
|
||||||
# ========== Container-Specific Configuration ==========
|
# ========== Container-Specific Configuration ==========
|
||||||
boot.isContainer = true;
|
boot.isContainer = true;
|
||||||
boot.loader.systemd-boot.enable = lib.mkForce false; # No bootloader in container
|
boot.loader.systemd-boot.enable = lib.mkForce false; # No bootloader in container
|
||||||
disko.enableConfig = lib.mkForce false; # No disk management in container
|
disko.enableConfig = lib.mkForce false; # No disk management in container
|
||||||
console.enable = true;
|
console.enable = true;
|
||||||
|
|
||||||
# Set timezone to fix /etc/localtime for Docker containers
|
# Allow getty to work in containers
|
||||||
time.timeZone = lib.mkDefault "America/New_York";
|
systemd.services."getty@".unitConfig.ConditionPathExists = [
|
||||||
|
""
|
||||||
|
"/dev/%I"
|
||||||
|
];
|
||||||
|
|
||||||
# Allow getty to work in containers
|
# Suppress unnecessary systemd units for containers
|
||||||
systemd.services."getty@".unitConfig.ConditionPathExists = [
|
systemd.suppressedSystemUnits = [
|
||||||
""
|
"dev-mqueue.mount"
|
||||||
"/dev/%I"
|
"sys-kernel-debug.mount"
|
||||||
];
|
"sys-fs-fuse-connections.mount"
|
||||||
|
];
|
||||||
|
|
||||||
# Suppress unnecessary systemd units for containers
|
# ========== Remote Development ==========
|
||||||
systemd.suppressedSystemUnits = [
|
services.vscode-server.enable = true;
|
||||||
"dev-mqueue.mount"
|
|
||||||
"sys-kernel-debug.mount"
|
|
||||||
"sys-fs-fuse-connections.mount"
|
|
||||||
];
|
|
||||||
|
|
||||||
# ========== Remote Development ==========
|
# ========== System Configuration ==========
|
||||||
services.vscode-server.enable = true;
|
system.stateVersion = "25.11";
|
||||||
|
athenix.host.buildMethods = lib.mkDefault [
|
||||||
|
"lxc" # LXC container tarball
|
||||||
|
"proxmox" # Proxmox VMA archive
|
||||||
|
];
|
||||||
|
|
||||||
# ========== System Configuration ==========
|
athenix.sw.enable = lib.mkDefault true;
|
||||||
system.stateVersion = "25.11";
|
athenix.sw.type = lib.mkDefault "headless";
|
||||||
athenix.host.buildMethods = lib.mkDefault [
|
|
||||||
"lxc" # LXC container tarball
|
|
||||||
"proxmox" # Proxmox VMA archive
|
|
||||||
];
|
|
||||||
|
|
||||||
athenix.sw.enable = lib.mkDefault true;
|
|
||||||
athenix.sw.headless.enable = lib.mkDefault true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,7 @@
|
|||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.athenix.hw.nix-surface;
|
|
||||||
# Use older kernel version for better Surface Go compatibility
|
# Use older kernel version for better Surface Go compatibility
|
||||||
refSystem = inputs.nixpkgs-old-kernel.lib.nixosSystem {
|
refSystem = inputs.nixpkgs-old-kernel.lib.nixosSystem {
|
||||||
system = pkgs.stdenv.hostPlatform.system;
|
system = pkgs.stdenv.hostPlatform.system;
|
||||||
@@ -30,60 +26,44 @@ in
|
|||||||
inputs.nixos-hardware.nixosModules.microsoft-surface-go
|
inputs.nixos-hardware.nixosModules.microsoft-surface-go
|
||||||
];
|
];
|
||||||
|
|
||||||
options.athenix.hw.nix-surface = mkOption {
|
# ========== Boot Configuration ==========
|
||||||
type = types.submodule {
|
|
||||||
options = {
|
|
||||||
enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable Microsoft Surface tablet hardware configuration.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
default = { };
|
|
||||||
description = "Microsoft Surface hardware type configuration.";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
boot.initrd.availableKernelModules = [
|
||||||
# ========== Boot Configuration ==========
|
"xhci_pci" # USB 3.0 support
|
||||||
|
"nvme" # NVMe support (though Surface uses eMMC)
|
||||||
|
"usb_storage" # USB storage devices
|
||||||
|
"sd_mod" # SD card support
|
||||||
|
"sdhci_pci" # SD card host controller
|
||||||
|
];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
boot.kernelParams = [
|
||||||
|
"quiet" # Minimal boot messages
|
||||||
|
"splash" # Show Plymouth boot splash
|
||||||
|
"boot.shell_on_fail" # Emergency shell on boot failure
|
||||||
|
"udev.log_priority=3" # Reduce udev logging
|
||||||
|
"rd.systemd.show_status=auto" # Show systemd status during boot
|
||||||
|
"intel_ipu3_imgu" # Intel camera image processing
|
||||||
|
"intel_ipu3_isys" # Intel camera sensor interface
|
||||||
|
"fbcon=map:1" # Framebuffer console mapping
|
||||||
|
"i915.enable_psr=0" # Disable Panel Self Refresh (breaks resume)
|
||||||
|
"i915.enable_dc=0" # Disable display power saving
|
||||||
|
];
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [
|
# Use older kernel for better Surface hardware support
|
||||||
"xhci_pci" # USB 3.0 support
|
boot.kernelPackages = lib.mkForce refKernelPackages;
|
||||||
"nvme" # NVMe support (though Surface uses eMMC)
|
|
||||||
"usb_storage" # USB storage devices
|
|
||||||
"sd_mod" # SD card support
|
|
||||||
"sdhci_pci" # SD card host controller
|
|
||||||
];
|
|
||||||
boot.initrd.kernelModules = [ ];
|
|
||||||
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
|
||||||
boot.extraModulePackages = [ ];
|
|
||||||
boot.kernelParams = [
|
|
||||||
"quiet" # Minimal boot messages
|
|
||||||
"splash" # Show Plymouth boot splash
|
|
||||||
"boot.shell_on_fail" # Emergency shell on boot failure
|
|
||||||
"udev.log_priority=3" # Reduce udev logging
|
|
||||||
"rd.systemd.show_status=auto" # Show systemd status during boot
|
|
||||||
"intel_ipu3_imgu" # Intel camera image processing
|
|
||||||
"intel_ipu3_isys" # Intel camera sensor interface
|
|
||||||
"fbcon=map:1" # Framebuffer console mapping
|
|
||||||
"i915.enable_psr=0" # Disable Panel Self Refresh (breaks resume)
|
|
||||||
"i915.enable_dc=0" # Disable display power saving
|
|
||||||
];
|
|
||||||
|
|
||||||
# Use older kernel for better Surface hardware support
|
# ========== Filesystem Configuration ==========
|
||||||
boot.kernelPackages = lib.mkForce refKernelPackages;
|
athenix.host.filesystem.swapSize = lib.mkDefault "8G";
|
||||||
|
athenix.host.filesystem.device = lib.mkDefault "/dev/mmcblk0"; # eMMC storage # eMMC storage
|
||||||
|
athenix.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
||||||
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
|
||||||
# ========== Filesystem Configuration ==========
|
# ========== Hardware Configuration ==========
|
||||||
athenix.host.filesystem.swapSize = lib.mkDefault "8G";
|
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
athenix.host.filesystem.device = lib.mkDefault "/dev/mmcblk0"; # eMMC storage # eMMC storage
|
|
||||||
athenix.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
|
||||||
|
|
||||||
# ========== Hardware Configuration ==========
|
# ========== Software Profile ==========
|
||||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
athenix.sw.enable = lib.mkDefault true;
|
||||||
|
athenix.sw.type = lib.mkDefault "tablet-kiosk"; # Touch-optimized kiosk mode
|
||||||
# ========== Software Profile ==========
|
|
||||||
athenix.sw.enable = lib.mkDefault true;
|
|
||||||
athenix.sw.tablet-kiosk.enable = lib.mkDefault true; # Touch-optimized kiosk mode
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,43 +7,23 @@
|
|||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.athenix.hw.nix-wsl;
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
options.athenix.hw.nix-wsl = mkOption {
|
imports = [
|
||||||
type = types.submodule {
|
inputs.nixos-wsl.nixosModules.default
|
||||||
options = {
|
inputs.vscode-server.nixosModules.default
|
||||||
enable = mkOption {
|
];
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable Windows Subsystem for Linux hardware configuration.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
default = { };
|
|
||||||
description = "WSL hardware type configuration.";
|
|
||||||
};
|
|
||||||
|
|
||||||
# WSL user option (at module level, not inside config)
|
# ========== Options ==========
|
||||||
options.athenix.host.wsl.user = lib.mkOption {
|
options.athenix.host.wsl.user = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "engr-ugaif";
|
default = "engr-ugaif";
|
||||||
description = ''
|
description = "The default user to log in as in WSL.";
|
||||||
The default user to automatically log in as when starting WSL.
|
|
||||||
|
|
||||||
This user must be enabled via athenix.users.<username>.enable = true.
|
|
||||||
Tip: Use athenix.forUser = "username" as a shortcut to set both.
|
|
||||||
'';
|
|
||||||
example = "alice";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = {
|
||||||
# ========== WSL Configuration ==========
|
# ========== WSL Configuration ==========
|
||||||
wsl.enable = true;
|
wsl.enable = true;
|
||||||
# Use forUser if set, otherwise fall back to wsl.user option
|
# Use forUser if set, otherwise fall back to wsl.user option
|
||||||
@@ -52,7 +32,7 @@ in
|
|||||||
|
|
||||||
# ========== Software Profile ==========
|
# ========== Software Profile ==========
|
||||||
athenix.sw.enable = lib.mkDefault true;
|
athenix.sw.enable = lib.mkDefault true;
|
||||||
athenix.sw.headless.enable = lib.mkDefault true;
|
athenix.sw.type = lib.mkDefault "headless";
|
||||||
|
|
||||||
# ========== Remote Development ==========
|
# ========== Remote Development ==========
|
||||||
services.vscode-server.enable = true;
|
services.vscode-server.enable = true;
|
||||||
@@ -69,8 +49,5 @@ in
|
|||||||
# Provide dummy values for required options from boot.nix
|
# Provide dummy values for required options from boot.nix
|
||||||
athenix.host.filesystem.device = "/dev/null";
|
athenix.host.filesystem.device = "/dev/null";
|
||||||
athenix.host.filesystem.swapSize = "0G";
|
athenix.host.filesystem.swapSize = "0G";
|
||||||
|
|
||||||
# WSL doesn't use installer ISOs
|
|
||||||
athenix.host.buildMethods = lib.mkDefault [ ];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,62 +10,40 @@
|
|||||||
modulesPath,
|
modulesPath,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.athenix.hw.nix-zima;
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
options.athenix.hw.nix-zima = mkOption {
|
# ========== Boot Configuration ==========
|
||||||
type = types.submodule {
|
|
||||||
options = {
|
|
||||||
enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable Zima-specific hardware configuration.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
default = { };
|
|
||||||
description = "Zima hardware type configuration.";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
boot.initrd.availableKernelModules = [
|
||||||
# ========== Boot Configuration ==========
|
"xhci_pci" # USB 3.0 support
|
||||||
|
"usb_storage" # USB storage devices
|
||||||
|
"sd_mod" # SD card support
|
||||||
|
"sdhci_pci" # SD card host controller
|
||||||
|
];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
boot.kernelParams = [
|
||||||
|
"quiet" # Minimal boot messages
|
||||||
|
"splash" # Show Plymouth boot splash
|
||||||
|
"boot.shell_on_fail" # Emergency shell on boot failure
|
||||||
|
"udev.log_priority=3" # Reduce udev logging
|
||||||
|
"rd.systemd.show_status=auto" # Show systemd status during boot
|
||||||
|
];
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [
|
# ========== Filesystem Configuration ==========
|
||||||
"xhci_pci" # USB 3.0 support
|
athenix.host.filesystem.useSwap = lib.mkDefault false;
|
||||||
"usb_storage" # USB storage devices
|
athenix.host.filesystem.device = lib.mkDefault "/dev/mmcblk0";
|
||||||
"sd_mod" # SD card support
|
athenix.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
||||||
"sdhci_pci" # SD card host controller
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
];
|
|
||||||
boot.initrd.kernelModules = [ ];
|
|
||||||
boot.kernelModules = [ "kvm-intel" ]; # Intel virtualization support
|
|
||||||
boot.extraModulePackages = [ ];
|
|
||||||
boot.kernelParams = [
|
|
||||||
"quiet" # Minimal boot messages
|
|
||||||
"splash" # Show Plymouth boot splash
|
|
||||||
"boot.shell_on_fail" # Emergency shell on boot failure
|
|
||||||
"udev.log_priority=3" # Reduce udev logging
|
|
||||||
"rd.systemd.show_status=auto" # Show systemd status during boot
|
|
||||||
];
|
|
||||||
|
|
||||||
# ========== Filesystem Configuration ==========
|
# ========== Hardware Configuration ==========
|
||||||
athenix.host.filesystem.useSwap = lib.mkDefault false;
|
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
athenix.host.filesystem.device = lib.mkDefault "/dev/mmcblk0";
|
|
||||||
athenix.host.buildMethods = lib.mkDefault [ "installer-iso" ];
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
|
||||||
|
|
||||||
# ========== Hardware Configuration ==========
|
# ========== Software Profile ==========
|
||||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
athenix.sw.enable = lib.mkDefault true;
|
||||||
|
athenix.sw.type = lib.mkDefault "desktop";
|
||||||
# ========== Software Profile ==========
|
|
||||||
athenix.sw.enable = lib.mkDefault true;
|
|
||||||
athenix.sw.desktop.enable = lib.mkDefault true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
fleet,
|
fleet,
|
||||||
self,
|
self,
|
||||||
system,
|
system,
|
||||||
users ? { },
|
|
||||||
}:
|
}:
|
||||||
# This file defines the logic for generating various build artifacts (ISOs, Netboot, LXC, etc.)
|
# This file defines the logic for generating various build artifacts (ISOs, Netboot, LXC, etc.)
|
||||||
# It exports a set of packages that can be built using `nix build .#<artifact-name>`
|
# It exports a set of packages that can be built using `nix build .#<artifact-name>`
|
||||||
@@ -30,7 +29,6 @@ let
|
|||||||
hostName
|
hostName
|
||||||
targetSystemBuild
|
targetSystemBuild
|
||||||
diskoScript
|
diskoScript
|
||||||
users
|
|
||||||
;
|
;
|
||||||
hostPlatform = system;
|
hostPlatform = system;
|
||||||
};
|
};
|
||||||
@@ -48,9 +46,6 @@ let
|
|||||||
inherit system;
|
inherit system;
|
||||||
specialArgs = { inherit inputs; };
|
specialArgs = { inherit inputs; };
|
||||||
modules = fleet.modules.${hostName} ++ [
|
modules = fleet.modules.${hostName} ++ [
|
||||||
{
|
|
||||||
config.athenix.users = lib.mapAttrs (_: user: lib.mapAttrs (_: lib.mkDefault) user) users;
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
disko.enableConfig = lib.mkForce false;
|
disko.enableConfig = lib.mkForce false;
|
||||||
services.upower.enable = lib.mkForce false;
|
services.upower.enable = lib.mkForce false;
|
||||||
@@ -68,9 +63,6 @@ let
|
|||||||
specialArgs = { inherit inputs; };
|
specialArgs = { inherit inputs; };
|
||||||
modules = fleet.modules.${hostName} ++ [
|
modules = fleet.modules.${hostName} ++ [
|
||||||
"${nixpkgs}/nixos/modules/installer/netboot/netboot.nix"
|
"${nixpkgs}/nixos/modules/installer/netboot/netboot.nix"
|
||||||
{
|
|
||||||
config.athenix.users = lib.mapAttrs (_: user: lib.mapAttrs (_: lib.mkDefault) user) users;
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
disko.enableConfig = lib.mkForce false;
|
disko.enableConfig = lib.mkForce false;
|
||||||
services.upower.enable = lib.mkForce false;
|
services.upower.enable = lib.mkForce false;
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
# It is intended to be used in an installation ISO.
|
# It is intended to be used in an installation ISO.
|
||||||
# It expects `targetSystem` (the closure to install) and `diskoScript` (the partitioning script) to be passed as arguments.
|
# It expects `targetSystem` (the closure to install) and `diskoScript` (the partitioning script) to be passed as arguments.
|
||||||
{
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
inputs,
|
||||||
hostName,
|
hostName,
|
||||||
hostPlatform,
|
hostPlatform,
|
||||||
targetSystemBuild,
|
targetSystemBuild,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Software configuration module - main module with all athenix.sw options
|
# Software configuration module - main module with all athenix.sw options
|
||||||
# Use athenix.sw.<type>.enable to enable software profiles: desktop, tablet-kiosk, headless, stateless-kiosk, builders
|
# Use athenix.sw.type to select profile: "desktop", "tablet-kiosk", "headless", "stateless-kiosk"
|
||||||
hw = hostTypes;
|
hw = hostTypes;
|
||||||
sw =
|
sw =
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
# External modules (instead of config):
|
# External modules (instead of config):
|
||||||
# Device values can be a config attrset with an optional 'external' field:
|
# Device values can be a config attrset with an optional 'external' field:
|
||||||
# devices."hostname" = {
|
# devices."hostname" = {
|
||||||
# external = { url = "..."; rev = "..."; submodules? = false; }; # Lazy: only fetched when building this host
|
# external = builtins.fetchGit { ... }; # Lazy: only fetched when building this host
|
||||||
# # ... additional config options
|
# # ... additional config options
|
||||||
# };
|
# };
|
||||||
# The external module will be imported and evaluated only when this specific host is built.
|
# The external module will be imported and evaluated only when this specific host is built.
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
# devices."alice".athenix.forUser = "alice123"; # Sets up for user alice123
|
# devices."alice".athenix.forUser = "alice123"; # Sets up for user alice123
|
||||||
# };
|
# };
|
||||||
# "external" = {
|
# "external" = {
|
||||||
# devices."remote".external = { url = "..."; rev = "..."; }; # External module via Git (lazy)
|
# devices."remote".external = builtins.fetchGit { # External module via Git (lazy)
|
||||||
# url = "https://github.com/example/config";
|
# url = "https://github.com/example/config";
|
||||||
# rev = "e1ccd7cc3e709afe4f50b0627e1c4bde49165014";
|
# rev = "e1ccd7cc3e709afe4f50b0627e1c4bde49165014";
|
||||||
# };
|
# };
|
||||||
@@ -92,10 +92,10 @@
|
|||||||
nix-surface = {
|
nix-surface = {
|
||||||
defaultCount = 3;
|
defaultCount = 3;
|
||||||
devices = {
|
devices = {
|
||||||
"1".athenix.sw.tablet-kiosk.kioskUrl = "https://google.com";
|
"1".athenix.sw.kioskUrl = "https://google.com";
|
||||||
};
|
};
|
||||||
overrides = {
|
overrides = {
|
||||||
athenix.sw.tablet-kiosk.kioskUrl = "https://yahoo.com";
|
athenix.sw.kioskUrl = "https://yahoo.com";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -106,32 +106,33 @@
|
|||||||
"nix-builder" = {
|
"nix-builder" = {
|
||||||
# Gitea Actions self-hosted runner configuration
|
# Gitea Actions self-hosted runner configuration
|
||||||
athenix.sw = {
|
athenix.sw = {
|
||||||
headless.enable = true;
|
type = [
|
||||||
builders = {
|
"headless"
|
||||||
|
"builders"
|
||||||
|
];
|
||||||
|
builders.giteaRunner = {
|
||||||
enable = true;
|
enable = true;
|
||||||
giteaRunner = {
|
url = "https://git.factory.uga.edu";
|
||||||
enable = true;
|
# Token file must be created manually at this path with a Gitea runner token
|
||||||
url = "https://git.factory.uga.edu";
|
# Generate in repository settings: Settings > Actions > Runners > Create new Runner
|
||||||
# Token file must be created manually at this path with a Gitea runner token
|
# echo "TOKEN=YOUR_TOKEN_HERE" | sudo tee /var/lib/gitea-runner-token > /dev/null
|
||||||
# Generate in repository settings: Settings > Actions > Runners > Create new Runner
|
tokenFile = "/var/lib/gitea-runner-token";
|
||||||
# echo "TOKEN=YOUR_TOKEN_HERE" | sudo tee /var/lib/gitea-runner-token > /dev/null
|
# Labels to identify this runner in workflows
|
||||||
tokenFile = "/var/lib/gitea-runner-token";
|
extraLabels = [
|
||||||
# Labels to identify this runner in workflows
|
"self-hosted"
|
||||||
extraLabels = [
|
"nix-builder"
|
||||||
"self-hosted"
|
];
|
||||||
"nix-builder"
|
# Runner service name
|
||||||
];
|
name = "athenix";
|
||||||
# Runner service name
|
|
||||||
name = "athenix";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
"usda-dash".external = {
|
"usda-dash".external = builtins.fetchGit {
|
||||||
url = "https://git.factory.uga.edu/MODEL/usda-dash-config.git";
|
url = "https://git.factory.uga.edu/MODEL/usda-dash-config.git";
|
||||||
rev = "ce2700b0196e106f7c013bbcee851a5f96b146a3";
|
rev = "dab32f5884895cead0fae28cb7d88d17951d0c12";
|
||||||
submodules = false;
|
submodules = true;
|
||||||
};
|
};
|
||||||
|
"usda-dash".athenix.users.engr-ugaif.enable = true;
|
||||||
};
|
};
|
||||||
overrides = {
|
overrides = {
|
||||||
athenix.host.useHostPrefix = false;
|
athenix.host.useHostPrefix = false;
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
{
|
{ inputs }:
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
{
|
{
|
||||||
mkFleet = import ./mkFleet.nix;
|
mkFleet = import ./mkFleet.nix;
|
||||||
macCaseBuilder = import ./macCaseBuilder.nix { inherit lib; };
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
{ lib }:
|
|
||||||
let
|
|
||||||
# Default MAC address to station number mapping
|
|
||||||
defaultHostmap = {
|
|
||||||
"00:e0:4c:46:0b:32" = "1";
|
|
||||||
"00:e0:4c:46:07:26" = "2";
|
|
||||||
"00:e0:4c:46:05:94" = "3";
|
|
||||||
"00:e0:4c:46:07:11" = "4";
|
|
||||||
"00:e0:4c:46:08:02" = "5";
|
|
||||||
"00:e0:4c:46:08:5c" = "6";
|
|
||||||
};
|
|
||||||
|
|
||||||
# macCaseBuilder: builds a shell case statement from a hostmap
|
|
||||||
# Parameters:
|
|
||||||
# varName: the shell variable to assign
|
|
||||||
# prefix: optional string to prepend to the value (default: "")
|
|
||||||
# hostmap: optional attribute set to use (default: built-in hostmap)
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
# macCaseBuilder { varName = "STATION"; prefix = "nix-"; }
|
|
||||||
# # Generates case statements like: 00:e0:4c:46:0b:32) STATION=nix-1 ;;
|
|
||||||
builder =
|
|
||||||
{
|
|
||||||
varName,
|
|
||||||
prefix ? "",
|
|
||||||
hostmap ? defaultHostmap,
|
|
||||||
}:
|
|
||||||
lib.concatStringsSep "\n" (
|
|
||||||
lib.mapAttrsToList (mac: val: " ${mac}) ${varName}=${prefix}${val} ;;") hostmap
|
|
||||||
);
|
|
||||||
in
|
|
||||||
# Export the builder function with hostmap as an accessible attribute
|
|
||||||
lib.setFunctionArgs builder { } // { hostmap = defaultHostmap; }
|
|
||||||
@@ -4,15 +4,7 @@
|
|||||||
inputs,
|
inputs,
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
self ? null,
|
|
||||||
users ? { },
|
|
||||||
}:
|
}:
|
||||||
import ../fleet/default.nix {
|
import ../fleet/default.nix {
|
||||||
inherit
|
inherit inputs lib config;
|
||||||
inputs
|
|
||||||
lib
|
|
||||||
config
|
|
||||||
self
|
|
||||||
users
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|||||||
194
parts/docs.nix
194
parts/docs.nix
@@ -1,194 +0,0 @@
|
|||||||
# Documentation generation
|
|
||||||
{
|
|
||||||
inputs,
|
|
||||||
self,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
|
|
||||||
|
|
||||||
# Extract options from a sample configuration
|
|
||||||
getAthenixOptions =
|
|
||||||
configName:
|
|
||||||
let
|
|
||||||
nixosConfig = self.nixosConfigurations.${configName};
|
|
||||||
evaledOptions = nixosConfig.options;
|
|
||||||
|
|
||||||
# Filter to just athenix namespace
|
|
||||||
athenixOptions = evaledOptions.athenix or { };
|
|
||||||
in
|
|
||||||
athenixOptions;
|
|
||||||
|
|
||||||
# Generate wiki home page
|
|
||||||
wikiHome = pkgs.writeText "Home.md" ''
|
|
||||||
# Athenix - NixOS Fleet Management
|
|
||||||
|
|
||||||
Athenix is a NixOS configuration system for managing the UGA Innovation Factory's fleet of devices using Nix flakes and a custom configuration framework.
|
|
||||||
|
|
||||||
## Quick Start
|
|
||||||
|
|
||||||
- [Configuration Options](Configuration-Options) - All available `athenix.*` options
|
|
||||||
- [User Guide](User-Configuration) - Setting up user accounts and dotfiles
|
|
||||||
- [Building](Building) - Creating installers and system images
|
|
||||||
- [Development](Development) - Contributing to Athenix
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- **Inventory-based fleet management** - Define entire device fleets in a single file
|
|
||||||
- **Multiple hardware types** - Desktops, laptops, Surface tablets, LXC containers, WSL
|
|
||||||
- **Flexible software configurations** - Desktop, headless, kiosk, and builder modes
|
|
||||||
- **External module support** - Load user dotfiles and system configs from Git repos
|
|
||||||
- **Declarative everything** - Reproducible builds with pinned dependencies
|
|
||||||
|
|
||||||
## Software Types
|
|
||||||
|
|
||||||
Enable different system configurations:
|
|
||||||
|
|
||||||
- **desktop** - Full KDE Plasma 6 desktop environment
|
|
||||||
- **headless** - Minimal server/container configuration
|
|
||||||
- **tablet-kiosk** - Touch-optimized kiosk for Surface tablets
|
|
||||||
- **stateless-kiosk** - Diskless PXE boot kiosk
|
|
||||||
- **builders** - CI/CD build server with Gitea Actions runner
|
|
||||||
|
|
||||||
## Hardware Types
|
|
||||||
|
|
||||||
- **nix-desktop** - Desktop workstations
|
|
||||||
- **nix-laptop** - Laptop computers
|
|
||||||
- **nix-surface** - Microsoft Surface Pro tablets
|
|
||||||
- **nix-lxc** - LXC containers (Proxmox)
|
|
||||||
- **nix-wsl** - Windows Subsystem for Linux
|
|
||||||
- **nix-ephemeral** - Stateless systems (PXE boot)
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
Browse the documentation using the sidebar or start with:
|
|
||||||
|
|
||||||
- [README](README) - Repository overview and getting started
|
|
||||||
- [Configuration Options](Configuration-Options) - Complete option reference
|
|
||||||
- [Inventory Guide](Inventory) - Managing the device fleet
|
|
||||||
- [External Modules](External-Modules) - Using external configurations
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Generate markdown documentation from options
|
|
||||||
optionsToMarkdown =
|
|
||||||
options:
|
|
||||||
pkgs.writeText "options.md" ''
|
|
||||||
# Configuration Options
|
|
||||||
|
|
||||||
This document describes all available configuration options in the Athenix namespace.
|
|
||||||
|
|
||||||
## Quick Reference
|
|
||||||
|
|
||||||
- **athenix.sw** - Software configuration (desktop, headless, kiosk modes)
|
|
||||||
- **athenix.users** - User account management
|
|
||||||
- **athenix.host** - Host-specific settings (filesystem, build methods)
|
|
||||||
- **athenix.fleet** - Fleet inventory definitions
|
|
||||||
- **athenix.forUser** - Convenience option to enable a user
|
|
||||||
- **athenix.system.gc** - Garbage collection settings
|
|
||||||
|
|
||||||
## Detailed Options
|
|
||||||
|
|
||||||
For detailed option information, use:
|
|
||||||
```bash
|
|
||||||
# View all athenix options
|
|
||||||
nix eval .#nixosConfigurations.nix-desktop1.options.athenix --apply builtins.attrNames
|
|
||||||
|
|
||||||
# View specific option description
|
|
||||||
nix eval .#nixosConfigurations.nix-desktop1.options.athenix.sw.desktop.enable.description
|
|
||||||
|
|
||||||
# Export all options to JSON
|
|
||||||
nix build .#athenix-options
|
|
||||||
cat result | jq
|
|
||||||
```
|
|
||||||
|
|
||||||
## Software Types
|
|
||||||
|
|
||||||
Enable different system configurations:
|
|
||||||
|
|
||||||
- **desktop** - Full KDE Plasma desktop environment
|
|
||||||
- **headless** - Server/container configuration
|
|
||||||
- **tablet-kiosk** - Touch-optimized kiosk for tablets
|
|
||||||
- **stateless-kiosk** - Diskless PXE boot kiosk
|
|
||||||
- **builders** - Build server with optional Gitea Actions runner
|
|
||||||
|
|
||||||
See the individual option descriptions for detailed information.
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
{
|
|
||||||
perSystem =
|
|
||||||
{ system, ... }:
|
|
||||||
lib.mkIf (system == "x86_64-linux") {
|
|
||||||
packages = {
|
|
||||||
# Generate option documentation in markdown
|
|
||||||
docs =
|
|
||||||
pkgs.runCommand "athenix-docs"
|
|
||||||
{
|
|
||||||
nativeBuildInputs = [ pkgs.jq ];
|
|
||||||
}
|
|
||||||
''
|
|
||||||
mkdir -p $out
|
|
||||||
|
|
||||||
# Generate wiki home page
|
|
||||||
cat > $out/Home.md << 'EOF'
|
|
||||||
${builtins.readFile wikiHome}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Copy main README
|
|
||||||
cp ${../README.md} $out/README.md
|
|
||||||
|
|
||||||
# Copy documentation with wiki-friendly names
|
|
||||||
cp ${../docs/BUILDING.md} $out/Building.md
|
|
||||||
cp ${../docs/DEVELOPMENT.md} $out/Development.md
|
|
||||||
cp ${../docs/EXTERNAL_MODULES.md} $out/External-Modules.md
|
|
||||||
cp ${../docs/INVENTORY.md} $out/Inventory.md
|
|
||||||
cp ${../docs/NAMESPACE.md} $out/Namespace.md
|
|
||||||
cp ${../docs/USER_CONFIGURATION.md} $out/User-Configuration.md
|
|
||||||
|
|
||||||
# Generate options reference
|
|
||||||
cat > $out/Configuration-Options.md << 'EOF'
|
|
||||||
${builtins.readFile (optionsToMarkdown (getAthenixOptions "nix-desktop1"))}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
echo "Documentation generated in $out"
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Extract just the athenix namespace options as JSON
|
|
||||||
athenix-options =
|
|
||||||
let
|
|
||||||
nixosConfig =
|
|
||||||
self.nixosConfigurations.nix-desktop1
|
|
||||||
or (builtins.head (builtins.attrValues self.nixosConfigurations));
|
|
||||||
|
|
||||||
# Recursively extract option information
|
|
||||||
extractOption =
|
|
||||||
opt:
|
|
||||||
if opt ? _type && opt._type == "option" then
|
|
||||||
{
|
|
||||||
inherit (opt) description;
|
|
||||||
type = opt.type.description or (opt.type.name or "unknown");
|
|
||||||
default =
|
|
||||||
if opt ? default then
|
|
||||||
if builtins.isAttrs opt.default && opt.default ? _type then "<special>" else opt.default
|
|
||||||
else
|
|
||||||
null;
|
|
||||||
example =
|
|
||||||
if opt ? example then
|
|
||||||
if builtins.isAttrs opt.example && opt.example ? _type then "<special>" else opt.example
|
|
||||||
else
|
|
||||||
null;
|
|
||||||
}
|
|
||||||
else if builtins.isAttrs opt then
|
|
||||||
lib.mapAttrs (name: value: extractOption value) (
|
|
||||||
# Filter out internal attributes
|
|
||||||
lib.filterAttrs (n: _: !lib.hasPrefix "_" n) opt
|
|
||||||
)
|
|
||||||
else
|
|
||||||
null;
|
|
||||||
|
|
||||||
athenixOpts = nixosConfig.options.athenix or { };
|
|
||||||
in
|
|
||||||
pkgs.writeText "athenix-options.json" (builtins.toJSON (extractOption athenixOpts));
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
# Library functions for flake-parts
|
# Library functions for flake-parts
|
||||||
{ inputs, ... }:
|
{ inputs, ... }:
|
||||||
{
|
{
|
||||||
flake.lib = import ../lib {
|
flake.lib = import ../lib { inherit inputs; };
|
||||||
inherit inputs;
|
|
||||||
lib = inputs.nixpkgs.lib;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
inputs,
|
inputs,
|
||||||
self,
|
self,
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
@@ -13,16 +14,7 @@
|
|||||||
|
|
||||||
flake.nixosConfigurations =
|
flake.nixosConfigurations =
|
||||||
let
|
let
|
||||||
users = config.athenix.users;
|
fleet = self.lib.mkFleet { inherit inputs lib config; };
|
||||||
fleet = self.lib.mkFleet {
|
|
||||||
inherit
|
|
||||||
inputs
|
|
||||||
lib
|
|
||||||
config
|
|
||||||
self
|
|
||||||
users
|
|
||||||
;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
fleet.nixosConfigurations;
|
fleet.nixosConfigurations;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,23 +12,13 @@
|
|||||||
lib.mkIf (system == "x86_64-linux") {
|
lib.mkIf (system == "x86_64-linux") {
|
||||||
packages =
|
packages =
|
||||||
let
|
let
|
||||||
users = config.athenix.users;
|
fleet = self.lib.mkFleet { inherit inputs lib config; };
|
||||||
fleet = self.lib.mkFleet {
|
|
||||||
inherit
|
|
||||||
inputs
|
|
||||||
lib
|
|
||||||
config
|
|
||||||
self
|
|
||||||
users
|
|
||||||
;
|
|
||||||
};
|
|
||||||
artifacts = import ../installer/artifacts.nix {
|
artifacts = import ../installer/artifacts.nix {
|
||||||
inherit
|
inherit
|
||||||
inputs
|
inputs
|
||||||
fleet
|
fleet
|
||||||
self
|
self
|
||||||
system
|
system
|
||||||
users
|
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|||||||
7
parts/users.nix
Normal file
7
parts/users.nix
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Flake-parts wrapper for users.nix
|
||||||
|
{ inputs, ... }:
|
||||||
|
let
|
||||||
|
# Minimal pkgs just for shell paths - will be overridden in actual NixOS configs
|
||||||
|
pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
|
||||||
|
in
|
||||||
|
import ../users.nix { inherit pkgs; }
|
||||||
187
secrets.nix
187
secrets.nix
@@ -1,187 +0,0 @@
|
|||||||
# ============================================================================
|
|
||||||
# Agenix Secret Recipients Configuration (Auto-Generated)
|
|
||||||
# ============================================================================
|
|
||||||
# This file automatically discovers hosts and their public keys from the
|
|
||||||
# secrets/ directory structure and generates recipient configurations.
|
|
||||||
#
|
|
||||||
# Directory structure:
|
|
||||||
# secrets/{hostname}/*.pub -> SSH/age public keys for that host
|
|
||||||
# secrets/global/*.pub -> Keys accessible to all hosts
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# ragenix -e secrets/global/example.age # Edit/create secret
|
|
||||||
# ragenix -r # Re-key all secrets
|
|
||||||
#
|
|
||||||
# To add admin keys for editing secrets, create secrets/admins/*.pub files
|
|
||||||
# with your personal age public keys (generated with: age-keygen)
|
|
||||||
|
|
||||||
let
|
|
||||||
lib = builtins;
|
|
||||||
|
|
||||||
# Helper functions not in builtins
|
|
||||||
filterAttrs =
|
|
||||||
pred: set:
|
|
||||||
lib.listToAttrs (
|
|
||||||
lib.filter (item: pred item.name item.value) (
|
|
||||||
lib.map (name: {
|
|
||||||
inherit name;
|
|
||||||
value = set.${name};
|
|
||||||
}) (lib.attrNames set)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
concatLists = lists: lib.foldl' (acc: list: acc ++ list) [ ] lists;
|
|
||||||
|
|
||||||
unique =
|
|
||||||
list:
|
|
||||||
let
|
|
||||||
go =
|
|
||||||
acc: remaining:
|
|
||||||
if remaining == [ ] then
|
|
||||||
acc
|
|
||||||
else if lib.elem (lib.head remaining) acc then
|
|
||||||
go acc (lib.tail remaining)
|
|
||||||
else
|
|
||||||
go (acc ++ [ (lib.head remaining) ]) (lib.tail remaining);
|
|
||||||
in
|
|
||||||
go [ ] list;
|
|
||||||
|
|
||||||
hasSuffix =
|
|
||||||
suffix: str:
|
|
||||||
let
|
|
||||||
lenStr = lib.stringLength str;
|
|
||||||
lenSuffix = lib.stringLength suffix;
|
|
||||||
in
|
|
||||||
lenStr >= lenSuffix && lib.substring (lenStr - lenSuffix) lenSuffix str == suffix;
|
|
||||||
|
|
||||||
nameValuePair = name: value: { inherit name value; };
|
|
||||||
|
|
||||||
secretsPath = ./secrets;
|
|
||||||
|
|
||||||
# Read all directories in secrets/
|
|
||||||
secretDirs = if lib.pathExists secretsPath then lib.readDir secretsPath else { };
|
|
||||||
|
|
||||||
# Filter to only directories (excludes files)
|
|
||||||
isDirectory = name: type: type == "directory";
|
|
||||||
directories = lib.filter (name: isDirectory name secretDirs.${name}) (lib.attrNames secretDirs);
|
|
||||||
|
|
||||||
# Read public keys from a directory and convert to age format
|
|
||||||
readHostKeys =
|
|
||||||
dirName:
|
|
||||||
let
|
|
||||||
dirPath = secretsPath + "/${dirName}";
|
|
||||||
files = if lib.pathExists dirPath then lib.readDir dirPath else { };
|
|
||||||
|
|
||||||
# Prefer .age.pub files (pre-converted), fall back to .pub files
|
|
||||||
agePubFiles = filterAttrs (name: type: type == "regular" && hasSuffix ".age.pub" name) files;
|
|
||||||
|
|
||||||
sshPubFiles = filterAttrs (
|
|
||||||
name: type: type == "regular" && hasSuffix ".pub" name && !(hasSuffix ".age.pub" name)
|
|
||||||
) files;
|
|
||||||
|
|
||||||
# Read age public keys (already in correct format)
|
|
||||||
ageKeys = lib.map (
|
|
||||||
name:
|
|
||||||
let
|
|
||||||
content = lib.readFile (dirPath + "/${name}");
|
|
||||||
# Trim whitespace/newlines
|
|
||||||
trimmed = lib.replaceStrings [ "\n" " " "\r" "\t" ] [ "" "" "" "" ] content;
|
|
||||||
in
|
|
||||||
trimmed
|
|
||||||
) (lib.attrNames agePubFiles);
|
|
||||||
|
|
||||||
# For SSH keys, just include them as-is (user needs to convert with ssh-to-age)
|
|
||||||
# Or they can run the update-age-keys.sh script
|
|
||||||
sshKeys =
|
|
||||||
if (lib.length (lib.attrNames sshPubFiles)) > 0 then
|
|
||||||
lib.trace "Warning: ${dirName} has unconverted SSH keys. Run secrets/update-age-keys.sh" [ ]
|
|
||||||
else
|
|
||||||
[ ];
|
|
||||||
in
|
|
||||||
lib.filter (k: k != null && k != "") (ageKeys ++ sshKeys);
|
|
||||||
|
|
||||||
# Build host key mappings: { hostname = [ "age1..." "age2..." ]; }
|
|
||||||
hostKeys = lib.listToAttrs (
|
|
||||||
lib.map (dir: nameValuePair dir (readHostKeys dir)) (
|
|
||||||
lib.filter (d: d != "global" && d != "admins") directories
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
# Global keys that all hosts can use
|
|
||||||
globalKeys = if lib.elem "global" directories then readHostKeys "global" else [ ];
|
|
||||||
|
|
||||||
# Admin keys for editing secrets
|
|
||||||
adminKeys = if lib.elem "admins" directories then readHostKeys "admins" else [ ];
|
|
||||||
|
|
||||||
# All host keys combined
|
|
||||||
allHostKeys = concatLists (lib.attrValues hostKeys);
|
|
||||||
|
|
||||||
# Find all .age files in the secrets directory
|
|
||||||
findSecrets =
|
|
||||||
dir:
|
|
||||||
let
|
|
||||||
dirPath = secretsPath + "/${dir}";
|
|
||||||
files = if lib.pathExists dirPath then lib.readDir dirPath else { };
|
|
||||||
ageFiles = filterAttrs (name: type: type == "regular" && hasSuffix ".age" name) files;
|
|
||||||
in
|
|
||||||
lib.map (name: "secrets/${dir}/${name}") (lib.attrNames ageFiles);
|
|
||||||
|
|
||||||
# Generate recipient list for a secret based on its location
|
|
||||||
getRecipients =
|
|
||||||
secretPath:
|
|
||||||
let
|
|
||||||
# Extract directory name from path: "secrets/nix-builder/foo.age" -> "nix-builder"
|
|
||||||
pathParts = lib.split "/" secretPath;
|
|
||||||
dirName = lib.elemAt pathParts 2;
|
|
||||||
in
|
|
||||||
if dirName == "global" then
|
|
||||||
# Global secrets: all hosts + admins
|
|
||||||
allHostKeys ++ globalKeys ++ adminKeys
|
|
||||||
else if hostKeys ? ${dirName} then
|
|
||||||
# Host-specific secrets: that host + global keys + admins
|
|
||||||
hostKeys.${dirName} ++ globalKeys ++ adminKeys
|
|
||||||
else
|
|
||||||
# Fallback: just admins
|
|
||||||
adminKeys;
|
|
||||||
|
|
||||||
# Find all secrets across all directories
|
|
||||||
allSecrets = concatLists (lib.map findSecrets directories);
|
|
||||||
|
|
||||||
# Generate the configuration
|
|
||||||
secretsConfig = lib.listToAttrs (
|
|
||||||
lib.map (
|
|
||||||
secretPath:
|
|
||||||
let
|
|
||||||
recipients = getRecipients secretPath;
|
|
||||||
# Remove duplicates and empty keys
|
|
||||||
uniqueRecipients = unique (lib.filter (k: k != null && k != "") recipients);
|
|
||||||
in
|
|
||||||
nameValuePair secretPath {
|
|
||||||
publicKeys = uniqueRecipients;
|
|
||||||
}
|
|
||||||
) allSecrets
|
|
||||||
);
|
|
||||||
|
|
||||||
# Generate wildcard rules for each directory to allow creating new secrets
|
|
||||||
wildcardRules = lib.listToAttrs (
|
|
||||||
lib.concatMap (dir: [
|
|
||||||
# Match with and without .age extension for ragenix compatibility
|
|
||||||
(nameValuePair "secrets/${dir}/*" {
|
|
||||||
publicKeys =
|
|
||||||
let
|
|
||||||
recipients = getRecipients "secrets/${dir}/dummy.age";
|
|
||||||
in
|
|
||||||
unique (lib.filter (k: k != null && k != "") recipients);
|
|
||||||
})
|
|
||||||
(nameValuePair "secrets/${dir}/*.age" {
|
|
||||||
publicKeys =
|
|
||||||
let
|
|
||||||
recipients = getRecipients "secrets/${dir}/dummy.age";
|
|
||||||
in
|
|
||||||
unique (lib.filter (k: k != null && k != "") recipients);
|
|
||||||
})
|
|
||||||
]) (lib.filter (d: d != "admins") directories)
|
|
||||||
);
|
|
||||||
|
|
||||||
in
|
|
||||||
secretsConfig // wildcardRules
|
|
||||||
@@ -1,174 +0,0 @@
|
|||||||
# Athenix Secrets System Design
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
The Athenix secrets management system integrates ragenix (agenix) with automatic host discovery based on the repository's fleet inventory structure. It provides a seamless workflow for managing encrypted secrets across all systems.
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
|
|
||||||
### Auto-Discovery Module (`sw/secrets.nix`)
|
|
||||||
|
|
||||||
**Purpose**: Automatically load and configure secrets at system deployment time.
|
|
||||||
|
|
||||||
**Features**:
|
|
||||||
- Discovers `.age` encrypted files from `secrets/` directories
|
|
||||||
- Loads global secrets from `secrets/global/` on ALL systems
|
|
||||||
- Loads host-specific secrets from `secrets/{hostname}/` on matching hosts
|
|
||||||
- Auto-configures decryption keys based on `.pub` files in directories
|
|
||||||
- Supports custom secret configuration via `default.nix` in each directory
|
|
||||||
|
|
||||||
**Key Behaviors**:
|
|
||||||
- Secrets are decrypted to `/run/agenix/{name}` at boot
|
|
||||||
- Identity paths include: system SSH keys + global keys + host-specific keys
|
|
||||||
- Host-specific secrets override global secrets with the same name
|
|
||||||
|
|
||||||
### Dynamic Recipients Configuration (`secrets/secrets.nix`)
|
|
||||||
|
|
||||||
**Purpose**: Generate ragenix recipient configuration from directory structure.
|
|
||||||
|
|
||||||
**Features**:
|
|
||||||
- Automatically discovers hosts from `secrets/` subdirectories
|
|
||||||
- Reads age public keys from `.age.pub` files (converted from SSH keys)
|
|
||||||
- Generates recipient lists based on secret location:
|
|
||||||
- `secrets/global/*.age` → ALL hosts + admins
|
|
||||||
- `secrets/{hostname}/*.age` → that host + global keys + admins
|
|
||||||
- Supports admin keys in `secrets/admins/` for secret editing
|
|
||||||
|
|
||||||
**Key Behaviors**:
|
|
||||||
- No manual recipient list maintenance required
|
|
||||||
- Adding a new host = create directory + add .pub key + run `update-age-keys.sh`
|
|
||||||
- Works with ragenix CLI: `ragenix -e`, `ragenix -r`
|
|
||||||
|
|
||||||
## Workflow
|
|
||||||
|
|
||||||
### Adding a New Host
|
|
||||||
|
|
||||||
1. **Capture SSH host key**:
|
|
||||||
```bash
|
|
||||||
# From the running system
|
|
||||||
cat /etc/ssh/ssh_host_ed25519_key.pub > secrets/new-host/ssh_host_ed25519_key.pub
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Convert to age format**:
|
|
||||||
```bash
|
|
||||||
cd secrets/
|
|
||||||
./update-age-keys.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
3. **Re-key existing secrets** (if needed):
|
|
||||||
```bash
|
|
||||||
ragenix -r
|
|
||||||
```
|
|
||||||
|
|
||||||
### Creating a New Secret
|
|
||||||
|
|
||||||
1. **Choose location**:
|
|
||||||
- `secrets/global/` → all systems can decrypt
|
|
||||||
- `secrets/{hostname}/` → only that host can decrypt
|
|
||||||
|
|
||||||
2. **Create/edit secret**:
|
|
||||||
```bash
|
|
||||||
ragenix -e secrets/global/my-secret.age
|
|
||||||
```
|
|
||||||
|
|
||||||
3. **Recipients are auto-determined** from `secrets.nix`:
|
|
||||||
- Global secrets: all host keys + admin keys
|
|
||||||
- Host-specific: that host + global keys + admin keys
|
|
||||||
|
|
||||||
### Cross-Host Secret Management
|
|
||||||
|
|
||||||
Any Athenix host can manage secrets for other hosts because:
|
|
||||||
- All public keys are in the repository (`*.age.pub` files)
|
|
||||||
- `secrets/secrets.nix` auto-generates recipient lists
|
|
||||||
- Hosts decrypt using their own private keys (not shared)
|
|
||||||
|
|
||||||
Example: From `nix-builder`, create a secret for `usda-dash`:
|
|
||||||
```bash
|
|
||||||
ragenix -e secrets/usda-dash/database-password.age
|
|
||||||
# Encrypted for usda-dash's public key + admins
|
|
||||||
# usda-dash will decrypt using its private key at /etc/ssh/ssh_host_ed25519_key
|
|
||||||
```
|
|
||||||
|
|
||||||
## Directory Structure
|
|
||||||
|
|
||||||
```
|
|
||||||
secrets/
|
|
||||||
├── secrets.nix # Auto-generated recipient config
|
|
||||||
├── update-age-keys.sh # Helper to convert SSH → age keys
|
|
||||||
├── README.md # User documentation
|
|
||||||
├── DESIGN.md # This file
|
|
||||||
│
|
|
||||||
├── global/ # Secrets for ALL hosts
|
|
||||||
│ ├── *.pub # SSH public keys
|
|
||||||
│ ├── *.age.pub # Age public keys (generated)
|
|
||||||
│ ├── *.age # Encrypted secrets
|
|
||||||
│ └── default.nix # Optional: custom secret config
|
|
||||||
│
|
|
||||||
├── {hostname}/ # Host-specific secrets
|
|
||||||
│ ├── *.pub
|
|
||||||
│ ├── *.age.pub
|
|
||||||
│ ├── *.age
|
|
||||||
│ └── default.nix
|
|
||||||
│
|
|
||||||
└── admins/ # Admin keys for editing
|
|
||||||
└── *.age.pub
|
|
||||||
```
|
|
||||||
|
|
||||||
## Security Model
|
|
||||||
|
|
||||||
1. **Public keys in git**: Safe to commit (only public keys, `.age.pub` and `.pub`)
|
|
||||||
2. **Private keys on hosts**: Never leave the system (`/etc/ssh/ssh_host_*_key`, `/etc/age/identity.key`)
|
|
||||||
3. **Encrypted secrets in git**: Safe to commit (`.age` files)
|
|
||||||
4. **Decrypted secrets**: Only in memory/tmpfs (`/run/agenix/*`)
|
|
||||||
|
|
||||||
## Integration Points
|
|
||||||
|
|
||||||
### With NixOS Configuration
|
|
||||||
|
|
||||||
```nix
|
|
||||||
# Access decrypted secrets in any NixOS module
|
|
||||||
config.age.secrets.my-secret.path # => /run/agenix/my-secret
|
|
||||||
|
|
||||||
# Example usage
|
|
||||||
services.myapp.passwordFile = config.age.secrets.database-password.path;
|
|
||||||
```
|
|
||||||
|
|
||||||
### With Inventory System
|
|
||||||
|
|
||||||
The system automatically matches `secrets/{hostname}/` to hostnames from `inventory.nix`. No manual configuration needed.
|
|
||||||
|
|
||||||
### With External Modules
|
|
||||||
|
|
||||||
External user/system modules can reference secrets:
|
|
||||||
```nix
|
|
||||||
# In external module
|
|
||||||
{ config, ... }:
|
|
||||||
{
|
|
||||||
programs.git.extraConfig.credential.helper =
|
|
||||||
"store --file ${config.age.secrets.git-credentials.path}";
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Advantages
|
|
||||||
|
|
||||||
1. **Zero manual recipient management**: Just add directories and keys
|
|
||||||
2. **Cross-host secret creation**: Any host can manage secrets for others
|
|
||||||
3. **Automatic host discovery**: Syncs with inventory structure
|
|
||||||
4. **Flexible permission model**: Global vs host-specific + custom configs
|
|
||||||
5. **Version controlled**: All public data in git, auditable history
|
|
||||||
6. **Secure by default**: Private keys never shared, secrets encrypted at rest
|
|
||||||
|
|
||||||
## Limitations
|
|
||||||
|
|
||||||
1. **Requires age key conversion**: SSH keys must be converted to age format (automated by script)
|
|
||||||
2. **Bootstrap chicken-egg**: Need initial host key before encrypting secrets (capture from first boot or generate locally)
|
|
||||||
3. **No secret rotation automation**: Must manually re-key with `ragenix -r`
|
|
||||||
4. **Git history contains old encrypted versions**: Rotating keys doesn't remove old ciphertexts from history
|
|
||||||
|
|
||||||
## Future Enhancements
|
|
||||||
|
|
||||||
- Auto-run `update-age-keys.sh` in pre-commit hook
|
|
||||||
- Integrate with inventory.nix to auto-generate host directories
|
|
||||||
- Support for multiple identity types per host
|
|
||||||
- Automated secret rotation scheduling
|
|
||||||
- Integration with hardware security modules (YubiKey, etc.)
|
|
||||||
@@ -1,250 +0,0 @@
|
|||||||
# Secrets Management with Agenix
|
|
||||||
|
|
||||||
This directory contains age-encrypted secrets for Athenix hosts. Secrets are automatically loaded based on directory structure.
|
|
||||||
|
|
||||||
## Directory Structure
|
|
||||||
|
|
||||||
```
|
|
||||||
secrets/
|
|
||||||
├── global/ # Secrets installed on ALL systems
|
|
||||||
│ ├── default.nix # Optional: Custom config for global secrets
|
|
||||||
│ └── example.age # Decrypted to /run/agenix/example on all hosts
|
|
||||||
├── nix-builder/ # Secrets only for nix-builder host
|
|
||||||
│ ├── default.nix # Optional: Custom config for nix-builder secrets
|
|
||||||
│ └── ssh_host_ed25519_key.age
|
|
||||||
└── usda-dash/ # Secrets only for usda-dash host
|
|
||||||
└── ssh_host_ed25519_key.age
|
|
||||||
```
|
|
||||||
|
|
||||||
## How It Works
|
|
||||||
|
|
||||||
1. **Global secrets** (`./secrets/global/*.age`) are installed on every system
|
|
||||||
2. **Host-specific secrets** (`./secrets/{hostname}/*.age`) are only installed on matching hosts
|
|
||||||
3. Only `.age` encrypted files are loaded; `.pub` public keys are ignored
|
|
||||||
4. Secrets are decrypted at boot to `/run/agenix/{secret-name}` with mode `0400` and owner `root:root`
|
|
||||||
5. **Custom configurations** can be defined in `default.nix` files within each directory
|
|
||||||
|
|
||||||
## Creating Secrets
|
|
||||||
|
|
||||||
### 1. Generate Age Keys
|
|
||||||
|
|
||||||
For a new host, generate an age identity:
|
|
||||||
```bash
|
|
||||||
# On the target system
|
|
||||||
mkdir -p /etc/age
|
|
||||||
age-keygen -o /etc/age/identity.key
|
|
||||||
chmod 600 /etc/age/identity.key
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use SSH host keys (automatically done by Athenix):
|
|
||||||
```bash
|
|
||||||
# Get the age public key from SSH host key
|
|
||||||
nix shell nixpkgs#ssh-to-age -c sh -c 'cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age'
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Store Public Keys
|
|
||||||
|
|
||||||
Save the public key to `secrets/{hostname}/` for reference:
|
|
||||||
```bash
|
|
||||||
# Example for nix-builder
|
|
||||||
echo "age1..." > secrets/nix-builder/identity.pub
|
|
||||||
```
|
|
||||||
|
|
||||||
Or from SSH host key:
|
|
||||||
```bash
|
|
||||||
cat /etc/ssh/ssh_host_ed25519_key.pub > secrets/nix-builder/ssh_host_ed25519_key.pub
|
|
||||||
```
|
|
||||||
|
|
||||||
**Then convert SSH keys to age format:**
|
|
||||||
```bash
|
|
||||||
cd secrets/
|
|
||||||
./update-age-keys.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
This creates `.age.pub` files that `secrets.nix` uses for ragenix recipient configuration.
|
|
||||||
|
|
||||||
### 3. Encrypt Secrets
|
|
||||||
|
|
||||||
Encrypt a secret for specific hosts:
|
|
||||||
```bash
|
|
||||||
# For a single host
|
|
||||||
age -r age1publickey... -o secrets/nix-builder/my-secret.age <<< "secret value"
|
|
||||||
|
|
||||||
# For multiple hosts (recipient list)
|
|
||||||
age -R recipients.txt -o secrets/global/shared-secret.age < plaintext-file
|
|
||||||
|
|
||||||
# Using SSH public keys
|
|
||||||
age -R secrets/nix-builder/ssh_host_ed25519_key.pub \
|
|
||||||
-o secrets/nix-builder/ssh_host_key.age < /etc/ssh/ssh_host_ed25519_key
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. Creating and Editing Secrets
|
|
||||||
|
|
||||||
**For new secrets**, use the helper script (automatically determines recipients):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd secrets/
|
|
||||||
|
|
||||||
# Create a host-specific secret
|
|
||||||
./create-secret.sh usda-dash/database-url.age <<< "postgresql://..."
|
|
||||||
|
|
||||||
# Create a global secret
|
|
||||||
echo "shared-api-key" | ./create-secret.sh global/api-key.age
|
|
||||||
|
|
||||||
# From a file
|
|
||||||
./create-secret.sh nix-builder/ssh-key.age < ~/.ssh/id_ed25519
|
|
||||||
```
|
|
||||||
|
|
||||||
The script automatically includes the correct recipients:
|
|
||||||
- **Host-specific**: that host's keys + global keys + admin keys
|
|
||||||
- **Global**: all host keys + admin keys
|
|
||||||
|
|
||||||
**To edit existing secrets**, use `ragenix`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Install ragenix
|
|
||||||
nix shell github:yaxitech/ragenix
|
|
||||||
|
|
||||||
# Edit an existing secret (you must have a decryption key)
|
|
||||||
ragenix -e secrets/global/existing-secret.age
|
|
||||||
|
|
||||||
# Re-key all secrets after adding new hosts
|
|
||||||
ragenix -r
|
|
||||||
```
|
|
||||||
|
|
||||||
**Why create with `age` first?** Ragenix requires the `.age` file to exist before editing. The `secrets/secrets.nix` configuration auto-discovers recipients from the directory structure, but ragenix doesn't support wildcard patterns for creating new files.
|
|
||||||
|
|
||||||
**Recipient management** is automatic:
|
|
||||||
- **Global secrets** (`secrets/global/*.age`): encrypted for ALL hosts + admins
|
|
||||||
- **Host secrets** (`secrets/{hostname}/*.age`): encrypted for that host + global keys + admins
|
|
||||||
- **Admin keys** from `secrets/admins/*.age.pub` allow editing from your workstation
|
|
||||||
|
|
||||||
After creating new .age files with `age`, use `ragenix -r` to re-key all secrets with the updated recipient configuration.
|
|
||||||
|
|
||||||
To add admin keys for editing secrets:
|
|
||||||
```bash
|
|
||||||
# Generate personal age key
|
|
||||||
age-keygen -o ~/.config/age/personal.key
|
|
||||||
|
|
||||||
# Extract public key and add to secrets
|
|
||||||
grep "public key:" ~/.config/age/personal.key | cut -d: -f2 | tr -d ' ' > secrets/admins/your-name.age.pub
|
|
||||||
```
|
|
||||||
|
|
||||||
## Using Secrets in Configuration
|
|
||||||
|
|
||||||
Secrets are automatically loaded. Reference them in your NixOS configuration:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
# Example: Using a secret for a service
|
|
||||||
services.myservice = {
|
|
||||||
enable = true;
|
|
||||||
passwordFile = config.age.secrets.my-password.path; # /run/agenix/my-password
|
|
||||||
};
|
|
||||||
|
|
||||||
# Example: Setting up SSH host key from secret
|
|
||||||
services.openssh = {
|
|
||||||
hostKeys = [{
|
|
||||||
path = config.age.secrets.ssh_host_ed25519_key.path;
|
|
||||||
type = "ed25519";
|
|
||||||
}];
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
## Custom Secret Configuration
|
|
||||||
|
|
||||||
For secrets needing custom permissions, use `athenix.sw.secrets.extraSecrets`:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
# In inventory.nix or host config
|
|
||||||
athenix.sw.secrets.extraSecrets = {
|
|
||||||
"nginx-cert" = {
|
|
||||||
file = ./secrets/custom/cert.age;
|
|
||||||
mode = "0440";
|
|
||||||
owner = "nginx";
|
|
||||||
group = "nginx";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
### Using default.nix in Secret Directories
|
|
||||||
|
|
||||||
Alternatively, create a `default.nix` file in the secret directory to configure all secrets in that directory:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
# secrets/global/default.nix
|
|
||||||
{
|
|
||||||
"example" = {
|
|
||||||
mode = "0440"; # Custom file mode (default: "0400")
|
|
||||||
owner = "nginx"; # Custom owner (default: "root")
|
|
||||||
group = "nginx"; # Custom group (default: "root")
|
|
||||||
path = "/run/secrets/example"; # Custom path (default: /run/agenix/{name})
|
|
||||||
};
|
|
||||||
|
|
||||||
"api-key" = {
|
|
||||||
mode = "0400";
|
|
||||||
owner = "myservice";
|
|
||||||
group = "myservice";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
The `default.nix` file should return an attribute set where:
|
|
||||||
- **Keys** are secret names (without the `.age` extension)
|
|
||||||
- **Values** are configuration objects with optional fields:
|
|
||||||
- `mode` - File permissions (string, e.g., `"0440"`)
|
|
||||||
- `owner` - File owner (string, e.g., `"nginx"`)
|
|
||||||
- `group` - File group (string, e.g., `"nginx"`)
|
|
||||||
- `path` - Custom installation path (string, e.g., `"/custom/path"`)
|
|
||||||
|
|
||||||
Secrets not listed in `default.nix` will use default settings.
|
|
||||||
|
|
||||||
## Security Best Practices
|
|
||||||
|
|
||||||
1. **Never commit unencrypted secrets** - Only `.age` and `.pub` files belong in this directory
|
|
||||||
2. **Use host-specific secrets** when possible - Limit exposure by using hostname directories
|
|
||||||
3. **Rotate secrets regularly** - Re-encrypt with new keys periodically
|
|
||||||
4. **Backup age identity keys** - Store `/etc/age/identity.key` securely offline
|
|
||||||
5. **Use SSH keys** - Leverage existing SSH host keys for age encryption when possible
|
|
||||||
6. **Pin to commits** - When using external secrets modules, always use `rev = "commit-hash"`
|
|
||||||
|
|
||||||
## Converting SSH Keys to Age Format
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Convert SSH public key to age public key
|
|
||||||
nix shell nixpkgs#ssh-to-age -c ssh-to-age < secrets/nix-builder/ssh_host_ed25519_key.pub
|
|
||||||
|
|
||||||
# Convert SSH private key to age identity (for editing secrets)
|
|
||||||
nix shell nixpkgs#ssh-to-age -c ssh-to-age -private-key -i ~/.ssh/id_ed25519
|
|
||||||
```
|
|
||||||
|
|
||||||
## Disabling Automatic Secrets
|
|
||||||
|
|
||||||
To disable automatic secret loading:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
# In inventory.nix or host config
|
|
||||||
athenix.sw.secrets.enable = false;
|
|
||||||
```
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
### Secret not found
|
|
||||||
- Ensure the `.age` file exists in `secrets/global/` or `secrets/{hostname}/`
|
|
||||||
- Check `hostname` matches directory name: `echo $HOSTNAME` on the target system
|
|
||||||
- Run `nix flake check` to verify secrets are discovered
|
|
||||||
|
|
||||||
### Permission denied
|
|
||||||
- Verify secret permissions in `/run/agenix/`
|
|
||||||
- Check if custom permissions are needed (use `extraSecrets`)
|
|
||||||
- Ensure the service user/group has access to the secret file
|
|
||||||
|
|
||||||
### Age decrypt failed
|
|
||||||
- Verify the host's age identity exists: `ls -l /etc/age/identity.key`
|
|
||||||
- Check that the secret was encrypted with the host's public key
|
|
||||||
- Confirm SSH host key hasn't changed (would change derived age key)
|
|
||||||
|
|
||||||
## References
|
|
||||||
|
|
||||||
- [ragenix GitHub](https://github.com/yaxitech/ragenix)
|
|
||||||
- [agenix upstream](https://github.com/ryantm/agenix)
|
|
||||||
- [age encryption tool](https://age-encryption.org/)
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
age14emzyraytqzmre58c452t07rtcj87cwqwmd9z3gj7upugtxk8s3sda5tju
|
|
||||||
BIN
secrets/core
BIN
secrets/core
Binary file not shown.
@@ -1,121 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# Create a new age-encrypted secret with auto-determined recipients
|
|
||||||
# Usage: ./create-secret.sh <path> [content]
|
|
||||||
# path: relative to secrets/ (e.g., "usda-dash/my-secret.age" or "global/shared.age")
|
|
||||||
# content: stdin if not provided
|
|
||||||
|
|
||||||
SECRETS_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
||||||
|
|
||||||
if [ $# -lt 1 ]; then
|
|
||||||
echo "Usage: $0 <path> [content]" >&2
|
|
||||||
echo "Examples:" >&2
|
|
||||||
echo " $0 usda-dash/database-url.age <<< 'postgresql://...'" >&2
|
|
||||||
echo " $0 global/api-key.age < secret-file.txt" >&2
|
|
||||||
echo " echo 'secret' | $0 nix-builder/token.age" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
SECRET_PATH="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
# Extract directory from path (e.g., "usda-dash/file.age" -> "usda-dash")
|
|
||||||
SECRET_DIR="$(dirname "$SECRET_PATH")"
|
|
||||||
SECRET_FILE="$(basename "$SECRET_PATH")"
|
|
||||||
|
|
||||||
# Ensure .age extension
|
|
||||||
if [[ ! "$SECRET_FILE" =~ \.age$ ]]; then
|
|
||||||
echo "Error: Secret file must have .age extension" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
TARGET_FILE="$SECRETS_DIR/$SECRET_PATH"
|
|
||||||
|
|
||||||
# Ensure target directory exists
|
|
||||||
mkdir -p "$(dirname "$TARGET_FILE")"
|
|
||||||
|
|
||||||
# Collect recipient keys
|
|
||||||
RECIPIENTS=()
|
|
||||||
|
|
||||||
if [ "$SECRET_DIR" = "global" ]; then
|
|
||||||
echo "Creating global secret (encrypted for all hosts + admins)..." >&2
|
|
||||||
|
|
||||||
# Add all host keys
|
|
||||||
for host_dir in "$SECRETS_DIR"/*/; do
|
|
||||||
host_name="$(basename "$host_dir")"
|
|
||||||
# Skip non-host directories
|
|
||||||
if [ "$host_name" = "admins" ] || [ "$host_name" = "global" ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add all .age.pub files from this host
|
|
||||||
while IFS= read -r -d '' key_file; do
|
|
||||||
RECIPIENTS+=("$key_file")
|
|
||||||
done < <(find "$host_dir" -maxdepth 1 -name "*.age.pub" -print0)
|
|
||||||
done
|
|
||||||
|
|
||||||
# Add global keys
|
|
||||||
while IFS= read -r -d '' key_file; do
|
|
||||||
RECIPIENTS+=("$key_file")
|
|
||||||
done < <(find "$SECRETS_DIR/global" -maxdepth 1 -name "*.age.pub" -print0 2>/dev/null || true)
|
|
||||||
|
|
||||||
else
|
|
||||||
echo "Creating host-specific secret for $SECRET_DIR..." >&2
|
|
||||||
|
|
||||||
# Check if host directory exists
|
|
||||||
if [ ! -d "$SECRETS_DIR/$SECRET_DIR" ]; then
|
|
||||||
echo "Error: Host directory $SECRET_DIR does not exist" >&2
|
|
||||||
echo "Create it first: mkdir -p secrets/$SECRET_DIR" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add this host's keys
|
|
||||||
while IFS= read -r -d '' key_file; do
|
|
||||||
RECIPIENTS+=("$key_file")
|
|
||||||
done < <(find "$SECRETS_DIR/$SECRET_DIR" -maxdepth 1 -name "*.age.pub" -print0)
|
|
||||||
|
|
||||||
# Add global keys (so global hosts can also decrypt)
|
|
||||||
while IFS= read -r -d '' key_file; do
|
|
||||||
RECIPIENTS+=("$key_file")
|
|
||||||
done < <(find "$SECRETS_DIR/global" -maxdepth 1 -name "*.age.pub" -print0 2>/dev/null || true)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add admin keys (for editing from workstations)
|
|
||||||
if [ -d "$SECRETS_DIR/admins" ]; then
|
|
||||||
while IFS= read -r -d '' key_file; do
|
|
||||||
RECIPIENTS+=("$key_file")
|
|
||||||
done < <(find "$SECRETS_DIR/admins" -maxdepth 1 -name "*.age.pub" -print0 2>/dev/null || true)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if we have any recipients
|
|
||||||
if [ ${#RECIPIENTS[@]} -eq 0 ]; then
|
|
||||||
echo "Error: No recipient keys found!" >&2
|
|
||||||
echo "Run ./update-age-keys.sh first to generate .age.pub files" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Found ${#RECIPIENTS[@]} recipient key(s):" >&2
|
|
||||||
for key in "${RECIPIENTS[@]}"; do
|
|
||||||
echo " - $(basename "$key")" >&2
|
|
||||||
done
|
|
||||||
|
|
||||||
# Create recipient list file (temporary)
|
|
||||||
RECIPIENT_LIST=$(mktemp)
|
|
||||||
trap "rm -f $RECIPIENT_LIST" EXIT
|
|
||||||
|
|
||||||
for key in "${RECIPIENTS[@]}"; do
|
|
||||||
cat "$key" >> "$RECIPIENT_LIST"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Encrypt the secret
|
|
||||||
if [ $# -gt 0 ]; then
|
|
||||||
# Content provided as argument
|
|
||||||
echo "$@" | age -R "$RECIPIENT_LIST" -o "$TARGET_FILE"
|
|
||||||
else
|
|
||||||
# Content from stdin
|
|
||||||
age -R "$RECIPIENT_LIST" -o "$TARGET_FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "✓ Created $TARGET_FILE" >&2
|
|
||||||
echo " Edit with: ragenix -e secrets/$SECRET_PATH" >&2
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
age1udmpqkedupd33gyut85ud3nvppydzeg04kkuneymkvxcjjej244s4v8xjc
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# Host-specific secret configuration for nix-builder
|
|
||||||
{
|
|
||||||
# SSH host key should be readable by sshd
|
|
||||||
ssh_host_ed25519_key = {
|
|
||||||
mode = "0600";
|
|
||||||
owner = "root";
|
|
||||||
group = "root";
|
|
||||||
path = "/etc/ssh/ssh_host_ed25519_key";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
age1u5tczg2sx90n03uuz9h549f4h3h7sq5uehhqpampzs7vj8ew7y6s2mjwz0
|
|
||||||
@@ -1,176 +0,0 @@
|
|||||||
# ============================================================================
|
|
||||||
# Agenix Secret Recipients Configuration (Auto-Generated)
|
|
||||||
# ============================================================================
|
|
||||||
# This file automatically discovers hosts and their public keys from the
|
|
||||||
# secrets/ directory structure and generates recipient configurations.
|
|
||||||
#
|
|
||||||
# Directory structure:
|
|
||||||
# secrets/{hostname}/*.pub -> SSH/age public keys for that host
|
|
||||||
# secrets/global/*.pub -> Keys accessible to all hosts
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# ragenix -e secrets/global/example.age # Edit/create secret
|
|
||||||
# ragenix -r # Re-key all secrets
|
|
||||||
#
|
|
||||||
# To add admin keys for editing secrets, create secrets/admins/*.pub files
|
|
||||||
# with your personal age public keys (generated with: age-keygen)
|
|
||||||
|
|
||||||
let
|
|
||||||
lib = builtins;
|
|
||||||
|
|
||||||
# Helper functions not in builtins
|
|
||||||
filterAttrs =
|
|
||||||
pred: set:
|
|
||||||
lib.listToAttrs (
|
|
||||||
lib.filter (item: pred item.name item.value) (
|
|
||||||
lib.map (name: {
|
|
||||||
inherit name;
|
|
||||||
value = set.${name};
|
|
||||||
}) (lib.attrNames set)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
concatLists = lists: lib.foldl' (acc: list: acc ++ list) [ ] lists;
|
|
||||||
|
|
||||||
unique =
|
|
||||||
list:
|
|
||||||
let
|
|
||||||
go =
|
|
||||||
acc: remaining:
|
|
||||||
if remaining == [ ] then
|
|
||||||
acc
|
|
||||||
else if lib.elem (lib.head remaining) acc then
|
|
||||||
go acc (lib.tail remaining)
|
|
||||||
else
|
|
||||||
go (acc ++ [ (lib.head remaining) ]) (lib.tail remaining);
|
|
||||||
in
|
|
||||||
go [ ] list;
|
|
||||||
|
|
||||||
hasSuffix =
|
|
||||||
suffix: str:
|
|
||||||
let
|
|
||||||
lenStr = lib.stringLength str;
|
|
||||||
lenSuffix = lib.stringLength suffix;
|
|
||||||
in
|
|
||||||
lenStr >= lenSuffix && lib.substring (lenStr - lenSuffix) lenSuffix str == suffix;
|
|
||||||
|
|
||||||
nameValuePair = name: value: { inherit name value; };
|
|
||||||
|
|
||||||
secretsPath = ./secrets;
|
|
||||||
|
|
||||||
# Read all directories in secrets/
|
|
||||||
secretDirs = if lib.pathExists secretsPath then lib.readDir secretsPath else { };
|
|
||||||
|
|
||||||
# Filter to only directories (excludes files)
|
|
||||||
isDirectory = name: type: type == "directory";
|
|
||||||
directories = lib.filter (name: isDirectory name secretDirs.${name}) (lib.attrNames secretDirs);
|
|
||||||
|
|
||||||
# Read public keys from a directory and convert to age format
|
|
||||||
readHostKeys =
|
|
||||||
dirName:
|
|
||||||
let
|
|
||||||
dirPath = secretsPath + "/${dirName}";
|
|
||||||
files = if lib.pathExists dirPath then lib.readDir dirPath else { };
|
|
||||||
|
|
||||||
# Prefer .age.pub files (pre-converted), fall back to .pub files
|
|
||||||
agePubFiles = filterAttrs (name: type: type == "regular" && hasSuffix ".age.pub" name) files;
|
|
||||||
|
|
||||||
sshPubFiles = filterAttrs (
|
|
||||||
name: type: type == "regular" && hasSuffix ".pub" name && !(hasSuffix ".age.pub" name)
|
|
||||||
) files;
|
|
||||||
|
|
||||||
# Read age public keys (already in correct format)
|
|
||||||
ageKeys = lib.map (
|
|
||||||
name:
|
|
||||||
let
|
|
||||||
content = lib.readFile (dirPath + "/${name}");
|
|
||||||
# Trim whitespace/newlines
|
|
||||||
trimmed = lib.replaceStrings [ "\n" " " "\r" "\t" ] [ "" "" "" "" ] content;
|
|
||||||
in
|
|
||||||
trimmed
|
|
||||||
) (lib.attrNames agePubFiles);
|
|
||||||
|
|
||||||
# For SSH keys, just include them as-is (user needs to convert with ssh-to-age)
|
|
||||||
# Or they can run the update-age-keys.sh script
|
|
||||||
sshKeys =
|
|
||||||
if (lib.length (lib.attrNames sshPubFiles)) > 0 then
|
|
||||||
lib.trace "Warning: ${dirName} has unconverted SSH keys. Run secrets/update-age-keys.sh" [ ]
|
|
||||||
else
|
|
||||||
[ ];
|
|
||||||
in
|
|
||||||
lib.filter (k: k != null && k != "") (ageKeys ++ sshKeys);
|
|
||||||
|
|
||||||
# Build host key mappings: { hostname = [ "age1..." "age2..." ]; }
|
|
||||||
hostKeys = lib.listToAttrs (
|
|
||||||
lib.map (dir: nameValuePair dir (readHostKeys dir)) (
|
|
||||||
lib.filter (d: d != "global" && d != "admins") directories
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
# Global keys that all hosts can use
|
|
||||||
globalKeys = if lib.elem "global" directories then readHostKeys "global" else [ ];
|
|
||||||
|
|
||||||
# Admin keys for editing secrets
|
|
||||||
adminKeys = if lib.elem "admins" directories then readHostKeys "admins" else [ ];
|
|
||||||
|
|
||||||
# All host keys combined
|
|
||||||
allHostKeys = concatLists (lib.attrValues hostKeys);
|
|
||||||
|
|
||||||
# Find all .age files in the secrets directory
|
|
||||||
findSecrets =
|
|
||||||
dir:
|
|
||||||
let
|
|
||||||
dirPath = secretsPath + "/${dir}";
|
|
||||||
files = if lib.pathExists dirPath then lib.readDir dirPath else { };
|
|
||||||
ageFiles = filterAttrs (name: type: type == "regular" && hasSuffix ".age" name) files;
|
|
||||||
in
|
|
||||||
lib.map (name: "secrets/${dir}/${name}") (lib.attrNames ageFiles);
|
|
||||||
|
|
||||||
# Generate recipient list for a secret based on its location
|
|
||||||
getRecipients =
|
|
||||||
secretPath:
|
|
||||||
let
|
|
||||||
# Extract directory name from path: "secrets/nix-builder/foo.age" -> "nix-builder"
|
|
||||||
pathParts = lib.split "/" secretPath;
|
|
||||||
dirName = lib.elemAt pathParts 2;
|
|
||||||
in
|
|
||||||
if dirName == "global" then
|
|
||||||
# Global secrets: all hosts + admins
|
|
||||||
allHostKeys ++ globalKeys ++ adminKeys
|
|
||||||
else if hostKeys ? ${dirName} then
|
|
||||||
# Host-specific secrets: that host + global keys + admins
|
|
||||||
hostKeys.${dirName} ++ globalKeys ++ adminKeys
|
|
||||||
else
|
|
||||||
# Fallback: just admins
|
|
||||||
adminKeys;
|
|
||||||
|
|
||||||
# Find all secrets across all directories
|
|
||||||
allSecrets = concatLists (lib.map findSecrets directories);
|
|
||||||
|
|
||||||
# Generate the configuration
|
|
||||||
secretsConfig = lib.listToAttrs (
|
|
||||||
lib.map (
|
|
||||||
secretPath:
|
|
||||||
let
|
|
||||||
recipients = getRecipients secretPath;
|
|
||||||
# Remove duplicates and empty keys
|
|
||||||
uniqueRecipients = unique (lib.filter (k: k != null && k != "") recipients);
|
|
||||||
in
|
|
||||||
nameValuePair secretPath {
|
|
||||||
publicKeys = uniqueRecipients;
|
|
||||||
}
|
|
||||||
) allSecrets
|
|
||||||
);
|
|
||||||
|
|
||||||
in
|
|
||||||
secretsConfig
|
|
||||||
// {
|
|
||||||
# Export helper information for debugging
|
|
||||||
_meta = {
|
|
||||||
hostKeys = hostKeys;
|
|
||||||
globalKeys = globalKeys;
|
|
||||||
adminKeys = adminKeys;
|
|
||||||
allHostKeys = allHostKeys;
|
|
||||||
discoveredSecrets = allSecrets;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# ============================================================================
|
|
||||||
# Update Age Keys from SSH Public Keys
|
|
||||||
# ============================================================================
|
|
||||||
# This script converts SSH public keys to age format for use with ragenix.
|
|
||||||
# Run this after adding new SSH .pub files to create corresponding .age.pub files.
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
cd "$SCRIPT_DIR"
|
|
||||||
|
|
||||||
echo "Converting SSH public keys to age format..."
|
|
||||||
|
|
||||||
# Find all .pub files that are SSH keys (not already .age.pub)
|
|
||||||
find . -name "*.pub" -not -name "*.age.pub" -type f | while read -r pubkey; do
|
|
||||||
# Check if it's an SSH key
|
|
||||||
if grep -q "^ssh-" "$pubkey" 2>/dev/null || grep -q "^ecdsa-" "$pubkey" 2>/dev/null; then
|
|
||||||
age_key=$(nix shell nixpkgs#ssh-to-age -c ssh-to-age < "$pubkey" 2>/dev/null || true)
|
|
||||||
|
|
||||||
if [ -n "$age_key" ]; then
|
|
||||||
# Create .age.pub file with the age key
|
|
||||||
age_file="${pubkey%.pub}.age.pub"
|
|
||||||
echo "$age_key" > "$age_file"
|
|
||||||
echo "✓ Converted: $pubkey -> $age_file"
|
|
||||||
else
|
|
||||||
echo "⚠ Skipped: $pubkey (conversion failed)"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "Done! Age public keys have been generated."
|
|
||||||
echo "You can now use ragenix to manage secrets:"
|
|
||||||
echo " ragenix -e secrets/global/my-secret.age"
|
|
||||||
echo " ragenix -r # Re-key all secrets with updated keys"
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
# Host-specific secret configuration for usda-dash
|
|
||||||
{
|
|
||||||
usda-vision-azure-env = {
|
|
||||||
mode = "0600";
|
|
||||||
owner = "root";
|
|
||||||
group = "root";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
age1lr24yvk7rdfh5wkle7h32jpxqxm2e8vk85mc4plv370u2sh4yfmszaaejx
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHI73LOEK2RgfjhZWpryntlLbx0LouHrhQ6v0vZu4Etr root@usda-dash
|
|
||||||
Binary file not shown.
@@ -11,123 +11,21 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with lib;
|
lib.mkMerge [
|
||||||
|
(import ./programs.nix {
|
||||||
let
|
inherit
|
||||||
cfg = config.athenix.sw.builders;
|
config
|
||||||
in
|
lib
|
||||||
{
|
pkgs
|
||||||
options.athenix.sw.builders = mkOption {
|
inputs
|
||||||
type = lib.types.submodule {
|
;
|
||||||
options = {
|
})
|
||||||
enable = mkOption {
|
(import ./services.nix {
|
||||||
type = lib.types.bool;
|
inherit
|
||||||
default = false;
|
config
|
||||||
description = ''
|
lib
|
||||||
Enable build server configuration.
|
pkgs
|
||||||
|
inputs
|
||||||
Includes:
|
;
|
||||||
- SSH host keys for common Git servers (factory.uga.edu, github.com)
|
})
|
||||||
- Gitea Actions runner support (optional)
|
]
|
||||||
- Build tools and dependencies
|
|
||||||
|
|
||||||
Recommended for: CI/CD servers, build containers, development infrastructure
|
|
||||||
'';
|
|
||||||
example = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
giteaRunner = mkOption {
|
|
||||||
type = lib.types.submodule {
|
|
||||||
options = {
|
|
||||||
enable = mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = false;
|
|
||||||
description = ''
|
|
||||||
Enable Gitea Actions self-hosted runner.
|
|
||||||
|
|
||||||
This runner will connect to a Gitea instance and execute CI/CD workflows.
|
|
||||||
Requires manual setup of the token file before the service will start.
|
|
||||||
'';
|
|
||||||
example = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
url = mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = ''
|
|
||||||
URL of the Gitea instance to connect to.
|
|
||||||
This should be the base URL without any path components.
|
|
||||||
'';
|
|
||||||
example = "https://git.factory.uga.edu";
|
|
||||||
};
|
|
||||||
|
|
||||||
tokenFile = mkOption {
|
|
||||||
type = lib.types.path;
|
|
||||||
default = "/var/lib/gitea-runner-token";
|
|
||||||
description = ''
|
|
||||||
Path to file containing Gitea runner registration token.
|
|
||||||
|
|
||||||
To generate:
|
|
||||||
1. Go to your Gitea repository settings
|
|
||||||
2. Navigate to Actions > Runners
|
|
||||||
3. Click "Create new Runner"
|
|
||||||
4. Save the token to this file:
|
|
||||||
echo "TOKEN=your-token-here" | sudo tee /var/lib/gitea-runner-token > /dev/null
|
|
||||||
|
|
||||||
The service will not start until this file exists.
|
|
||||||
'';
|
|
||||||
example = "/var/secrets/gitea-runner-token";
|
|
||||||
};
|
|
||||||
|
|
||||||
extraLabels = mkOption {
|
|
||||||
type = lib.types.listOf lib.types.str;
|
|
||||||
default = [ ];
|
|
||||||
description = ''
|
|
||||||
Additional labels to identify this runner in workflow files.
|
|
||||||
Use labels to target specific runners for different job types.
|
|
||||||
'';
|
|
||||||
example = [
|
|
||||||
"self-hosted"
|
|
||||||
"nix"
|
|
||||||
"x86_64-linux"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
name = mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "athenix";
|
|
||||||
description = ''
|
|
||||||
Unique name for this runner instance.
|
|
||||||
Shown in Gitea's runner list and logs.
|
|
||||||
'';
|
|
||||||
example = "nix-builder-1";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
default = { };
|
|
||||||
description = "Gitea Actions runner configuration.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
default = { };
|
|
||||||
description = "Build server configuration (CI/CD, Gitea Actions).";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
|
||||||
(import ./programs.nix {
|
|
||||||
inherit
|
|
||||||
config
|
|
||||||
lib
|
|
||||||
pkgs
|
|
||||||
inputs
|
|
||||||
;
|
|
||||||
})
|
|
||||||
(import ./services.nix {
|
|
||||||
inherit
|
|
||||||
config
|
|
||||||
lib
|
|
||||||
pkgs
|
|
||||||
inputs
|
|
||||||
;
|
|
||||||
})
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@@ -8,7 +10,7 @@ with lib;
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.athenix.sw;
|
cfg = config.athenix.sw;
|
||||||
basePackages = [
|
basePackages = with pkgs; [
|
||||||
# Build-related packages can be added here if needed
|
# Build-related packages can be added here if needed
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
|
|||||||
212
sw/default.nix
212
sw/default.nix
@@ -10,14 +10,19 @@
|
|||||||
# Software Module Entry Point
|
# Software Module Entry Point
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# This module manages the software configuration for the system. It provides
|
# This module manages the software configuration for the system. It provides
|
||||||
# enable options for each system type (desktop, headless, builders, etc.)
|
# options to select the system type ('desktop' or 'kiosk') and handles
|
||||||
# that can be enabled independently or in combination. Each type is a proper
|
# the conditional importation of the appropriate sub-modules.
|
||||||
# NixOS submodule with its own enable flag and type-specific options.
|
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.athenix.sw;
|
cfg = config.athenix.sw;
|
||||||
|
|
||||||
|
# Normalize type to always be a list
|
||||||
|
swTypes = if isList cfg.type then cfg.type else [ cfg.type ];
|
||||||
|
|
||||||
|
# Helper to check if a type is enabled
|
||||||
|
hasType = type: elem type swTypes;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
@@ -26,82 +31,169 @@ in
|
|||||||
./gc.nix
|
./gc.nix
|
||||||
./updater.nix
|
./updater.nix
|
||||||
./update-ref.nix
|
./update-ref.nix
|
||||||
./secrets.nix
|
|
||||||
./desktop
|
|
||||||
./headless
|
|
||||||
./builders
|
|
||||||
./tablet-kiosk
|
|
||||||
./stateless-kiosk
|
|
||||||
inputs.home-manager.nixosModules.home-manager
|
inputs.home-manager.nixosModules.home-manager
|
||||||
inputs.agenix.nixosModules.default
|
inputs.agenix.nixosModules.default
|
||||||
inputs.disko.nixosModules.disko
|
inputs.disko.nixosModules.disko
|
||||||
];
|
];
|
||||||
|
|
||||||
options.athenix.sw = {
|
options.athenix.sw = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Standard Workstation Configuration";
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
description = ''
|
|
||||||
Enable standard workstation configuration with base packages.
|
|
||||||
|
|
||||||
Provides:
|
|
||||||
- Base CLI tools (htop, git, binutils)
|
|
||||||
- Shell configuration (Zsh)
|
|
||||||
- Secret management (agenix)
|
|
||||||
- Oh My Posh shell theme
|
|
||||||
|
|
||||||
This is typically enabled automatically when any sw type is enabled.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = lib.types.nullOr (lib.types.either lib.types.str (lib.types.listOf lib.types.str));
|
type = types.oneOf [
|
||||||
default = null;
|
(types.enum [
|
||||||
description = "DEPRECATED: Use athenix.sw.<type>.enable instead. Legacy type selection.";
|
"desktop"
|
||||||
visible = false;
|
"tablet-kiosk"
|
||||||
|
"headless"
|
||||||
|
"stateless-kiosk"
|
||||||
|
"builders"
|
||||||
|
])
|
||||||
|
(types.listOf (
|
||||||
|
types.enum [
|
||||||
|
"desktop"
|
||||||
|
"tablet-kiosk"
|
||||||
|
"headless"
|
||||||
|
"stateless-kiosk"
|
||||||
|
"builders"
|
||||||
|
]
|
||||||
|
))
|
||||||
|
];
|
||||||
|
default = "desktop";
|
||||||
|
description = "Type(s) of system configuration. Can be a single type or a list of types to combine multiple configurations.";
|
||||||
};
|
};
|
||||||
|
|
||||||
extraPackages = mkOption {
|
extraPackages = mkOption {
|
||||||
type = lib.types.listOf lib.types.package;
|
type = types.listOf types.package;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = ''
|
description = "Extra packages to install.";
|
||||||
Additional system packages to install beyond the defaults.
|
|
||||||
These packages are added to environment.systemPackages.
|
|
||||||
'';
|
|
||||||
example = lib.literalExpression "[ pkgs.vim pkgs.wget pkgs.curl ]";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
excludePackages = mkOption {
|
excludePackages = mkOption {
|
||||||
type = lib.types.listOf lib.types.package;
|
type = types.listOf types.package;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = ''
|
description = "Packages to exclude from the default list.";
|
||||||
Packages to exclude from the default package list.
|
};
|
||||||
Useful for removing unwanted default packages.
|
|
||||||
'';
|
kioskUrl = mkOption {
|
||||||
example = lib.literalExpression "[ pkgs.htop ]";
|
type = types.str;
|
||||||
|
default = "https://ha.factory.uga.edu";
|
||||||
|
description = "URL to open in Chromium kiosk mode.";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Builders-specific options
|
||||||
|
builders = mkOption {
|
||||||
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
giteaRunner = {
|
||||||
|
enable = mkEnableOption "Gitea Actions self-hosted runner";
|
||||||
|
|
||||||
|
url = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Gitea instance URL for the runner";
|
||||||
|
};
|
||||||
|
|
||||||
|
tokenFile = mkOption {
|
||||||
|
type = types.path;
|
||||||
|
default = "/var/lib/gitea-runner-token";
|
||||||
|
description = ''
|
||||||
|
Path to file containing Gitea runner token.
|
||||||
|
Generate in Gitea repository settings under Actions > Runners.
|
||||||
|
The token must have runner registration access.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
extraLabels = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [ ];
|
||||||
|
description = "Extra labels to identify this runner in workflows";
|
||||||
|
};
|
||||||
|
|
||||||
|
name = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "athenix";
|
||||||
|
description = "Name of the Gitea runner service";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = { };
|
||||||
|
description = "Builder-specific configuration options";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable (mkMerge [
|
||||||
# ========== System-Wide Configuration ==========
|
{
|
||||||
nixpkgs.config.allowUnfree = true;
|
# ========== System-Wide Configuration ==========
|
||||||
|
nixpkgs.config.allowUnfree = true;
|
||||||
|
|
||||||
# ========== Shell Configuration ==========
|
# ========== Shell Configuration ==========
|
||||||
programs.zsh.enable = true;
|
programs.zsh.enable = true;
|
||||||
programs.nix-ld.enable = true; # Allow running non-NixOS binaries
|
programs.nix-ld.enable = true; # Allow running non-NixOS binaries
|
||||||
|
|
||||||
# ========== Base Packages ==========
|
# ========== Base Packages ==========
|
||||||
environment.systemPackages =
|
environment.systemPackages =
|
||||||
with pkgs;
|
with pkgs;
|
||||||
subtractLists cfg.excludePackages [
|
subtractLists cfg.excludePackages [
|
||||||
htop # System monitor
|
htop # System monitor
|
||||||
binutils # Binary utilities
|
binutils # Binary utilities
|
||||||
zsh # Z shell
|
zsh # Z shell
|
||||||
git # Version control
|
git # Version control
|
||||||
oh-my-posh # Shell prompt theme
|
oh-my-posh # Shell prompt theme
|
||||||
age # Simple file encryption tool
|
age # Simple file encryption tool
|
||||||
age-plugin-fido2-hmac # age FIDO2 support
|
age-plugin-fido2-hmac # age FIDO2 support
|
||||||
inputs.agenix.packages.${stdenv.hostPlatform.system}.default # Secret management
|
inputs.agenix.packages.${stdenv.hostPlatform.system}.default # Secret management
|
||||||
];
|
];
|
||||||
};
|
}
|
||||||
|
# ========== Software Profile Imports ==========
|
||||||
|
(mkIf (hasType "desktop") (
|
||||||
|
import ./desktop {
|
||||||
|
inherit
|
||||||
|
config
|
||||||
|
lib
|
||||||
|
pkgs
|
||||||
|
inputs
|
||||||
|
;
|
||||||
|
}
|
||||||
|
))
|
||||||
|
(mkIf (hasType "tablet-kiosk") (
|
||||||
|
import ./tablet-kiosk {
|
||||||
|
inherit
|
||||||
|
config
|
||||||
|
lib
|
||||||
|
pkgs
|
||||||
|
inputs
|
||||||
|
;
|
||||||
|
}
|
||||||
|
))
|
||||||
|
(mkIf (hasType "headless") (
|
||||||
|
import ./headless {
|
||||||
|
inherit
|
||||||
|
config
|
||||||
|
lib
|
||||||
|
pkgs
|
||||||
|
inputs
|
||||||
|
;
|
||||||
|
}
|
||||||
|
))
|
||||||
|
(mkIf (hasType "stateless-kiosk") (
|
||||||
|
import ./stateless-kiosk {
|
||||||
|
inherit
|
||||||
|
config
|
||||||
|
lib
|
||||||
|
pkgs
|
||||||
|
inputs
|
||||||
|
;
|
||||||
|
}
|
||||||
|
))
|
||||||
|
(mkIf (hasType "builders") (
|
||||||
|
import ./builders {
|
||||||
|
inherit
|
||||||
|
config
|
||||||
|
lib
|
||||||
|
pkgs
|
||||||
|
inputs
|
||||||
|
;
|
||||||
|
}
|
||||||
|
))
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,56 +10,21 @@
|
|||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
lib.mkMerge [
|
||||||
with lib;
|
(import ./programs.nix {
|
||||||
|
inherit
|
||||||
let
|
config
|
||||||
cfg = config.athenix.sw.desktop;
|
lib
|
||||||
in
|
pkgs
|
||||||
{
|
inputs
|
||||||
options.athenix.sw.desktop = mkOption {
|
;
|
||||||
type = lib.types.submodule {
|
})
|
||||||
options = {
|
(import ./services.nix {
|
||||||
enable = mkOption {
|
inherit
|
||||||
type = lib.types.bool;
|
config
|
||||||
default = false;
|
lib
|
||||||
description = ''
|
pkgs
|
||||||
Enable full desktop environment with KDE Plasma 6.
|
inputs
|
||||||
|
;
|
||||||
Includes:
|
})
|
||||||
- KDE Plasma 6 desktop with SDDM display manager
|
]
|
||||||
- Full graphical software suite (Firefox, Chromium, LibreOffice)
|
|
||||||
- Printing and scanning support (CUPS)
|
|
||||||
- Virtualization (libvirt, virt-manager)
|
|
||||||
- Bluetooth and audio (PipeWire)
|
|
||||||
- Video conferencing (Zoom, Teams)
|
|
||||||
|
|
||||||
Recommended for: Workstations, development machines, user desktops
|
|
||||||
'';
|
|
||||||
example = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
default = { };
|
|
||||||
description = "Desktop environment configuration (KDE Plasma 6).";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
|
||||||
(import ./programs.nix {
|
|
||||||
inherit
|
|
||||||
config
|
|
||||||
lib
|
|
||||||
pkgs
|
|
||||||
inputs
|
|
||||||
;
|
|
||||||
})
|
|
||||||
(import ./services.nix {
|
|
||||||
inherit
|
|
||||||
config
|
|
||||||
lib
|
|
||||||
pkgs
|
|
||||||
inputs
|
|
||||||
;
|
|
||||||
})
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
config,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
|
|||||||
27
sw/gc.nix
27
sw/gc.nix
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
@@ -9,40 +10,22 @@
|
|||||||
enable = lib.mkOption {
|
enable = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = ''
|
description = "Whether to enable automatic garbage collection.";
|
||||||
Enable automatic garbage collection of old NixOS generations.
|
|
||||||
Helps keep disk usage under control on long-running systems.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
frequency = lib.mkOption {
|
frequency = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "weekly";
|
default = "weekly";
|
||||||
description = ''
|
description = "How often to run garbage collection (systemd timer format).";
|
||||||
How often to run garbage collection (systemd timer format).
|
|
||||||
|
|
||||||
Common values: "daily", "weekly", "monthly"
|
|
||||||
Advanced: "*-*-* 03:00:00" (daily at 3 AM)
|
|
||||||
'';
|
|
||||||
example = "daily";
|
|
||||||
};
|
};
|
||||||
retentionDays = lib.mkOption {
|
retentionDays = lib.mkOption {
|
||||||
type = lib.types.int;
|
type = lib.types.int;
|
||||||
default = 30;
|
default = 30;
|
||||||
description = ''
|
description = "Number of days to keep old generations before deletion.";
|
||||||
Number of days to keep old system generations before deletion.
|
|
||||||
|
|
||||||
Older generations allow rolling back system changes.
|
|
||||||
Recommended: 30-90 days for workstations, 7-14 for servers.
|
|
||||||
'';
|
|
||||||
example = 60;
|
|
||||||
};
|
};
|
||||||
optimise = lib.mkOption {
|
optimise = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = ''
|
description = "Whether to automatically optimize the Nix store.";
|
||||||
Whether to automatically hard-link identical files in the Nix store.
|
|
||||||
Can save significant disk space but uses CPU during optimization.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,7 @@
|
|||||||
# It reconstructs the terminfo database from the provided definition and
|
# It reconstructs the terminfo database from the provided definition and
|
||||||
# adds it to the system packages.
|
# adds it to the system packages.
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.athenix.sw;
|
|
||||||
|
|
||||||
ghostty-terminfo = pkgs.runCommand "ghostty-terminfo" { } ''
|
ghostty-terminfo = pkgs.runCommand "ghostty-terminfo" { } ''
|
||||||
mkdir -p $out/share/terminfo
|
mkdir -p $out/share/terminfo
|
||||||
cat > ghostty.info <<'EOF'
|
cat > ghostty.info <<'EOF'
|
||||||
@@ -105,7 +101,5 @@ let
|
|||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = mkIf cfg.enable {
|
environment.systemPackages = [ ghostty-terminfo ];
|
||||||
environment.systemPackages = [ ghostty-terminfo ];
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,53 +11,21 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with lib;
|
lib.mkMerge [
|
||||||
|
(import ./programs.nix {
|
||||||
let
|
inherit
|
||||||
cfg = config.athenix.sw.headless;
|
config
|
||||||
in
|
lib
|
||||||
{
|
pkgs
|
||||||
options.athenix.sw.headless = mkOption {
|
inputs
|
||||||
type = lib.types.submodule {
|
;
|
||||||
options = {
|
})
|
||||||
enable = mkOption {
|
(import ./services.nix {
|
||||||
type = lib.types.bool;
|
inherit
|
||||||
default = false;
|
config
|
||||||
description = ''
|
lib
|
||||||
Enable minimal headless server configuration.
|
pkgs
|
||||||
|
inputs
|
||||||
Includes:
|
;
|
||||||
- SSH server with password authentication
|
})
|
||||||
- Minimal CLI tools (tmux, man)
|
]
|
||||||
- Systemd-networkd for networking
|
|
||||||
- No graphical environment
|
|
||||||
|
|
||||||
Recommended for: Servers, containers (LXC), WSL, remote systems
|
|
||||||
'';
|
|
||||||
example = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
default = { };
|
|
||||||
description = "Headless server configuration (SSH, minimal CLI tools).";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
|
||||||
(import ./programs.nix {
|
|
||||||
inherit
|
|
||||||
config
|
|
||||||
lib
|
|
||||||
pkgs
|
|
||||||
inputs
|
|
||||||
;
|
|
||||||
})
|
|
||||||
(import ./services.nix {
|
|
||||||
inherit
|
|
||||||
config
|
|
||||||
lib
|
|
||||||
pkgs
|
|
||||||
inputs
|
|
||||||
;
|
|
||||||
})
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
|||||||
@@ -18,27 +18,10 @@ let
|
|||||||
cfg = config.athenix.sw.python;
|
cfg = config.athenix.sw.python;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.athenix.sw.python = lib.mkOption {
|
options.athenix.sw.python = {
|
||||||
type = lib.types.submodule {
|
enable = mkEnableOption "Python development tools (pixi, uv)" // {
|
||||||
options = {
|
default = true;
|
||||||
enable = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
description = ''
|
|
||||||
Enable Python development tools (pixi, uv).
|
|
||||||
|
|
||||||
Provides:
|
|
||||||
- pixi: Fast, cross-platform package manager for Python
|
|
||||||
- uv: Extremely fast Python package installer and resolver
|
|
||||||
|
|
||||||
These tools manage project-based dependencies rather than global
|
|
||||||
Python packages, avoiding conflicts and improving reproducibility.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
default = { };
|
|
||||||
description = "Python development environment configuration.";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|||||||
230
sw/secrets.nix
230
sw/secrets.nix
@@ -1,230 +0,0 @@
|
|||||||
# ============================================================================
|
|
||||||
# Automatic Secret Management with Agenix
|
|
||||||
# ============================================================================
|
|
||||||
# This module automatically loads age-encrypted secrets from ./secrets based on
|
|
||||||
# the hostname. Secrets are organized by directory:
|
|
||||||
# - ./secrets/global/ -> Installed on ALL systems
|
|
||||||
# - ./secrets/{hostname}/ -> Installed only on matching host
|
|
||||||
#
|
|
||||||
# Secret files should be .age encrypted files. Public keys (.pub) are ignored.
|
|
||||||
|
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.athenix.sw;
|
|
||||||
secretsPath = ../secrets;
|
|
||||||
|
|
||||||
# Get the fleet-assigned hostname (avoids issues with LXC empty hostnames)
|
|
||||||
hostname = config.athenix.host.name;
|
|
||||||
|
|
||||||
# Read all directories in ./secrets
|
|
||||||
secretDirs = if builtins.pathExists secretsPath then builtins.readDir secretsPath else { };
|
|
||||||
|
|
||||||
# Filter to only directories (excludes files)
|
|
||||||
isDirectory = name: type: type == "directory";
|
|
||||||
directories = lib.filterAttrs isDirectory secretDirs;
|
|
||||||
|
|
||||||
# Read secrets from a specific directory
|
|
||||||
readSecretsFromDir =
|
|
||||||
dirName:
|
|
||||||
let
|
|
||||||
dirPath = secretsPath + "/${dirName}";
|
|
||||||
files = builtins.readDir dirPath;
|
|
||||||
|
|
||||||
# Check if there's a default.nix with custom secret configurations
|
|
||||||
hasDefaultNix = files ? "default.nix";
|
|
||||||
customConfigs = if hasDefaultNix then import (dirPath + "/default.nix") else { };
|
|
||||||
|
|
||||||
# Only include .age files (exclude .pub public keys and other files)
|
|
||||||
secretFiles = lib.filterAttrs (name: type: type == "regular" && lib.hasSuffix ".age" name) files;
|
|
||||||
in
|
|
||||||
lib.mapAttrs' (
|
|
||||||
name: _:
|
|
||||||
let
|
|
||||||
# Remove .age extension for the secret name
|
|
||||||
secretName = lib.removeSuffix ".age" name;
|
|
||||||
|
|
||||||
# Get custom config for this secret if defined
|
|
||||||
customConfig = customConfigs.${secretName} or { };
|
|
||||||
|
|
||||||
# Base configuration with file path
|
|
||||||
baseConfig = {
|
|
||||||
file = dirPath + "/${name}";
|
|
||||||
};
|
|
||||||
in
|
|
||||||
lib.nameValuePair secretName (baseConfig // customConfig)
|
|
||||||
) secretFiles;
|
|
||||||
|
|
||||||
# Read public keys from a specific directory and map to private key paths
|
|
||||||
readIdentityPathsFromDir =
|
|
||||||
dirName:
|
|
||||||
let
|
|
||||||
dirPath = secretsPath + "/${dirName}";
|
|
||||||
files = if builtins.pathExists dirPath then builtins.readDir dirPath else { };
|
|
||||||
# Only include .pub public key files
|
|
||||||
pubKeyFiles = lib.filterAttrs (name: type: type == "regular" && lib.hasSuffix ".pub" name) files;
|
|
||||||
in
|
|
||||||
lib.mapAttrsToList (
|
|
||||||
name: _:
|
|
||||||
let
|
|
||||||
# Map public key filename to expected private key location
|
|
||||||
baseName = lib.removeSuffix ".pub" name;
|
|
||||||
filePath = dirPath + "/${name}";
|
|
||||||
fileContent = builtins.readFile filePath;
|
|
||||||
# Check if it's an SSH key by looking at the content
|
|
||||||
isSSHKey = lib.hasPrefix "ssh-" fileContent || lib.hasPrefix "ecdsa-" fileContent;
|
|
||||||
in
|
|
||||||
if lib.hasPrefix "ssh_host_" name then
|
|
||||||
# SSH host keys: ssh_host_ed25519_key.pub -> /etc/ssh/ssh_host_ed25519_key
|
|
||||||
"/etc/ssh/${baseName}"
|
|
||||||
else if name == "identity.pub" then
|
|
||||||
# Standard age identity: identity.pub -> /etc/age/identity.key
|
|
||||||
"/etc/age/identity.key"
|
|
||||||
else if isSSHKey then
|
|
||||||
# Other SSH keys (user keys, etc.): hunter_halloran_key.pub -> /etc/ssh/hunter_halloran_key
|
|
||||||
"/etc/ssh/${baseName}"
|
|
||||||
else
|
|
||||||
# Generic age keys: key.pub -> /etc/age/key
|
|
||||||
"/etc/age/${baseName}"
|
|
||||||
) pubKeyFiles;
|
|
||||||
|
|
||||||
# Determine which secrets apply to this host
|
|
||||||
applicableSecrets =
|
|
||||||
let
|
|
||||||
# Global secrets apply to all hosts
|
|
||||||
globalSecrets = if directories ? "global" then readSecretsFromDir "global" else { };
|
|
||||||
|
|
||||||
# Host-specific secrets
|
|
||||||
hostSecrets = if directories ? ${hostname} then readSecretsFromDir hostname else { };
|
|
||||||
in
|
|
||||||
globalSecrets // hostSecrets; # Host-specific secrets override global if same name
|
|
||||||
|
|
||||||
# Determine which identity paths (private keys) to use for decryption
|
|
||||||
identityPaths =
|
|
||||||
let
|
|
||||||
# Global identity paths (keys in global/ that all hosts can use)
|
|
||||||
globalPaths = if directories ? "global" then readIdentityPathsFromDir "global" else [ ];
|
|
||||||
|
|
||||||
# Host-specific identity paths
|
|
||||||
hostPaths = if directories ? ${hostname} then readIdentityPathsFromDir hostname else [ ];
|
|
||||||
|
|
||||||
# Default paths that NixOS/agenix use
|
|
||||||
defaultPaths = [
|
|
||||||
"/etc/ssh/ssh_host_rsa_key"
|
|
||||||
"/etc/ssh/ssh_host_ed25519_key"
|
|
||||||
"/etc/age/identity.key"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Combine all paths and remove duplicates
|
|
||||||
allPaths = lib.unique (defaultPaths ++ globalPaths ++ hostPaths);
|
|
||||||
in
|
|
||||||
allPaths;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.athenix.sw.secrets = {
|
|
||||||
enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = true;
|
|
||||||
description = ''
|
|
||||||
Enable automatic secret management using agenix.
|
|
||||||
|
|
||||||
Secrets are loaded from ./secrets based on directory structure:
|
|
||||||
- ./secrets/global/ -> All systems
|
|
||||||
- ./secrets/{hostname}/ -> Specific host only
|
|
||||||
|
|
||||||
Only .age encrypted files are loaded; .pub files are ignored.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
extraSecrets = mkOption {
|
|
||||||
type = types.attrsOf (
|
|
||||||
types.submodule {
|
|
||||||
options = {
|
|
||||||
file = mkOption {
|
|
||||||
type = types.path;
|
|
||||||
description = "Path to the encrypted secret file";
|
|
||||||
};
|
|
||||||
mode = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "0400";
|
|
||||||
description = "Permissions mode for the decrypted secret";
|
|
||||||
};
|
|
||||||
owner = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "root";
|
|
||||||
description = "Owner of the decrypted secret file";
|
|
||||||
};
|
|
||||||
group = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "root";
|
|
||||||
description = "Group of the decrypted secret file";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
default = { };
|
|
||||||
description = ''
|
|
||||||
Additional secrets to define manually, beyond the auto-discovered ones.
|
|
||||||
Use this for secrets that need custom permissions or are stored elsewhere.
|
|
||||||
'';
|
|
||||||
example = lib.literalExpression ''
|
|
||||||
{
|
|
||||||
"my-secret" = {
|
|
||||||
file = ./secrets/custom/secret.age;
|
|
||||||
mode = "0440";
|
|
||||||
owner = "nginx";
|
|
||||||
group = "nginx";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf (cfg.enable && cfg.secrets.enable) {
|
|
||||||
# Auto-discovered secrets with default permissions
|
|
||||||
age.secrets = applicableSecrets // cfg.secrets.extraSecrets;
|
|
||||||
|
|
||||||
# Generate age identity files from SSH host keys at boot
|
|
||||||
# This is needed because age can't reliably use OpenSSH private keys directly
|
|
||||||
# Must run before agenix tries to decrypt secrets
|
|
||||||
system.activationScripts.convertSshToAge = {
|
|
||||||
deps = [
|
|
||||||
"users"
|
|
||||||
"groups"
|
|
||||||
];
|
|
||||||
text = ''
|
|
||||||
mkdir -p /etc/age
|
|
||||||
if [ -f /etc/ssh/ssh_host_ed25519_key ]; then
|
|
||||||
${pkgs.ssh-to-age}/bin/ssh-to-age -private-key -i /etc/ssh/ssh_host_ed25519_key > /etc/age/ssh_host_ed25519.age || true
|
|
||||||
chmod 600 /etc/age/ssh_host_ed25519.age 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
if [ -f /etc/ssh/ssh_host_rsa_key ]; then
|
|
||||||
${pkgs.ssh-to-age}/bin/ssh-to-age -private-key -i /etc/ssh/ssh_host_rsa_key > /etc/age/ssh_host_rsa.age 2>/dev/null || true
|
|
||||||
chmod 600 /etc/age/ssh_host_rsa.age 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
# Add the converted age keys to identity paths (in addition to auto-discovered ones)
|
|
||||||
age.identityPaths = identityPaths ++ [
|
|
||||||
"/etc/age/ssh_host_ed25519.age"
|
|
||||||
"/etc/age/ssh_host_rsa.age"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Optional: Add assertion to warn if no secrets found
|
|
||||||
warnings =
|
|
||||||
let
|
|
||||||
hasSecrets = (builtins.length (builtins.attrNames applicableSecrets)) > 0;
|
|
||||||
in
|
|
||||||
lib.optional (
|
|
||||||
!hasSecrets
|
|
||||||
) "No age-encrypted secrets found in ./secrets/global/ or ./secrets/${hostname}/";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -7,83 +7,37 @@
|
|||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
lib.mkMerge [
|
||||||
with lib;
|
(import ./kiosk-browser.nix {
|
||||||
|
inherit
|
||||||
let
|
config
|
||||||
cfg = config.athenix.sw.stateless-kiosk;
|
lib
|
||||||
in
|
pkgs
|
||||||
{
|
inputs
|
||||||
options.athenix.sw.stateless-kiosk = mkOption {
|
;
|
||||||
type = lib.types.submodule {
|
})
|
||||||
options = {
|
(import ./services.nix {
|
||||||
enable = mkOption {
|
inherit
|
||||||
type = lib.types.bool;
|
config
|
||||||
default = false;
|
lib
|
||||||
description = ''
|
pkgs
|
||||||
Enable stateless kiosk mode for diskless PXE boot systems.
|
inputs
|
||||||
|
;
|
||||||
Includes:
|
})
|
||||||
- Sway (Wayland compositor)
|
(import ./net.nix {
|
||||||
- Chromium in fullscreen kiosk mode
|
inherit
|
||||||
- MAC address-based URL routing
|
config
|
||||||
- Network-only boot (no local storage)
|
lib
|
||||||
- Auto-start browser on boot
|
pkgs
|
||||||
|
inputs
|
||||||
Recommended for: Assembly line stations, diskless kiosks, PXE boot displays
|
;
|
||||||
'';
|
})
|
||||||
example = true;
|
(import ./programs.nix {
|
||||||
};
|
inherit
|
||||||
|
config
|
||||||
kioskUrl = mkOption {
|
lib
|
||||||
type = lib.types.str;
|
pkgs
|
||||||
default = "https://ha.factory.uga.edu";
|
inputs
|
||||||
description = ''
|
;
|
||||||
Default URL to display in the kiosk browser.
|
})
|
||||||
|
]
|
||||||
Note: For stateless-kiosk, MAC address-based routing may override this.
|
|
||||||
See sw/stateless-kiosk/mac-hostmap.nix for MAC-to-URL mappings.
|
|
||||||
'';
|
|
||||||
example = "https://homeassistant.lan:8123/lovelace/dashboard";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
default = { };
|
|
||||||
description = "Stateless kiosk configuration (PXE boot, Sway, MAC-based routing).";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
|
||||||
(import ./kiosk-browser.nix {
|
|
||||||
inherit
|
|
||||||
config
|
|
||||||
lib
|
|
||||||
pkgs
|
|
||||||
inputs
|
|
||||||
;
|
|
||||||
})
|
|
||||||
(import ./services.nix {
|
|
||||||
inherit
|
|
||||||
config
|
|
||||||
lib
|
|
||||||
pkgs
|
|
||||||
inputs
|
|
||||||
;
|
|
||||||
})
|
|
||||||
(import ./net.nix {
|
|
||||||
inherit
|
|
||||||
config
|
|
||||||
lib
|
|
||||||
pkgs
|
|
||||||
inputs
|
|
||||||
;
|
|
||||||
})
|
|
||||||
(import ./programs.nix {
|
|
||||||
inherit
|
|
||||||
config
|
|
||||||
lib
|
|
||||||
pkgs
|
|
||||||
inputs
|
|
||||||
;
|
|
||||||
})
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
# This module configures Chromium for kiosk mode under Sway.
|
# This module configures Chromium for kiosk mode under Sway.
|
||||||
# It includes a startup script that determines the kiosk URL based on the machine's MAC address.
|
# It includes a startup script that determines the kiosk URL based on the machine's MAC address.
|
||||||
{
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
inputs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
macCaseBuilder = inputs.self.lib.macCaseBuilder;
|
macCaseBuilder = (import ./mac-hostmap.nix { inherit lib; }).macCaseBuilder;
|
||||||
macCases = macCaseBuilder {
|
macCases = macCaseBuilder {
|
||||||
varName = "STATION";
|
varName = "STATION";
|
||||||
};
|
};
|
||||||
|
|||||||
28
sw/stateless-kiosk/mac-hostmap.nix
Normal file
28
sw/stateless-kiosk/mac-hostmap.nix
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# Shared MAC address to station mapping and case builder for stateless-kiosk modules
|
||||||
|
{ lib }:
|
||||||
|
let
|
||||||
|
hostmap = {
|
||||||
|
"00:e0:4c:46:0b:32" = "1";
|
||||||
|
"00:e0:4c:46:07:26" = "2";
|
||||||
|
"00:e0:4c:46:05:94" = "3";
|
||||||
|
"00:e0:4c:46:07:11" = "4";
|
||||||
|
"00:e0:4c:46:08:02" = "5";
|
||||||
|
"00:e0:4c:46:08:5c" = "6";
|
||||||
|
};
|
||||||
|
# macCaseBuilder: builds a shell case statement from a hostmap
|
||||||
|
# varName: the shell variable to assign
|
||||||
|
# prefix: optional string to prepend to the value (default: "")
|
||||||
|
# attrset: attribute set to use (default: hostmap)
|
||||||
|
macCaseBuilder =
|
||||||
|
{
|
||||||
|
varName,
|
||||||
|
prefix ? "",
|
||||||
|
attrset ? hostmap,
|
||||||
|
}:
|
||||||
|
lib.concatStringsSep "\n" (
|
||||||
|
lib.mapAttrsToList (mac: val: " ${mac}) ${varName}=${prefix}${val} ;;") attrset
|
||||||
|
);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit hostmap macCaseBuilder;
|
||||||
|
}
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
inputs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
macCaseBuilder = inputs.self.lib.macCaseBuilder;
|
macCaseBuilder = (import ./mac-hostmap.nix { inherit lib; }).macCaseBuilder;
|
||||||
shellCases = macCaseBuilder {
|
shellCases = macCaseBuilder {
|
||||||
varName = "NEW_HOST";
|
varName = "NEW_HOST";
|
||||||
prefix = "nix-station";
|
prefix = "nix-station";
|
||||||
|
|||||||
@@ -5,74 +5,29 @@
|
|||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
lib.mkMerge [
|
||||||
with lib;
|
(import ./programs.nix {
|
||||||
|
inherit
|
||||||
let
|
config
|
||||||
cfg = config.athenix.sw.tablet-kiosk;
|
lib
|
||||||
in
|
pkgs
|
||||||
{
|
inputs
|
||||||
options.athenix.sw.tablet-kiosk = mkOption {
|
;
|
||||||
type = lib.types.submodule {
|
})
|
||||||
options = {
|
(import ./services.nix {
|
||||||
enable = mkOption {
|
inherit
|
||||||
type = lib.types.bool;
|
config
|
||||||
default = false;
|
lib
|
||||||
description = ''
|
pkgs
|
||||||
Enable tablet kiosk mode with touch-optimized interface.
|
inputs
|
||||||
|
;
|
||||||
Includes:
|
})
|
||||||
- Phosh mobile desktop environment
|
(import ./gsettings.nix {
|
||||||
- Chromium in fullscreen kiosk mode
|
inherit
|
||||||
- On-screen keyboard (Squeekboard)
|
config
|
||||||
- Auto-login and auto-start browser
|
lib
|
||||||
- Touch gesture support
|
pkgs
|
||||||
- Optimized for Surface Pro tablets
|
inputs
|
||||||
|
;
|
||||||
Recommended for: Surface tablets, touchscreen kiosks, interactive displays
|
})
|
||||||
'';
|
]
|
||||||
example = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
kioskUrl = mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "https://ha.factory.uga.edu";
|
|
||||||
description = ''
|
|
||||||
URL to display in the kiosk browser on startup.
|
|
||||||
The browser will automatically navigate to this URL in fullscreen mode.
|
|
||||||
'';
|
|
||||||
example = "https://dashboard.example.com";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
default = { };
|
|
||||||
description = "Tablet kiosk configuration (Phosh, touch interface).";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
|
||||||
(import ./programs.nix {
|
|
||||||
inherit
|
|
||||||
config
|
|
||||||
lib
|
|
||||||
pkgs
|
|
||||||
inputs
|
|
||||||
;
|
|
||||||
})
|
|
||||||
(import ./services.nix {
|
|
||||||
inherit
|
|
||||||
config
|
|
||||||
lib
|
|
||||||
pkgs
|
|
||||||
inputs
|
|
||||||
;
|
|
||||||
})
|
|
||||||
(import ./gsettings.nix {
|
|
||||||
inherit
|
|
||||||
config
|
|
||||||
lib
|
|
||||||
pkgs
|
|
||||||
inputs
|
|
||||||
;
|
|
||||||
})
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -155,7 +155,7 @@
|
|||||||
--noerrdialogs \
|
--noerrdialogs \
|
||||||
--disable-session-crashed-bubble \
|
--disable-session-crashed-bubble \
|
||||||
--disable-infobars \
|
--disable-infobars \
|
||||||
${config.athenix.sw.tablet-kiosk.kioskUrl}
|
${config.athenix.sw.kioskUrl}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
pkgs,
|
pkgs,
|
||||||
config,
|
config,
|
||||||
|
osConfig,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|||||||
@@ -1,524 +1,511 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
config,
|
environment.systemPackages = with pkgs; [
|
||||||
lib,
|
python3
|
||||||
pkgs,
|
git
|
||||||
...
|
(pkgs.writeShellScriptBin "update-ref" ''
|
||||||
}:
|
set -euo pipefail
|
||||||
|
|
||||||
with lib;
|
RED='\033[31m'; YEL='\033[33m'; NC='\033[0m'
|
||||||
|
die() { printf "''${RED}error:''${NC} %s\n" "$*" >&2; exit 2; }
|
||||||
|
warn() { printf "''${YEL}warning:''${NC} %s\n" "$*" >&2; }
|
||||||
|
|
||||||
let
|
usage() {
|
||||||
cfg = config.athenix.sw;
|
cat >&2 <<'EOF'
|
||||||
in
|
usage:
|
||||||
{
|
update-ref [-R PATH|--athenix-repo=PATH] [-b BRANCH|--athenix-branch=BRANCH]
|
||||||
config = mkIf cfg.enable {
|
[-m "msg"|--message "msg"]
|
||||||
environment.systemPackages = with pkgs; [
|
[-p[=false] [remote[=URL]]|--push[=false] [remote[=URL]]]
|
||||||
python3
|
[--make-local|-l] [--make-remote|-r] [--ssh]
|
||||||
git
|
user=<username> | system=<device-type>:<hostkey>
|
||||||
(pkgs.writeShellScriptBin "update-ref" ''
|
EOF
|
||||||
set -euo pipefail
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
RED='\033[31m'; YEL='\033[33m'; NC='\033[0m'
|
# --- must be in a git repo (current dir) ---
|
||||||
die() { printf "''${RED}error:''${NC} %s\n" "$*" >&2; exit 2; }
|
git rev-parse --is-inside-work-tree >/dev/null 2>&1 || die "This directory is not a git project"
|
||||||
warn() { printf "''${YEL}warning:''${NC} %s\n" "$*" >&2; }
|
CUR_REPO_ROOT="$(git rev-parse --show-toplevel)"
|
||||||
|
CUR_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
||||||
|
|
||||||
usage() {
|
# --- athenix checkout (working tree) ---
|
||||||
cat >&2 <<'EOF'
|
ATHENIX_DIR="$HOME/athenix"
|
||||||
usage:
|
ATHENIX_BRANCH=""
|
||||||
update-ref [-R PATH|--athenix-repo=PATH] [-b BRANCH|--athenix-branch=BRANCH]
|
|
||||||
[-m "msg"|--message "msg"]
|
|
||||||
[-p[=false] [remote[=URL]]|--push[=false] [remote[=URL]]]
|
|
||||||
[--make-local|-l] [--make-remote|-r] [--ssh]
|
|
||||||
user=<username> | system=<device-type>:<hostkey>
|
|
||||||
EOF
|
|
||||||
exit 2
|
|
||||||
}
|
|
||||||
|
|
||||||
# --- must be in a git repo (current dir) ---
|
# --- current repo automation ---
|
||||||
git rev-parse --is-inside-work-tree >/dev/null 2>&1 || die "This directory is not a git project"
|
COMMIT_MSG=""
|
||||||
CUR_REPO_ROOT="$(git rev-parse --show-toplevel)"
|
PUSH_SPEC=""
|
||||||
CUR_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
|
||||||
|
|
||||||
# --- athenix checkout (working tree) ---
|
# --- push / url mode ---
|
||||||
ATHENIX_DIR="$HOME/athenix"
|
PUSH_SET=0
|
||||||
ATHENIX_BRANCH=""
|
DO_PUSH=0
|
||||||
|
MODE_FORCE="" # "", local, remote
|
||||||
|
|
||||||
# --- current repo automation ---
|
TARGET=""
|
||||||
COMMIT_MSG=""
|
|
||||||
PUSH_SPEC=""
|
|
||||||
|
|
||||||
# --- push / url mode ---
|
is_remote_url() {
|
||||||
PUSH_SET=0
|
# https://, http://, ssh://, or scp-style git@host:org/repo
|
||||||
DO_PUSH=0
|
printf "%s" "$1" | grep -qE '^(https?|ssh)://|^[^/@:]+@[^/:]+:'
|
||||||
MODE_FORCE="" # "", local, remote
|
}
|
||||||
|
|
||||||
TARGET=""
|
derive_full_hostname() {
|
||||||
|
devtype="$1"; hostkey="$2"
|
||||||
|
if printf "%s" "$hostkey" | grep -q '-' || printf "%s" "$hostkey" | grep -q "^$devtype"; then
|
||||||
|
printf "%s" "$hostkey"
|
||||||
|
elif printf "%s" "$hostkey" | grep -qE '^[0-9]+$'; then
|
||||||
|
printf "%s" "$devtype$hostkey"
|
||||||
|
else
|
||||||
|
printf "%s" "$devtype-$hostkey"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
is_remote_url() {
|
extract_existing_fetch_url() {
|
||||||
# https://, http://, ssh://, or scp-style git@host:org/repo
|
# args: mode file username key
|
||||||
printf "%s" "$1" | grep -qE '^(https?|ssh)://|^[^/@:]+@[^/:]+:'
|
python3 - "$1" "$2" "$3" "$4" "$5"<<'PY'
|
||||||
}
|
import sys, re, pathlib
|
||||||
|
mode, file, username, key, use_ssh = sys.argv[1:5]
|
||||||
|
t = pathlib.Path(file).read_text()
|
||||||
|
|
||||||
derive_full_hostname() {
|
def url_from_block(block: str) -> str:
|
||||||
devtype="$1"; hostkey="$2"
|
if not block:
|
||||||
if printf "%s" "$hostkey" | grep -q '-' || printf "%s" "$hostkey" | grep -q "^$devtype"; then
|
return ""
|
||||||
printf "%s" "$hostkey"
|
m = re.search(r'url\s*=\s*"([^"]+)"\s*;', block)
|
||||||
elif printf "%s" "$hostkey" | grep -qE '^[0-9]+$'; then
|
url = m.group(1) if m else ""
|
||||||
printf "%s" "$devtype$hostkey"
|
|
||||||
else
|
|
||||||
printf "%s" "$devtype-$hostkey"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
extract_existing_fetch_url() {
|
if use_ssh = "true":
|
||||||
# args: mode file username key
|
return url
|
||||||
python3 - "$1" "$2" "$3" "$4" "$5"<<'PY'
|
|
||||||
import sys, re, pathlib
|
|
||||||
mode, file, username, key, use_ssh = sys.argv[1:5]
|
|
||||||
t = pathlib.Path(file).read_text()
|
|
||||||
|
|
||||||
def url_from_block(block: str) -> str:
|
# Already https
|
||||||
if not block:
|
if url.startswith("https://"):
|
||||||
return ""
|
|
||||||
m = re.search(r'url\s*=\s*"([^"]+)"\s*;', block)
|
|
||||||
url = m.group(1) if m else ""
|
|
||||||
|
|
||||||
if use_ssh = "true":
|
|
||||||
return url
|
return url
|
||||||
|
|
||||||
# Already https
|
# ssh://git@host/org/repo.git
|
||||||
if url.startswith("https://"):
|
m = re.match(r"ssh://(?:.+?)@([^/]+)/(.+)", url)
|
||||||
return url
|
if m:
|
||||||
|
host, path = m.groups()
|
||||||
|
return f"https://{host}/{path}"
|
||||||
|
|
||||||
# ssh://git@host/org/repo.git
|
# git@host:org/repo.git
|
||||||
m = re.match(r"ssh://(?:.+?)@([^/]+)/(.+)", url)
|
m = re.match(r"(?:.+?)@([^:]+):(.+)", url)
|
||||||
if m:
|
if m:
|
||||||
host, path = m.groups()
|
host, path = m.groups()
|
||||||
return f"https://{host}/{path}"
|
return f"https://{host}/{path}"
|
||||||
|
|
||||||
# git@host:org/repo.git
|
# If you gave me something cursed
|
||||||
m = re.match(r"(?:.+?)@([^:]+):(.+)", url)
|
raise ValueError(f"Unrecognized SSH git URL format: {url}")
|
||||||
if m:
|
|
||||||
host, path = m.groups()
|
|
||||||
return f"https://{host}/{path}"
|
|
||||||
|
|
||||||
# If you gave me something cursed
|
|
||||||
raise ValueError(f"Unrecognized SSH git URL format: {url}")
|
|
||||||
|
|
||||||
|
|
||||||
if mode == "user":
|
if mode == "user":
|
||||||
m = re.search(r'(?s)\n\s*' + re.escape(username) + r'\.external\s*=\s*builtins\.fetchGit\s*\{(.*?)\n\s*\};', t)
|
m = re.search(r'(?s)\n\s*' + re.escape(username) + r'\.external\s*=\s*builtins\.fetchGit\s*\{(.*?)\n\s*\};', t)
|
||||||
block = m.group(1) if m else ""
|
block = m.group(1) if m else ""
|
||||||
print(url_from_block(block))
|
print(url_from_block(block))
|
||||||
else:
|
else:
|
||||||
m = re.search(r'(?s)\n\s*"' + re.escape(key) + r'"\s*=\s*builtins\.fetchGit\s*\{(.*?)\n\s*\};', t)
|
m = re.search(r'(?s)\n\s*"' + re.escape(key) + r'"\s*=\s*builtins\.fetchGit\s*\{(.*?)\n\s*\};', t)
|
||||||
block = m.group(1) if m else ""
|
block = m.group(1) if m else ""
|
||||||
print(url_from_block(block))
|
print(url_from_block(block))
|
||||||
PY
|
PY
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- parse args ---
|
# --- parse args ---
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
user=*|system=*)
|
user=*|system=*)
|
||||||
[ -z "$TARGET" ] || die "Only one subcommand allowed (user=... or system=...)"
|
[ -z "$TARGET" ] || die "Only one subcommand allowed (user=... or system=...)"
|
||||||
TARGET="$1"; shift
|
TARGET="$1"; shift
|
||||||
;;
|
;;
|
||||||
--athenix-repo=*)
|
--athenix-repo=*)
|
||||||
ATHENIX_DIR="''${1#*=}"; shift
|
ATHENIX_DIR="''${1#*=}"; shift
|
||||||
;;
|
;;
|
||||||
-R)
|
-R)
|
||||||
[ "$#" -ge 2 ] || usage
|
[ "$#" -ge 2 ] || usage
|
||||||
ATHENIX_DIR="$2"; shift 2
|
ATHENIX_DIR="$2"; shift 2
|
||||||
;;
|
;;
|
||||||
--athenix-branch=*)
|
--athenix-branch=*)
|
||||||
ATHENIX_BRANCH="''${1#*=}"; shift
|
ATHENIX_BRANCH="''${1#*=}"; shift
|
||||||
;;
|
;;
|
||||||
-b)
|
-b)
|
||||||
[ "$#" -ge 2 ] || usage
|
[ "$#" -ge 2 ] || usage
|
||||||
ATHENIX_BRANCH="$2"; shift 2
|
ATHENIX_BRANCH="$2"; shift 2
|
||||||
;;
|
;;
|
||||||
-m|--message)
|
-m|--message)
|
||||||
[ "$#" -ge 2 ] || usage
|
[ "$#" -ge 2 ] || usage
|
||||||
COMMIT_MSG="$2"; shift 2
|
COMMIT_MSG="$2"; shift 2
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-p|--push)
|
-p|--push)
|
||||||
PUSH_SET=1
|
PUSH_SET=1
|
||||||
DO_PUSH=1
|
DO_PUSH=1
|
||||||
PUSH_SPEC=""
|
PUSH_SPEC=""
|
||||||
|
|
||||||
# If there is a next token, only consume it if it is a remote spec
|
# If there is a next token, only consume it if it is a remote spec
|
||||||
# and not another flag or the subcommand.
|
# and not another flag or the subcommand.
|
||||||
if [ "$#" -ge 2 ]; then
|
if [ "$#" -ge 2 ]; then
|
||||||
nxt="$2"
|
nxt="$2"
|
||||||
|
|
||||||
if printf "%s" "$nxt" | grep -qE '^(user=|system=)'; then
|
if printf "%s" "$nxt" | grep -qE '^(user=|system=)'; then
|
||||||
# next token is the subcommand; don't consume it
|
# next token is the subcommand; don't consume it
|
||||||
shift
|
shift
|
||||||
elif printf "%s" "$nxt" | grep -qE '^-'; then
|
elif printf "%s" "$nxt" | grep -qE '^-'; then
|
||||||
# next token is another flag; don't consume it
|
# next token is another flag; don't consume it
|
||||||
shift
|
shift
|
||||||
elif printf "%s" "$nxt" | grep -qE '^[A-Za-z0-9._-]+$'; then
|
elif printf "%s" "$nxt" | grep -qE '^[A-Za-z0-9._-]+$'; then
|
||||||
# remote name
|
# remote name
|
||||||
PUSH_SPEC="$nxt"
|
PUSH_SPEC="$nxt"
|
||||||
shift 2
|
shift 2
|
||||||
elif printf "%s" "$nxt" | grep -qE '^[A-Za-z0-9._-]+=.+$'; then
|
elif printf "%s" "$nxt" | grep -qE '^[A-Za-z0-9._-]+=.+$'; then
|
||||||
# remote=URL
|
# remote=URL
|
||||||
PUSH_SPEC="$nxt"
|
PUSH_SPEC="$nxt"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
|
||||||
# unknown token; treat as not-a-push-spec and don't consume it
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
|
# unknown token; treat as not-a-push-spec and don't consume it
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
;;
|
else
|
||||||
|
|
||||||
-p=*|--push=*)
|
|
||||||
PUSH_SET=1
|
|
||||||
val="''${1#*=}"
|
|
||||||
case "$val" in
|
|
||||||
false|0|no|off) DO_PUSH=0 ;;
|
|
||||||
true|1|yes|on|"") DO_PUSH=1 ;;
|
|
||||||
*) die "Invalid value for --push: $val (use true/false)" ;;
|
|
||||||
esac
|
|
||||||
shift
|
shift
|
||||||
;;
|
|
||||||
|
|
||||||
--make-local|-l) MODE_FORCE="local"; shift ;;
|
|
||||||
--make-remote|-r) MODE_FORCE="remote"; shift ;;
|
|
||||||
--ssh) USE_SSH="true"; shift ;;
|
|
||||||
-h|--help) usage ;;
|
|
||||||
*) die "Unknown argument: $1" ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
[ -n "$TARGET" ] || die "Missing required subcommand: user=<username> or system=<device-type>:<hostkey>"
|
|
||||||
|
|
||||||
# --- validate athenix working tree path ---
|
|
||||||
[ -d "$ATHENIX_DIR" ] || die "$ATHENIX_DIR does not exist"
|
|
||||||
git -C "$ATHENIX_DIR" rev-parse --is-inside-work-tree >/dev/null 2>&1 || die "$ATHENIX_DIR is not a git project (athenix checkout)"
|
|
||||||
|
|
||||||
# --- -b behavior: fork/switch athenix working tree into branch ---
|
|
||||||
if [ -n "$ATHENIX_BRANCH" ]; then
|
|
||||||
ATH_CUR_BRANCH="$(git -C "$ATHENIX_DIR" rev-parse --abbrev-ref HEAD)"
|
|
||||||
if [ "$ATH_CUR_BRANCH" != "$ATHENIX_BRANCH" ]; then
|
|
||||||
if git -C "$ATHENIX_DIR" show-ref --verify --quiet "refs/heads/$ATHENIX_BRANCH"; then
|
|
||||||
warn "Branch '$ATHENIX_BRANCH' already exists in $ATHENIX_DIR."
|
|
||||||
warn "Delete and recreate it from current branch '$ATH_CUR_BRANCH' state? [y/N] "
|
|
||||||
read -r ans || true
|
|
||||||
case "''${ans:-N}" in
|
|
||||||
y|Y|yes|YES)
|
|
||||||
git -C "$ATHENIX_DIR" branch -D "$ATHENIX_BRANCH"
|
|
||||||
git -C "$ATHENIX_DIR" switch -c "$ATHENIX_BRANCH"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
git -C "$ATHENIX_DIR" switch "$ATHENIX_BRANCH"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
git -C "$ATHENIX_DIR" switch -c "$ATHENIX_BRANCH"
|
|
||||||
fi
|
fi
|
||||||
fi
|
;;
|
||||||
fi
|
|
||||||
|
|
||||||
# --- target file + identifiers ---
|
-p=*|--push=*)
|
||||||
MODE=""; FILE=""; USERNAME=""; DEVTYPE=""; HOSTKEY=""
|
PUSH_SET=1
|
||||||
case "$TARGET" in
|
val="''${1#*=}"
|
||||||
user=*)
|
case "$val" in
|
||||||
MODE="user"
|
false|0|no|off) DO_PUSH=0 ;;
|
||||||
USERNAME="''${TARGET#user=}"
|
true|1|yes|on|"") DO_PUSH=1 ;;
|
||||||
[ -n "$USERNAME" ] || die "user=<username>: username missing"
|
*) die "Invalid value for --push: $val (use true/false)" ;;
|
||||||
FILE="$ATHENIX_DIR/users.nix"
|
esac
|
||||||
;;
|
shift
|
||||||
system=*)
|
|
||||||
MODE="system"
|
|
||||||
RHS="''${TARGET#system=}"
|
|
||||||
printf "%s" "$RHS" | grep -q ':' || die "system=... must be system=<device-type>:<hostkey>"
|
|
||||||
DEVTYPE="''${RHS%%:*}"
|
|
||||||
HOSTKEY="''${RHS#*:}"
|
|
||||||
[ -n "$DEVTYPE" ] || die "system=<device-type>:<hostkey>: device-type missing"
|
|
||||||
[ -n "$HOSTKEY" ] || die "system=<device-type>:<hostkey>: hostkey missing"
|
|
||||||
FILE="$ATHENIX_DIR/inventory.nix"
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
--make-local|-l) MODE_FORCE="local"; shift ;;
|
||||||
|
--make-remote|-r) MODE_FORCE="remote"; shift ;;
|
||||||
|
--ssh) USE_SSH="true"; shift ;;
|
||||||
|
-h|--help) usage ;;
|
||||||
|
*) die "Unknown argument: $1" ;;
|
||||||
esac
|
esac
|
||||||
[ -f "$FILE" ] || die "File not found: $FILE"
|
done
|
||||||
|
|
||||||
# --- push default based on existing entry url in the target file ---
|
[ -n "$TARGET" ] || die "Missing required subcommand: user=<username> or system=<device-type>:<hostkey>"
|
||||||
EXISTING_URL=""
|
|
||||||
ENTRY_EXISTS=0
|
# --- validate athenix working tree path ---
|
||||||
if [ "$MODE" = "user" ]; then
|
[ -d "$ATHENIX_DIR" ] || die "$ATHENIX_DIR does not exist"
|
||||||
EXISTING_URL="$(extract_existing_fetch_url user "$FILE" "$USERNAME" "" "false")"
|
git -C "$ATHENIX_DIR" rev-parse --is-inside-work-tree >/dev/null 2>&1 || die "$ATHENIX_DIR is not a git project (athenix checkout)"
|
||||||
|
|
||||||
|
# --- -b behavior: fork/switch athenix working tree into branch ---
|
||||||
|
if [ -n "$ATHENIX_BRANCH" ]; then
|
||||||
|
ATH_CUR_BRANCH="$(git -C "$ATHENIX_DIR" rev-parse --abbrev-ref HEAD)"
|
||||||
|
if [ "$ATH_CUR_BRANCH" != "$ATHENIX_BRANCH" ]; then
|
||||||
|
if git -C "$ATHENIX_DIR" show-ref --verify --quiet "refs/heads/$ATHENIX_BRANCH"; then
|
||||||
|
warn "Branch '$ATHENIX_BRANCH' already exists in $ATHENIX_DIR."
|
||||||
|
warn "Delete and recreate it from current branch '$ATH_CUR_BRANCH' state? [y/N] "
|
||||||
|
read -r ans || true
|
||||||
|
case "''${ans:-N}" in
|
||||||
|
y|Y|yes|YES)
|
||||||
|
git -C "$ATHENIX_DIR" branch -D "$ATHENIX_BRANCH"
|
||||||
|
git -C "$ATHENIX_DIR" switch -c "$ATHENIX_BRANCH"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
git -C "$ATHENIX_DIR" switch "$ATHENIX_BRANCH"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
git -C "$ATHENIX_DIR" switch -c "$ATHENIX_BRANCH"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- target file + identifiers ---
|
||||||
|
MODE=""; FILE=""; USERNAME=""; DEVTYPE=""; HOSTKEY=""
|
||||||
|
case "$TARGET" in
|
||||||
|
user=*)
|
||||||
|
MODE="user"
|
||||||
|
USERNAME="''${TARGET#user=}"
|
||||||
|
[ -n "$USERNAME" ] || die "user=<username>: username missing"
|
||||||
|
FILE="$ATHENIX_DIR/users.nix"
|
||||||
|
;;
|
||||||
|
system=*)
|
||||||
|
MODE="system"
|
||||||
|
RHS="''${TARGET#system=}"
|
||||||
|
printf "%s" "$RHS" | grep -q ':' || die "system=... must be system=<device-type>:<hostkey>"
|
||||||
|
DEVTYPE="''${RHS%%:*}"
|
||||||
|
HOSTKEY="''${RHS#*:}"
|
||||||
|
[ -n "$DEVTYPE" ] || die "system=<device-type>:<hostkey>: device-type missing"
|
||||||
|
[ -n "$HOSTKEY" ] || die "system=<device-type>:<hostkey>: hostkey missing"
|
||||||
|
FILE="$ATHENIX_DIR/inventory.nix"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
[ -f "$FILE" ] || die "File not found: $FILE"
|
||||||
|
|
||||||
|
# --- push default based on existing entry url in the target file ---
|
||||||
|
EXISTING_URL=""
|
||||||
|
ENTRY_EXISTS=0
|
||||||
|
if [ "$MODE" = "user" ]; then
|
||||||
|
EXISTING_URL="$(extract_existing_fetch_url user "$FILE" "$USERNAME" "" "false")"
|
||||||
|
[ -n "$EXISTING_URL" ] && ENTRY_EXISTS=1 || true
|
||||||
|
else
|
||||||
|
FULL="$(derive_full_hostname "$DEVTYPE" "$HOSTKEY")"
|
||||||
|
EXISTING_URL="$(extract_existing_fetch_url system "$FILE" "" "$HOSTKEY")"
|
||||||
|
if [ -n "$EXISTING_URL" ]; then
|
||||||
|
ENTRY_EXISTS=1
|
||||||
|
elif [ "$FULL" != "$HOSTKEY" ]; then
|
||||||
|
EXISTING_URL="$(extract_existing_fetch_url system "$FILE" "" "$FULL")"
|
||||||
[ -n "$EXISTING_URL" ] && ENTRY_EXISTS=1 || true
|
[ -n "$EXISTING_URL" ] && ENTRY_EXISTS=1 || true
|
||||||
else
|
|
||||||
FULL="$(derive_full_hostname "$DEVTYPE" "$HOSTKEY")"
|
|
||||||
EXISTING_URL="$(extract_existing_fetch_url system "$FILE" "" "$HOSTKEY")"
|
|
||||||
if [ -n "$EXISTING_URL" ]; then
|
|
||||||
ENTRY_EXISTS=1
|
|
||||||
elif [ "$FULL" != "$HOSTKEY" ]; then
|
|
||||||
EXISTING_URL="$(extract_existing_fetch_url system "$FILE" "" "$FULL")"
|
|
||||||
[ -n "$EXISTING_URL" ] && ENTRY_EXISTS=1 || true
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$PUSH_SET" -eq 0 ]; then
|
if [ "$PUSH_SET" -eq 0 ]; then
|
||||||
if [ "$ENTRY_EXISTS" -eq 1 ] && is_remote_url "$EXISTING_URL"; then
|
if [ "$ENTRY_EXISTS" -eq 1 ] && is_remote_url "$EXISTING_URL"; then
|
||||||
DO_PUSH=1
|
DO_PUSH=1
|
||||||
else
|
else
|
||||||
DO_PUSH=0
|
|
||||||
[ "$MODE_FORCE" = "remote" ] && DO_PUSH=1 || true
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [ "$MODE_FORCE" = "local" ] && [ "$PUSH_SET" -eq 0 ]; then
|
|
||||||
DO_PUSH=0
|
DO_PUSH=0
|
||||||
|
[ "$MODE_FORCE" = "remote" ] && DO_PUSH=1 || true
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
if [ "$MODE_FORCE" = "local" ] && [ "$PUSH_SET" -eq 0 ]; then
|
||||||
|
DO_PUSH=0
|
||||||
|
fi
|
||||||
|
|
||||||
# --- if current repo dirty, prompt ---
|
# --- if current repo dirty, prompt ---
|
||||||
if [ -n "$(git status --porcelain)" ]; then
|
if [ -n "$(git status --porcelain)" ]; then
|
||||||
warn "This branch has untracked or uncommitted changes. Would you like to add, commit''${DO_PUSH:+, and push}? [y/N] "
|
warn "This branch has untracked or uncommitted changes. Would you like to add, commit''${DO_PUSH:+, and push}? [y/N] "
|
||||||
read -r ans || true
|
read -r ans || true
|
||||||
case "''${ans:-N}" in
|
case "''${ans:-N}" in
|
||||||
y|Y|yes|YES)
|
y|Y|yes|YES)
|
||||||
git add -A
|
git add -A
|
||||||
if ! git diff --cached --quiet; then
|
if ! git diff --cached --quiet; then
|
||||||
if [ -n "$COMMIT_MSG" ]; then git commit -m "$COMMIT_MSG"; else git commit; fi
|
if [ -n "$COMMIT_MSG" ]; then git commit -m "$COMMIT_MSG"; else git commit; fi
|
||||||
else
|
|
||||||
warn "No staged changes to commit."
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*) warn "Proceeding without committing. (rev will be last committed HEAD.)" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --- push current repo if requested ---
|
|
||||||
PUSH_REMOTE_URL=""
|
|
||||||
if [ "$DO_PUSH" -eq 1 ]; then
|
|
||||||
if [ -n "$PUSH_SPEC" ]; then
|
|
||||||
if printf "%s" "$PUSH_SPEC" | grep -q '='; then
|
|
||||||
REM_NAME="''${PUSH_SPEC%%=*}"
|
|
||||||
REM_URL="''${PUSH_SPEC#*=}"
|
|
||||||
[ -n "$REM_NAME" ] || die "--push remote-name=URL: remote-name missing"
|
|
||||||
[ -n "$REM_URL" ] || die "--push remote-name=URL: URL missing"
|
|
||||||
if git remote get-url "$REM_NAME" >/dev/null 2>&1; then
|
|
||||||
git remote set-url "$REM_NAME" "$REM_URL"
|
|
||||||
else
|
|
||||||
git remote add "$REM_NAME" "$REM_URL"
|
|
||||||
fi
|
|
||||||
git push -u "$REM_NAME" "$CUR_BRANCH"
|
|
||||||
PUSH_REMOTE_URL="$REM_URL"
|
|
||||||
else
|
else
|
||||||
REM_NAME="$PUSH_SPEC"
|
warn "No staged changes to commit."
|
||||||
git push -u "$REM_NAME" "$CUR_BRANCH"
|
|
||||||
PUSH_REMOTE_URL="$(git remote get-url "$REM_NAME")"
|
|
||||||
fi
|
fi
|
||||||
else
|
;;
|
||||||
if ! git rev-parse --abbrev-ref --symbolic-full-name @{u} >/dev/null 2>&1; then
|
*) warn "Proceeding without committing. (rev will be last committed HEAD.)" ;;
|
||||||
die "No upstream is set. Set a default upstream with \"git branch -u <remote>/<remote_branch_name>\""
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- push current repo if requested ---
|
||||||
|
PUSH_REMOTE_URL=""
|
||||||
|
if [ "$DO_PUSH" -eq 1 ]; then
|
||||||
|
if [ -n "$PUSH_SPEC" ]; then
|
||||||
|
if printf "%s" "$PUSH_SPEC" | grep -q '='; then
|
||||||
|
REM_NAME="''${PUSH_SPEC%%=*}"
|
||||||
|
REM_URL="''${PUSH_SPEC#*=}"
|
||||||
|
[ -n "$REM_NAME" ] || die "--push remote-name=URL: remote-name missing"
|
||||||
|
[ -n "$REM_URL" ] || die "--push remote-name=URL: URL missing"
|
||||||
|
if git remote get-url "$REM_NAME" >/dev/null 2>&1; then
|
||||||
|
git remote set-url "$REM_NAME" "$REM_URL"
|
||||||
|
else
|
||||||
|
git remote add "$REM_NAME" "$REM_URL"
|
||||||
fi
|
fi
|
||||||
git push
|
git push -u "$REM_NAME" "$CUR_BRANCH"
|
||||||
UPSTREAM_REMOTE="$(git rev-parse --abbrev-ref --symbolic-full-name @{u} | cut -d/ -f1)"
|
PUSH_REMOTE_URL="$REM_URL"
|
||||||
PUSH_REMOTE_URL="$(git remote get-url "$UPSTREAM_REMOTE")"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
CUR_REV="$(git -C "$CUR_REPO_ROOT" rev-parse HEAD)"
|
|
||||||
|
|
||||||
# --- choose URL to write into fetchGit ---
|
|
||||||
if [ "$MODE_FORCE" = "local" ]; then
|
|
||||||
FETCH_URL="file://$CUR_REPO_ROOT"
|
|
||||||
elif [ "$MODE_FORCE" = "remote" ]; then
|
|
||||||
if [ "$DO_PUSH" -eq 1 ]; then
|
|
||||||
FETCH_URL="$PUSH_REMOTE_URL"
|
|
||||||
elif [ "$ENTRY_EXISTS" -eq 1 ] && [ -n "$EXISTING_URL" ] && is_remote_url "$EXISTING_URL"; then
|
|
||||||
FETCH_URL="$EXISTING_URL"
|
|
||||||
else
|
else
|
||||||
CUR_ORIGIN="$(git remote get-url origin 2>/dev/null || true)"
|
REM_NAME="$PUSH_SPEC"
|
||||||
[ -n "$CUR_ORIGIN" ] && is_remote_url "$CUR_ORIGIN" || die "--make-remote requires a remote url (set origin or use -p remote=URL)"
|
git push -u "$REM_NAME" "$CUR_BRANCH"
|
||||||
FETCH_URL="$CUR_ORIGIN"
|
PUSH_REMOTE_URL="$(git remote get-url "$REM_NAME")"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$DO_PUSH" -eq 1 ]; then FETCH_URL="$PUSH_REMOTE_URL"; else FETCH_URL="file://$CUR_REPO_ROOT"; fi
|
if ! git rev-parse --abbrev-ref --symbolic-full-name @{u} >/dev/null 2>&1; then
|
||||||
|
die "No upstream is set. Set a default upstream with \"git branch -u <remote>/<remote_branch_name>\""
|
||||||
|
fi
|
||||||
|
git push
|
||||||
|
UPSTREAM_REMOTE="$(git rev-parse --abbrev-ref --symbolic-full-name @{u} | cut -d/ -f1)"
|
||||||
|
PUSH_REMOTE_URL="$(git remote get-url "$UPSTREAM_REMOTE")"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# --- rewrite users.nix or inventory.nix ---
|
CUR_REV="$(git -C "$CUR_REPO_ROOT" rev-parse HEAD)"
|
||||||
python3 - "$MODE" "$FILE" "$FETCH_URL" "$CUR_REV" "$USERNAME" "$DEVTYPE" "$HOSTKEY" <<'PY'
|
|
||||||
import sys, re, pathlib
|
|
||||||
|
|
||||||
mode = sys.argv[1]
|
# --- choose URL to write into fetchGit ---
|
||||||
path = pathlib.Path(sys.argv[2])
|
if [ "$MODE_FORCE" = "local" ]; then
|
||||||
fetch_url = sys.argv[3]
|
FETCH_URL="file://$CUR_REPO_ROOT"
|
||||||
rev = sys.argv[4]
|
elif [ "$MODE_FORCE" = "remote" ]; then
|
||||||
username = sys.argv[5]
|
if [ "$DO_PUSH" -eq 1 ]; then
|
||||||
devtype = sys.argv[6]
|
FETCH_URL="$PUSH_REMOTE_URL"
|
||||||
hostkey = sys.argv[7]
|
elif [ "$ENTRY_EXISTS" -eq 1 ] && [ -n "$EXISTING_URL" ] && is_remote_url "$EXISTING_URL"; then
|
||||||
text = path.read_text()
|
FETCH_URL="$EXISTING_URL"
|
||||||
|
else
|
||||||
|
CUR_ORIGIN="$(git remote get-url origin 2>/dev/null || true)"
|
||||||
|
[ -n "$CUR_ORIGIN" ] && is_remote_url "$CUR_ORIGIN" || die "--make-remote requires a remote url (set origin or use -p remote=URL)"
|
||||||
|
FETCH_URL="$CUR_ORIGIN"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$DO_PUSH" -eq 1 ]; then FETCH_URL="$PUSH_REMOTE_URL"; else FETCH_URL="file://$CUR_REPO_ROOT"; fi
|
||||||
|
fi
|
||||||
|
|
||||||
def find_matching_brace(s: str, start: int) -> int:
|
# --- rewrite users.nix or inventory.nix ---
|
||||||
depth = 0
|
python3 - "$MODE" "$FILE" "$FETCH_URL" "$CUR_REV" "$USERNAME" "$DEVTYPE" "$HOSTKEY" <<'PY'
|
||||||
i = start
|
import sys, re, pathlib
|
||||||
in_str = False
|
|
||||||
while i < len(s):
|
|
||||||
ch = s[i]
|
|
||||||
if in_str:
|
|
||||||
if ch == '\\':
|
|
||||||
i += 2
|
|
||||||
continue
|
|
||||||
if ch == '"':
|
|
||||||
in_str = False
|
|
||||||
i += 1
|
|
||||||
continue
|
|
||||||
if ch == '"':
|
|
||||||
in_str = True
|
|
||||||
i += 1
|
|
||||||
continue
|
|
||||||
if ch == '{':
|
|
||||||
depth += 1
|
|
||||||
elif ch == '}':
|
|
||||||
depth -= 1
|
|
||||||
if depth == 0:
|
|
||||||
return i
|
|
||||||
i += 1
|
|
||||||
raise ValueError("Could not find matching '}'")
|
|
||||||
|
|
||||||
def mk_fetch(entry_indent: str) -> str:
|
mode = sys.argv[1]
|
||||||
# entry_indent is indentation for the whole `"key" = <here>;` line.
|
path = pathlib.Path(sys.argv[2])
|
||||||
# The attrset contents should be indented one level deeper.
|
fetch_url = sys.argv[3]
|
||||||
inner = entry_indent + " "
|
rev = sys.argv[4]
|
||||||
return (
|
username = sys.argv[5]
|
||||||
'builtins.fetchGit {\n'
|
devtype = sys.argv[6]
|
||||||
f'{inner}url = "{fetch_url}";\n'
|
hostkey = sys.argv[7]
|
||||||
f'{inner}rev = "{rev}";\n'
|
text = path.read_text()
|
||||||
f'{inner}submodules = true;\n'
|
|
||||||
f'{entry_indent}}}'
|
def find_matching_brace(s: str, start: int) -> int:
|
||||||
|
depth = 0
|
||||||
|
i = start
|
||||||
|
in_str = False
|
||||||
|
while i < len(s):
|
||||||
|
ch = s[i]
|
||||||
|
if in_str:
|
||||||
|
if ch == '\\':
|
||||||
|
i += 2
|
||||||
|
continue
|
||||||
|
if ch == '"':
|
||||||
|
in_str = False
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if ch == '"':
|
||||||
|
in_str = True
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if ch == '{':
|
||||||
|
depth += 1
|
||||||
|
elif ch == '}':
|
||||||
|
depth -= 1
|
||||||
|
if depth == 0:
|
||||||
|
return i
|
||||||
|
i += 1
|
||||||
|
raise ValueError("Could not find matching '}'")
|
||||||
|
|
||||||
|
def mk_fetch(entry_indent: str) -> str:
|
||||||
|
# entry_indent is indentation for the whole `"key" = <here>;` line.
|
||||||
|
# The attrset contents should be indented one level deeper.
|
||||||
|
inner = entry_indent + " "
|
||||||
|
return (
|
||||||
|
'builtins.fetchGit {\n'
|
||||||
|
f'{inner}url = "{fetch_url}";\n'
|
||||||
|
f'{inner}rev = "{rev}";\n'
|
||||||
|
f'{inner}submodules = true;\n'
|
||||||
|
f'{entry_indent}}}'
|
||||||
|
)
|
||||||
|
|
||||||
|
def full_hostname(devtype: str, hostkey: str) -> str:
|
||||||
|
if hostkey.startswith(devtype) or "-" in hostkey:
|
||||||
|
return hostkey
|
||||||
|
if hostkey.isdigit():
|
||||||
|
return f"{devtype}{hostkey}"
|
||||||
|
return f"{devtype}-{hostkey}"
|
||||||
|
|
||||||
|
def update_user(t: str) -> str:
|
||||||
|
mblock = re.search(r"(?s)athenix\.users\s*=\s*\{(.*?)\n\s*\};", t)
|
||||||
|
if not mblock:
|
||||||
|
raise SystemExit("error: could not locate `athenix.users = { ... };` block")
|
||||||
|
|
||||||
|
# locate the full span of the users block to edit inside it
|
||||||
|
# (re-find with groups for reconstruction)
|
||||||
|
m2 = re.search(r"(?s)(athenix\.users\s*=\s*\{)(.*?)(\n\s*\};)", t)
|
||||||
|
head, body, tail = m2.group(1), m2.group(2), m2.group(3)
|
||||||
|
|
||||||
|
entry_re = re.search(
|
||||||
|
r"(?s)(\n[ \t]*" + re.escape(username) + r"\.external\s*=\s*)builtins\.fetchGit\s*\{",
|
||||||
|
body
|
||||||
)
|
)
|
||||||
|
if entry_re:
|
||||||
|
brace = body.rfind("{", 0, entry_re.end())
|
||||||
|
end = find_matching_brace(body, brace)
|
||||||
|
semi = re.match(r"\s*;", body[end+1:])
|
||||||
|
if not semi:
|
||||||
|
raise SystemExit("error: expected ';' after fetchGit attrset")
|
||||||
|
semi_end = end + 1 + semi.end()
|
||||||
|
|
||||||
def full_hostname(devtype: str, hostkey: str) -> str:
|
line_start = body.rfind("\n", 0, entry_re.start()) + 1
|
||||||
if hostkey.startswith(devtype) or "-" in hostkey:
|
indent = re.match(r"[ \t]*", body[line_start:entry_re.start()]).group(0)
|
||||||
return hostkey
|
|
||||||
if hostkey.isdigit():
|
|
||||||
return f"{devtype}{hostkey}"
|
|
||||||
return f"{devtype}-{hostkey}"
|
|
||||||
|
|
||||||
def update_user(t: str) -> str:
|
new_body = body[:entry_re.start()] + entry_re.group(1) + mk_fetch(indent) + ";" + body[semi_end:]
|
||||||
mblock = re.search(r"(?s)athenix\.users\s*=\s*\{(.*?)\n\s*\};", t)
|
else:
|
||||||
if not mblock:
|
indent = " "
|
||||||
raise SystemExit("error: could not locate `athenix.users = { ... };` block")
|
new_body = body + f"\n{indent}{username}.external = {mk_fetch(indent)};\n"
|
||||||
|
|
||||||
# locate the full span of the users block to edit inside it
|
return t[:m2.start()] + head + new_body + tail + t[m2.end():]
|
||||||
# (re-find with groups for reconstruction)
|
|
||||||
m2 = re.search(r"(?s)(athenix\.users\s*=\s*\{)(.*?)(\n\s*\};)", t)
|
|
||||||
head, body, tail = m2.group(1), m2.group(2), m2.group(3)
|
|
||||||
|
|
||||||
entry_re = re.search(
|
def update_system(t: str) -> str:
|
||||||
r"(?s)(\n[ \t]*" + re.escape(username) + r"\.external\s*=\s*)builtins\.fetchGit\s*\{",
|
# Find devtype block robustly: start-of-file or newline.
|
||||||
body
|
m = re.search(r"(?s)(^|\n)[ \t]*" + re.escape(devtype) + r"\s*=\s*\{", t)
|
||||||
)
|
if not m:
|
||||||
if entry_re:
|
raise SystemExit(f"error: could not locate `{devtype} = {{ ... }};` block")
|
||||||
brace = body.rfind("{", 0, entry_re.end())
|
|
||||||
end = find_matching_brace(body, brace)
|
dev_open = t.find("{", m.end() - 1)
|
||||||
semi = re.match(r"\s*;", body[end+1:])
|
dev_close = find_matching_brace(t, dev_open)
|
||||||
|
dev = t[dev_open:dev_close+1]
|
||||||
|
|
||||||
|
# Find devices attrset inside dev
|
||||||
|
dm = re.search(r"(?s)(^|\n)[ \t]*devices\s*=\s*\{", dev)
|
||||||
|
if not dm:
|
||||||
|
raise SystemExit(f"error: could not locate `devices = {{ ... }};` inside `{devtype}`")
|
||||||
|
|
||||||
|
devices_open = dev.find("{", dm.end() - 1)
|
||||||
|
devices_close = find_matching_brace(dev, devices_open)
|
||||||
|
devices = dev[devices_open:devices_close+1]
|
||||||
|
|
||||||
|
# indentation for entries in devices
|
||||||
|
# find indent of the 'devices' line, then add 2 spaces
|
||||||
|
|
||||||
|
candidates = [hostkey, full_hostname(devtype, hostkey)]
|
||||||
|
seen = set()
|
||||||
|
candidates = [c for c in candidates if not (c in seen or seen.add(c))]
|
||||||
|
|
||||||
|
for key in candidates:
|
||||||
|
entry = re.search(
|
||||||
|
r'(?s)\n([ ]*)"' + re.escape(key) + r'"\s*=\s*builtins\.fetchGit\s*\{',
|
||||||
|
devices
|
||||||
|
)
|
||||||
|
if entry:
|
||||||
|
entry_indent = entry.group(1)
|
||||||
|
|
||||||
|
# find the '{' we matched
|
||||||
|
brace = devices.find("{", entry.end() - 1)
|
||||||
|
end = find_matching_brace(devices, brace)
|
||||||
|
|
||||||
|
semi = re.match(r"\s*;", devices[end+1:])
|
||||||
if not semi:
|
if not semi:
|
||||||
raise SystemExit("error: expected ';' after fetchGit attrset")
|
raise SystemExit("error: expected ';' after fetchGit attrset in devices")
|
||||||
semi_end = end + 1 + semi.end()
|
semi_end = end + 1 + semi.end()
|
||||||
|
|
||||||
line_start = body.rfind("\n", 0, entry_re.start()) + 1
|
# Reconstruct the prefix: newline + indent + "key" =
|
||||||
indent = re.match(r"[ \t]*", body[line_start:entry_re.start()]).group(0)
|
prefix = f'\n{entry_indent}"{key}" = '
|
||||||
|
|
||||||
new_body = body[:entry_re.start()] + entry_re.group(1) + mk_fetch(indent) + ";" + body[semi_end:]
|
new_devices = (
|
||||||
else:
|
devices[:entry.start()]
|
||||||
indent = " "
|
+ prefix
|
||||||
new_body = body + f"\n{indent}{username}.external = {mk_fetch(indent)};\n"
|
+ mk_fetch(entry_indent)
|
||||||
|
+ ";"
|
||||||
return t[:m2.start()] + head + new_body + tail + t[m2.end():]
|
+ devices[semi_end:]
|
||||||
|
|
||||||
def update_system(t: str) -> str:
|
|
||||||
# Find devtype block robustly: start-of-file or newline.
|
|
||||||
m = re.search(r"(?s)(^|\n)[ \t]*" + re.escape(devtype) + r"\s*=\s*\{", t)
|
|
||||||
if not m:
|
|
||||||
raise SystemExit(f"error: could not locate `{devtype} = {{ ... }};` block")
|
|
||||||
|
|
||||||
dev_open = t.find("{", m.end() - 1)
|
|
||||||
dev_close = find_matching_brace(t, dev_open)
|
|
||||||
dev = t[dev_open:dev_close+1]
|
|
||||||
|
|
||||||
# Find devices attrset inside dev
|
|
||||||
dm = re.search(r"(?s)(^|\n)[ \t]*devices\s*=\s*\{", dev)
|
|
||||||
if not dm:
|
|
||||||
raise SystemExit(f"error: could not locate `devices = {{ ... }};` inside `{devtype}`")
|
|
||||||
|
|
||||||
devices_open = dev.find("{", dm.end() - 1)
|
|
||||||
devices_close = find_matching_brace(dev, devices_open)
|
|
||||||
devices = dev[devices_open:devices_close+1]
|
|
||||||
|
|
||||||
# indentation for entries in devices
|
|
||||||
# find indent of the 'devices' line, then add 2 spaces
|
|
||||||
|
|
||||||
candidates = [hostkey, full_hostname(devtype, hostkey)]
|
|
||||||
seen = set()
|
|
||||||
candidates = [c for c in candidates if not (c in seen or seen.add(c))]
|
|
||||||
|
|
||||||
for key in candidates:
|
|
||||||
entry = re.search(
|
|
||||||
r'(?s)\n([ ]*)"' + re.escape(key) + r'"\s*=\s*builtins\.fetchGit\s*\{',
|
|
||||||
devices
|
|
||||||
)
|
)
|
||||||
if entry:
|
new_dev = dev[:devices_open] + new_devices + dev[devices_close+1:]
|
||||||
entry_indent = entry.group(1)
|
|
||||||
|
|
||||||
# find the '{' we matched
|
return t[:dev_open] + new_dev + t[dev_close+1:]
|
||||||
brace = devices.find("{", entry.end() - 1)
|
|
||||||
end = find_matching_brace(devices, brace)
|
|
||||||
|
|
||||||
semi = re.match(r"\s*;", devices[end+1:])
|
# Not found: append into devices (exact hostkey)
|
||||||
if not semi:
|
# Indent for new entries: take indent of the closing '}' of devices, add 2 spaces.
|
||||||
raise SystemExit("error: expected ';' after fetchGit attrset in devices")
|
close_line_start = devices.rfind("\n", 0, len(devices)-1) + 1
|
||||||
semi_end = end + 1 + semi.end()
|
close_indent = re.match(r"[ ]*", devices[close_line_start:]).group(0)
|
||||||
|
entry_indent = close_indent + " "
|
||||||
|
|
||||||
# Reconstruct the prefix: newline + indent + "key" =
|
insertion = f'\n{entry_indent}"{hostkey}" = {mk_fetch(entry_indent)};\n'
|
||||||
prefix = f'\n{entry_indent}"{key}" = '
|
new_devices = devices[:-1].rstrip() + insertion + close_indent + "}"
|
||||||
|
new_dev = dev[:devices_open] + new_devices + dev[devices_close+1:]
|
||||||
|
return t[:dev_open] + new_dev + t[dev_close+1:]
|
||||||
|
|
||||||
new_devices = (
|
if mode == "user":
|
||||||
devices[:entry.start()]
|
out = update_user(text)
|
||||||
+ prefix
|
elif mode == "system":
|
||||||
+ mk_fetch(entry_indent)
|
out = update_system(text)
|
||||||
+ ";"
|
else:
|
||||||
+ devices[semi_end:]
|
raise SystemExit("error: unknown mode")
|
||||||
)
|
|
||||||
new_dev = dev[:devices_open] + new_devices + dev[devices_close+1:]
|
|
||||||
|
|
||||||
return t[:dev_open] + new_dev + t[dev_close+1:]
|
path.write_text(out)
|
||||||
|
PY
|
||||||
|
|
||||||
# Not found: append into devices (exact hostkey)
|
cd $ATHENIX_DIR
|
||||||
# Indent for new entries: take indent of the closing '}' of devices, add 2 spaces.
|
nix fmt **/*.nix
|
||||||
close_line_start = devices.rfind("\n", 0, len(devices)-1) + 1
|
cd $CUR_REPO_ROOT
|
||||||
close_indent = re.match(r"[ ]*", devices[close_line_start:]).group(0)
|
|
||||||
entry_indent = close_indent + " "
|
|
||||||
|
|
||||||
insertion = f'\n{entry_indent}"{hostkey}" = {mk_fetch(entry_indent)};\n'
|
printf "updated %s\n" "$FILE" >&2
|
||||||
new_devices = devices[:-1].rstrip() + insertion + close_indent + "}"
|
printf " url = %s\n" "$FETCH_URL" >&2
|
||||||
new_dev = dev[:devices_open] + new_devices + dev[devices_close+1:]
|
printf " rev = %s\n" "$CUR_REV" >&2
|
||||||
return t[:dev_open] + new_dev + t[dev_close+1:]
|
'')
|
||||||
|
];
|
||||||
if mode == "user":
|
|
||||||
out = update_user(text)
|
|
||||||
elif mode == "system":
|
|
||||||
out = update_system(text)
|
|
||||||
else:
|
|
||||||
raise SystemExit("error: unknown mode")
|
|
||||||
|
|
||||||
path.write_text(out)
|
|
||||||
PY
|
|
||||||
|
|
||||||
cd $ATHENIX_DIR
|
|
||||||
nix fmt **/*.nix
|
|
||||||
cd $CUR_REPO_ROOT
|
|
||||||
|
|
||||||
printf "updated %s\n" "$FILE" >&2
|
|
||||||
printf " url = %s\n" "$FETCH_URL" >&2
|
|
||||||
printf " rev = %s\n" "$CUR_REV" >&2
|
|
||||||
'')
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,47 +9,27 @@ with lib;
|
|||||||
|
|
||||||
{
|
{
|
||||||
options.athenix.sw.remoteBuild = lib.mkOption {
|
options.athenix.sw.remoteBuild = lib.mkOption {
|
||||||
type = lib.types.submodule {
|
type = types.submodule {
|
||||||
options = {
|
options = {
|
||||||
hosts = mkOption {
|
hosts = mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = types.listOf types.str;
|
||||||
default = [ "engr-ugaif@192.168.11.133 x86_64-linux" ];
|
default = [ "engr-ugaif@192.168.11.133 x86_64-linux" ];
|
||||||
description = ''
|
description = "List of remote build hosts for system rebuilding.";
|
||||||
List of remote build hosts for system rebuilding.
|
|
||||||
|
|
||||||
Format: "user@hostname architecture"
|
|
||||||
Each host must have SSH access and nix-daemon available.
|
|
||||||
|
|
||||||
Useful for offloading builds from low-power devices (tablets, laptops)
|
|
||||||
to more powerful build servers.
|
|
||||||
'';
|
|
||||||
example = lib.literalExpression ''
|
|
||||||
[
|
|
||||||
"builder@nix-builder x86_64-linux"
|
|
||||||
"user@192.168.1.100 aarch64-linux"
|
|
||||||
]'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
type = lib.types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = "Whether to enable remote build for 'update-system' command.";
|
||||||
Whether to enable remote builds for the 'update-system' command.
|
|
||||||
|
|
||||||
When enabled, 'update-system' will use the configured remote hosts
|
|
||||||
to build the new system configuration instead of building locally.
|
|
||||||
|
|
||||||
Automatically enabled for tablet-kiosk systems.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
default = { };
|
default = { };
|
||||||
description = "Remote build configuration for system updates.";
|
description = "Remote build configuration";
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
athenix.sw.remoteBuild.enable = lib.mkDefault (config.athenix.sw.tablet-kiosk.enable);
|
athenix.sw.remoteBuild.enable = lib.mkDefault (config.athenix.sw.type == "tablet-kiosk");
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
(pkgs.writeShellScriptBin "update-system" ''
|
(pkgs.writeShellScriptBin "update-system" ''
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{ ... }:
|
{ inputs, ... }:
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# User Configuration
|
# User Configuration
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
# nixos-systems configuration (nixpkgs, home-manager, etc.).
|
# nixos-systems configuration (nixpkgs, home-manager, etc.).
|
||||||
|
|
||||||
{
|
{
|
||||||
|
config,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
osConfig ? null, # Only available in home-manager context
|
osConfig ? null, # Only available in home-manager context
|
||||||
@@ -59,7 +60,7 @@
|
|||||||
fd
|
fd
|
||||||
bat
|
bat
|
||||||
]
|
]
|
||||||
++ lib.optional (osConfig.athenix.sw.desktop.enable or false) firefox;
|
++ lib.optional (osConfig.athenix.sw.type or null == "desktop") firefox;
|
||||||
# Conditionally add packages based on system type
|
# Conditionally add packages based on system type
|
||||||
|
|
||||||
# ========== Programs ==========
|
# ========== Programs ==========
|
||||||
|
|||||||
@@ -13,9 +13,8 @@
|
|||||||
#
|
#
|
||||||
# External User Configuration:
|
# External User Configuration:
|
||||||
# Users can specify external configuration modules via the 'external' attribute:
|
# Users can specify external configuration modules via the 'external' attribute:
|
||||||
# external = { url = "..."; rev = "..."; submodules? = false; };
|
# external = builtins.fetchGit { url = "..."; rev = "..."; };
|
||||||
# external = /path/to/local/config;
|
# external = /path/to/local/config;
|
||||||
# external = builtins.fetchGit { ... }; # legacy, still supported
|
|
||||||
#
|
#
|
||||||
# External repositories should contain:
|
# External repositories should contain:
|
||||||
# - user.nix (required): Defines athenix.users.<name> options AND home-manager config
|
# - user.nix (required): Defines athenix.users.<name> options AND home-manager config
|
||||||
@@ -27,7 +26,7 @@
|
|||||||
#
|
#
|
||||||
# User options can be set in users.nix OR in the external module's user.nix.
|
# User options can be set in users.nix OR in the external module's user.nix.
|
||||||
# External module options take precedence over users.nix defaults.
|
# External module options take precedence over users.nix defaults.
|
||||||
config.athenix.users = {
|
athenix.users = {
|
||||||
root = {
|
root = {
|
||||||
isNormalUser = false;
|
isNormalUser = false;
|
||||||
hashedPassword = "!";
|
hashedPassword = "!";
|
||||||
@@ -48,10 +47,9 @@
|
|||||||
enable = true; # Default user, enabled everywhere
|
enable = true; # Default user, enabled everywhere
|
||||||
};
|
};
|
||||||
hdh20267 = {
|
hdh20267 = {
|
||||||
external = {
|
external = builtins.fetchGit {
|
||||||
url = "https://git.factory.uga.edu/hdh20267/hdh20267-nix";
|
url = "https://git.factory.uga.edu/hdh20267/hdh20267-nix";
|
||||||
rev = "dbdf65c7bd59e646719f724a3acd2330e0c922ec";
|
rev = "dbdf65c7bd59e646719f724a3acd2330e0c922ec";
|
||||||
# submodules = false; # optional, defaults to false
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
sv22900 = {
|
sv22900 = {
|
||||||
|
|||||||
Reference in New Issue
Block a user