refactor: nix fmt classic to nix fmt

This commit is contained in:
Rasyidan Akbar F. 2026-01-30 15:59:48 +07:00
commit f9614371a3
57 changed files with 923 additions and 493 deletions

View file

@ -1,6 +1,18 @@
{ config, lib, pkgs, inputs, ... }:
{
config,
lib,
pkgs,
inputs,
...
}:
let
inherit (lib) mkEnableOption mkOption types mkIf escapeShellArg;
inherit (lib)
mkEnableOption
mkOption
types
mkIf
escapeShellArg
;
cfg = config.rsydn.aiTools;
system = pkgs.stdenv.hostPlatform.system;
@ -10,48 +22,51 @@ let
llmPkgsPinned = inputs.llm-agents-pinned.packages.${system};
# Z.AI Gateway wrapper for Claude Code
zaiWrapperPackages = let zaiCfg = cfg.zai;
in if zaiCfg.enable then
zaiWrapperPackages =
let
claudeExe = lib.getExe llmPkgsPinned.claude-code;
commandName = zaiCfg.commandName;
baseUrl = zaiCfg.baseUrl;
model = zaiCfg.model;
tokenEnvVar = zaiCfg.tokenEnvVar;
in [
(pkgs.writeShellApplication {
name = commandName;
text = ''
if [ -z "''${${tokenEnvVar}:-}" ]; then
echo "${commandName}: environment variable ${tokenEnvVar} is not set" >&2
exit 1
fi
zaiCfg = cfg.zai;
in
if zaiCfg.enable then
let
claudeExe = lib.getExe llmPkgsPinned.claude-code;
commandName = zaiCfg.commandName;
baseUrl = zaiCfg.baseUrl;
model = zaiCfg.model;
tokenEnvVar = zaiCfg.tokenEnvVar;
in
[
(pkgs.writeShellApplication {
name = commandName;
text = ''
if [ -z "''${${tokenEnvVar}:-}" ]; then
echo "${commandName}: environment variable ${tokenEnvVar} is not set" >&2
exit 1
fi
export ANTHROPIC_BASE_URL=${escapeShellArg baseUrl}
export ANTHROPIC_AUTH_TOKEN="''${${tokenEnvVar}}"
export ANTHROPIC_MODEL=${escapeShellArg model}
export ANTHROPIC_BASE_URL=${escapeShellArg baseUrl}
export ANTHROPIC_AUTH_TOKEN="''${${tokenEnvVar}}"
export ANTHROPIC_MODEL=${escapeShellArg model}
exec ${claudeExe} "$@"
'';
})
]
else
[ ];
exec ${claudeExe} "$@"
'';
})
]
else
[ ];
in {
in
{
options.rsydn.aiTools = {
enable = mkEnableOption "AI CLI tools from llm-agents.nix";
zai = mkOption {
type = types.submodule {
options = {
enable = mkEnableOption
"Expose the Z.AI Gateway wrapper command for Claude.";
enable = mkEnableOption "Expose the Z.AI Gateway wrapper command for Claude.";
commandName = mkOption {
type = types.str;
default = "glm";
description =
"Name of the wrapper command that launches Claude via Z.AI.";
description = "Name of the wrapper command that launches Claude via Z.AI.";
};
baseUrl = mkOption {
type = types.str;
@ -66,8 +81,7 @@ in {
tokenEnvVar = mkOption {
type = types.str;
default = "ZAI_API_KEY";
description =
"Environment variable that stores the Z.AI API token.";
description = "Environment variable that stores the Z.AI API token.";
};
};
};
@ -78,15 +92,13 @@ in {
model = "glm-4.7";
tokenEnvVar = "ZAI_API_KEY";
};
description =
"Configuration for the Claude wrapper that targets the Z.AI gateway.";
description = "Configuration for the Claude wrapper that targets the Z.AI gateway.";
};
extraPackages = mkOption {
type = types.listOf types.package;
default = [ ];
description =
"Additional AI tooling packages to add alongside the defaults.";
description = "Additional AI tooling packages to add alongside the defaults.";
};
};
@ -98,6 +110,8 @@ in {
llmPkgs.ccstatusline # latest
llmPkgs.ccusage # latest
llmPkgs.codex
] ++ zaiWrapperPackages ++ cfg.extraPackages;
]
++ zaiWrapperPackages
++ cfg.extraPackages;
};
}

View file

@ -1,8 +1,14 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkOption types mkIf;
cfg = config.rsydn.devTools;
in {
in
{
options.rsydn.devTools = {
enable = mkOption {
type = types.bool;

View file

@ -2,13 +2,13 @@
let
inherit (lib) mkOption types mkIf;
cfg = config.rsydn.direnv;
in {
in
{
options.rsydn.direnv = {
enable = mkOption {
type = types.bool;
default = false;
description =
"Enable direnv with nix-direnv for automatic devshell activation.";
description = "Enable direnv with nix-direnv for automatic devshell activation.";
};
silent = mkOption {
type = types.bool;

View file

@ -1,12 +1,29 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkEnableOption mkOption mkIf types warn unique;
inherit (lib)
mkEnableOption
mkOption
mkIf
types
warn
unique
;
cfg = config.rsydn.languages;
hasPkg = name: builtins.hasAttr name pkgs;
getPkg = name: if hasPkg name then pkgs.${name} else null;
mkToolOption = { name, defaultPackage, description }:
mkToolOption =
{
name,
defaultPackage,
description,
}:
mkOption {
type = types.submodule {
options = {
@ -18,8 +35,7 @@ let
package = mkOption {
type = types.nullOr types.package;
default = defaultPackage;
description =
"Package derivation to install for ${name}. Set to null to skip.";
description = "Package derivation to install for ${name}. Set to null to skip.";
};
};
};
@ -30,23 +46,25 @@ let
description = description;
};
mkToolPackages = specs:
builtins.concatMap (tool:
let toolCfg = tool.cfg;
in if toolCfg.enable then
mkToolPackages =
specs:
builtins.concatMap (
tool:
let
toolCfg = tool.cfg;
in
if toolCfg.enable then
if toolCfg.package != null then
[ toolCfg.package ]
else
warn "rsydn.languages.${tool.name}: package is null, skipping" [ ]
else
[ ]) specs;
[ ]
) specs;
uvPackage = getPkg "uv";
goPackage = getPkg "go";
nodePackage = if builtins.hasAttr "nodejs_20" pkgs then
pkgs.nodejs_20
else
getPkg "nodejs";
nodePackage = if builtins.hasAttr "nodejs_20" pkgs then pkgs.nodejs_20 else getPkg "nodejs";
cargoPackage = getPkg "cargo";
bunPackage = getPkg "bun";
@ -80,7 +98,8 @@ let
languagePackages = mkToolPackages toolSpecs;
in {
in
{
options.rsydn.languages = {
enable = mkEnableOption "Language tooling packages for everyday workflows";

View file

@ -1,8 +1,20 @@
{ config, lib, pkgs, try, ... }:
{
config,
lib,
pkgs,
try,
...
}:
let
inherit (lib) mkEnableOption mkOption types mkIf;
inherit (lib)
mkEnableOption
mkOption
types
mkIf
;
cfg = config.rsydn.try;
in {
in
{
imports = [ try.homeModules.default ];
options.rsydn.try = {