refactor: Move macCaseBuilder into athenix.lib
All checks were successful
CI / Format Check (push) Successful in 2s
CI / Flake Check (push) Successful in 1m44s
CI / Evaluate Key Configurations (nix-builder) (push) Successful in 14s
CI / Evaluate Key Configurations (nix-laptop1) (push) Successful in 8s
CI / Evaluate Artifacts (lxc-nix-builder) (push) Successful in 13s
CI / Build and Publish Documentation (push) Successful in 10s
CI / Evaluate Key Configurations (nix-desktop1) (push) Successful in 8s
CI / Evaluate Artifacts (installer-iso-nix-laptop1) (push) Successful in 19s
All checks were successful
CI / Format Check (push) Successful in 2s
CI / Flake Check (push) Successful in 1m44s
CI / Evaluate Key Configurations (nix-builder) (push) Successful in 14s
CI / Evaluate Key Configurations (nix-laptop1) (push) Successful in 8s
CI / Evaluate Artifacts (lxc-nix-builder) (push) Successful in 13s
CI / Build and Publish Documentation (push) Successful in 10s
CI / Evaluate Key Configurations (nix-desktop1) (push) Successful in 8s
CI / Evaluate Artifacts (installer-iso-nix-laptop1) (push) Successful in 19s
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
{ ... }:
|
{
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
mkFleet = import ./mkFleet.nix;
|
mkFleet = import ./mkFleet.nix;
|
||||||
|
macCaseBuilder = import ./macCaseBuilder.nix { inherit lib; };
|
||||||
}
|
}
|
||||||
|
|||||||
33
lib/macCaseBuilder.nix
Normal file
33
lib/macCaseBuilder.nix
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{ 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; }
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
# Library functions for flake-parts
|
# Library functions for flake-parts
|
||||||
{ inputs, ... }:
|
{ inputs, ... }:
|
||||||
{
|
{
|
||||||
flake.lib = import ../lib { inherit inputs; };
|
flake.lib = import ../lib {
|
||||||
|
inherit inputs;
|
||||||
|
lib = inputs.nixpkgs.lib;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
# 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.
|
||||||
{
|
{
|
||||||
lib,
|
|
||||||
pkgs,
|
pkgs,
|
||||||
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
macCaseBuilder = (import ./mac-hostmap.nix { inherit lib; }).macCaseBuilder;
|
macCaseBuilder = inputs.self.lib.macCaseBuilder;
|
||||||
macCases = macCaseBuilder {
|
macCases = macCaseBuilder {
|
||||||
varName = "STATION";
|
varName = "STATION";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
# 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,7 +1,4 @@
|
|||||||
{
|
{
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
lib,
|
|
||||||
pkgs,
|
pkgs,
|
||||||
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
macCaseBuilder = (import ./mac-hostmap.nix { inherit lib; }).macCaseBuilder;
|
macCaseBuilder = inputs.self.lib.macCaseBuilder;
|
||||||
shellCases = macCaseBuilder {
|
shellCases = macCaseBuilder {
|
||||||
varName = "NEW_HOST";
|
varName = "NEW_HOST";
|
||||||
prefix = "nix-station";
|
prefix = "nix-station";
|
||||||
|
|||||||
Reference in New Issue
Block a user