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,4 +1,10 @@
{ pkgs, lib, customPkgs, ... }: {
{
pkgs,
lib,
customPkgs,
...
}:
{
imports = [
./programs/fastfetch
./programs/helix.nix
@ -23,7 +29,10 @@
programs.git.enable = true;
home.packages = with pkgs; [ docker docker-compose ];
home.packages = with pkgs; [
docker
docker-compose
];
rsydn.aiTools = {
enable = lib.mkDefault true;

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 = {

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
{
home.packages = [ pkgs.fastfetch ];
@ -6,147 +11,145 @@
# Copy the custom logo file
xdg.configFile."fastfetch/oguri-logo.txt".source = ./oguri-logo.txt;
xdg.configFile."fastfetch/config.jsonc".text = let
esc = builtins.fromJSON ''"\u001b"'';
osIcon = if pkgs.stdenv.isDarwin then "" else "";
in builtins.toJSON {
"$schema" =
"https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json";
xdg.configFile."fastfetch/config.jsonc".text =
let
esc = builtins.fromJSON ''"\u001b"'';
osIcon = if pkgs.stdenv.isDarwin then "" else "";
in
builtins.toJSON {
"$schema" = "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json";
logo = {
type = "file";
source = "~/.config/fastfetch/oguri-logo.txt";
color."1" = "green";
padding = {
top = 2;
right = 6;
left = 2;
logo = {
type = "file";
source = "~/.config/fastfetch/oguri-logo.txt";
color."1" = "green";
padding = {
top = 2;
right = 6;
left = 2;
};
};
display = {
separator = " ";
key = {
width = 16;
};
};
modules = [
"break"
# Hardware Section
{
type = "custom";
format = "${esc}[32m Hardware${esc}[0m";
}
{
type = "host";
key = " PC";
keyColor = "green";
}
{
type = "cpu";
key = " CPU";
showPeCoreCount = true;
keyColor = "green";
}
{
type = "gpu";
key = " GPU";
detectionMethod = "pci";
keyColor = "green";
}
{
type = "display";
key = "󱄄 Display";
keyColor = "green";
}
{
type = "disk";
key = "󰋊 Disk";
keyColor = "green";
}
{
type = "memory";
key = " Memory";
keyColor = "green";
}
{
type = "swap";
key = "󰓡 Swap";
keyColor = "green";
}
"break"
# Software Section
{
type = "custom";
format = "${esc}[34m Software${esc}[0m";
}
{
type = "command";
key = "${osIcon} OS";
keyColor = "blue";
text = "if [ $(uname) = 'Darwin' ]; then ver=$(sw_vers -productVersion); major=$(echo $ver | cut -d. -f1); case $major in 15) name='Sequoia';; 14) name='Sonoma';; 13) name='Ventura';; 12) name='Monterey';; 11) name='Big Sur';; *) name=''';; esac; echo \"macOS $name $major\"; else echo \"$(cat /etc/os-release | grep PRETTY_NAME | cut -d'\\\"' -f2)\"; fi";
}
{
type = "kernel";
key = " Kernel";
keyColor = "blue";
}
{
type = "wm";
key = " WM";
keyColor = "blue";
}
{
type = "de";
key = " DE";
keyColor = "blue";
}
{
type = "terminal";
key = " Terminal";
keyColor = "blue";
}
{
type = "packages";
key = "󰏖 Packages";
keyColor = "blue";
}
{
type = "wmtheme";
key = "󰉼 WM Theme";
keyColor = "blue";
}
{
type = "terminalfont";
key = " Font";
keyColor = "blue";
}
"break"
# Uptime / Age Section
{
type = "custom";
format = "${esc}[35m Uptime / Age${esc}[0m";
}
{
type = "command";
key = "󱦟 OS Age";
keyColor = "magenta";
# macOS compatible stat command
text = ''if [ $(uname) = 'Darwin' ]; then birth=$(stat -f %B /); else birth=$(stat -c %W /); fi; current=$(date +%s); days=$(( (current - birth) / 86400 )); echo "$days days"'';
}
{
type = "uptime";
key = "󱫐 Uptime";
keyColor = "magenta";
}
"break"
];
};
display = {
separator = " ";
key = { width = 16; };
};
modules = [
"break"
# Hardware Section
{
type = "custom";
format =
"${esc}[32m Hardware${esc}[0m";
}
{
type = "host";
key = " PC";
keyColor = "green";
}
{
type = "cpu";
key = " CPU";
showPeCoreCount = true;
keyColor = "green";
}
{
type = "gpu";
key = " GPU";
detectionMethod = "pci";
keyColor = "green";
}
{
type = "display";
key = "󱄄 Display";
keyColor = "green";
}
{
type = "disk";
key = "󰋊 Disk";
keyColor = "green";
}
{
type = "memory";
key = " Memory";
keyColor = "green";
}
{
type = "swap";
key = "󰓡 Swap";
keyColor = "green";
}
"break"
# Software Section
{
type = "custom";
format =
"${esc}[34m Software${esc}[0m";
}
{
type = "command";
key = "${osIcon} OS";
keyColor = "blue";
text =
"if [ $(uname) = 'Darwin' ]; then ver=$(sw_vers -productVersion); major=$(echo $ver | cut -d. -f1); case $major in 15) name='Sequoia';; 14) name='Sonoma';; 13) name='Ventura';; 12) name='Monterey';; 11) name='Big Sur';; *) name=''';; esac; echo \"macOS $name $major\"; else echo \"$(cat /etc/os-release | grep PRETTY_NAME | cut -d'\\\"' -f2)\"; fi";
}
{
type = "kernel";
key = " Kernel";
keyColor = "blue";
}
{
type = "wm";
key = " WM";
keyColor = "blue";
}
{
type = "de";
key = " DE";
keyColor = "blue";
}
{
type = "terminal";
key = " Terminal";
keyColor = "blue";
}
{
type = "packages";
key = "󰏖 Packages";
keyColor = "blue";
}
{
type = "wmtheme";
key = "󰉼 WM Theme";
keyColor = "blue";
}
{
type = "terminalfont";
key = " Font";
keyColor = "blue";
}
"break"
# Uptime / Age Section
{
type = "custom";
format =
"${esc}[35m Uptime / Age${esc}[0m";
}
{
type = "command";
key = "󱦟 OS Age";
keyColor = "magenta";
# macOS compatible stat command
text = ''
if [ $(uname) = 'Darwin' ]; then birth=$(stat -f %B /); else birth=$(stat -c %W /); fi; current=$(date +%s); days=$(( (current - birth) / 86400 )); echo "$days days"'';
}
{
type = "uptime";
key = "󱫐 Uptime";
keyColor = "magenta";
}
"break"
];
};
}

View file

@ -1,4 +1,5 @@
{ pkgs, lib, ... }: {
{ pkgs, lib, ... }:
{
programs.helix = {
enable = lib.mkDefault true;
settings = {
@ -18,10 +19,12 @@
};
};
};
languages.language = [{
name = "nix";
auto-format = true;
formatter.command = "${pkgs.nixfmt-classic}/bin/nixfmt";
}];
languages.language = [
{
name = "nix";
auto-format = true;
formatter.command = "${pkgs.nixfmt}/bin/nixfmt";
}
];
};
}

View file

@ -1,4 +1,5 @@
{ pkgs, config, ... }: {
{ pkgs, config, ... }:
{
programs.neovim = {
enable = true;
viAlias = true;
@ -27,7 +28,7 @@
# Formatters
stylua # Lua
nixfmt-classic # Nix (matches your fmt command)
nixfmt # Nix
ruff # Python (formatter + linter)
prettierd # JS/TS/JSON/YAML/Markdown
rustfmt # Rust
@ -61,15 +62,14 @@
};
# Copy lazy-lock.json as writable (not symlinked to read-only Nix store)
home.activation.makeNvimLockWritable =
config.lib.dag.entryAfter [ "linkGeneration" ] ''
lockFile="${config.xdg.configHome}/nvim/lazy-lock.json"
sourceLock="${./nvim/lazy-lock.json}"
home.activation.makeNvimLockWritable = config.lib.dag.entryAfter [ "linkGeneration" ] ''
lockFile="${config.xdg.configHome}/nvim/lazy-lock.json"
sourceLock="${./nvim/lazy-lock.json}"
if [ -L "$lockFile" ]; then
rm "$lockFile"
cp "$sourceLock" "$lockFile"
chmod 644 "$lockFile"
fi
'';
if [ -L "$lockFile" ]; then
rm "$lockFile"
cp "$sourceLock" "$lockFile"
chmod 644 "$lockFile"
fi
'';
}

View file

@ -1,24 +1,43 @@
{ config, lib, inputs, ... }:
{
config,
lib,
inputs,
...
}:
let
inherit (lib) mkEnableOption mkOption mkIf types;
inherit (lib)
mkEnableOption
mkOption
mkIf
types
;
cfg = config.rsydn.secrets;
sanitizeSecret = name: secret:
sanitizeSecret =
name: secret:
let
sopsFile = secret.sopsFile or cfg.defaultSopsFile;
extra =
lib.filterAttrs (k: _: !(builtins.elem k [ "path" "mode" "sopsFile" ]))
secret;
in {
extra = lib.filterAttrs (
k: _:
!(builtins.elem k [
"path"
"mode"
"sopsFile"
])
) secret;
in
{
path = secret.path or "${config.xdg.configHome}/secrets/${name}";
mode = secret.mode or "0400";
} // (lib.optionalAttrs (sopsFile != null) { inherit sopsFile; }) // extra;
in {
}
// (lib.optionalAttrs (sopsFile != null) { inherit sopsFile; })
// extra;
in
{
imports = [ inputs.sops-nix.homeManagerModules.sops ];
options.rsydn.secrets = {
enable =
mkEnableOption "sops-nix integration for managing decrypted secrets";
enable = mkEnableOption "sops-nix integration for managing decrypted secrets";
ageKeyFile = mkOption {
type = types.str;
@ -29,15 +48,13 @@ in {
defaultSopsFile = mkOption {
type = types.nullOr types.path;
default = null;
description =
"Optional default SOPS file used when a secret definition omits `sopsFile`.";
description = "Optional default SOPS file used when a secret definition omits `sopsFile`.";
};
secrets = mkOption {
type = types.attrsOf types.attrs;
default = { };
description =
"Secret entries forwarded to `sops.secrets` with sensible defaults.";
description = "Secret entries forwarded to `sops.secrets` with sensible defaults.";
example = lib.literalExpression ''
{
"api-key" = {
@ -58,14 +75,14 @@ in {
};
secrets = lib.mapAttrs sanitizeSecret cfg.secrets;
} // (lib.optionalAttrs (cfg.defaultSopsFile != null) {
}
// (lib.optionalAttrs (cfg.defaultSopsFile != null) {
defaultSopsFile = cfg.defaultSopsFile;
});
home.activation.ensureSecretDir =
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
mkdir -p "${config.xdg.configHome}/secrets"
chmod 700 "${config.xdg.configHome}/secrets"
'';
home.activation.ensureSecretDir = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
mkdir -p "${config.xdg.configHome}/secrets"
chmod 700 "${config.xdg.configHome}/secrets"
'';
};
}

View file

@ -1,4 +1,10 @@
{ config, pkgs, lib, ... }: {
{
config,
pkgs,
lib,
...
}:
{
programs.fish = {
enable = true;
interactiveShellInit = ''

View file

@ -1,31 +1,40 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
profileBin = "${config.home.profileDirectory}/bin";
# System binaries path - same on both NixOS and Darwin
systemBin = "/run/current-system/sw/bin";
defaultBin = "/nix/var/nix/profiles/default/bin";
darwinHomebrewDir = if pkgs.stdenv.hostPlatform.isAarch64 then
"/opt/homebrew"
else
"/usr/local";
darwinHomebrewDir = if pkgs.stdenv.hostPlatform.isAarch64 then "/opt/homebrew" else "/usr/local";
homebrewBin = "${darwinHomebrewDir}/bin";
homebrewSbin = "${darwinHomebrewDir}/sbin";
homebrewPaths = if pkgs.stdenv.hostPlatform.isDarwin then
lib.unique [ homebrewBin homebrewSbin ]
else
[ ];
homebrewPaths =
if pkgs.stdenv.hostPlatform.isDarwin then
lib.unique [
homebrewBin
homebrewSbin
]
else
[ ];
# Add common macOS system paths that may contain user-installed CLIs
macosSystemPaths = if pkgs.stdenv.hostPlatform.isDarwin then [
"/usr/local/bin"
"/usr/bin"
"/bin"
"/usr/sbin"
"/sbin"
] else
[ ];
formatPathList = paths:
lib.concatMapStrings (path: " \"${path}\"\n") paths;
in {
macosSystemPaths =
if pkgs.stdenv.hostPlatform.isDarwin then
[
"/usr/local/bin"
"/usr/bin"
"/bin"
"/usr/sbin"
"/sbin"
]
else
[ ];
formatPathList = paths: lib.concatMapStrings (path: " \"${path}\"\n") paths;
in
{
imports = [ ./starship ];
programs.nushell.enable = lib.mkDefault true;
@ -141,7 +150,13 @@ in {
$env.XDG_CACHE_HOME = "${config.xdg.cacheHome}"
let nix_paths = [
${formatPathList [ profileBin systemBin defaultBin ]} ]
${
formatPathList [
profileBin
systemBin
defaultBin
]
} ]
let homebrew_paths = [
${formatPathList homebrewPaths} ]

View file

@ -1,4 +1,5 @@
{ lib, ... }: {
{ lib, ... }:
{
programs.starship = {
enable = lib.mkDefault true;
enableFishIntegration = true;

View file

@ -1,4 +1,10 @@
{ config, lib, pkgs, ... }: {
{
config,
lib,
pkgs,
...
}:
{
programs.tmux = {
enable = lib.mkDefault true;
clock24 = true;
@ -8,7 +14,7 @@
prefix = "C-a";
escapeTime = 0;
aggressiveResize = true;
plugins = [{ plugin = pkgs.tmuxPlugins.gruvbox; }];
plugins = [ { plugin = pkgs.tmuxPlugins.gruvbox; } ];
extraConfig = ''
# Terminal configuration for proper colors and features
set-option -g default-terminal "screen-256color"