Formatting with nixfmt-rfc-style and setup nixd language server

This commit is contained in:
Daniel Flanagan 2025-02-14 13:20:17 -06:00
parent 7915f78ee3
commit 8e8a483e97
7 changed files with 1903 additions and 1796 deletions

9
.helix/languages.toml Normal file
View file

@ -0,0 +1,9 @@
[[language]]
auto-format = true
file-types = ["nix"]
name = "nix"
scope = "source.nix"
[language.formatter]
args = ["-"]
command = "nixfmt"

View file

@ -1,9 +1,12 @@
{ {
outputs = inputs: let outputs =
inputs:
let
lib = import ./lib inputs; lib = import ./lib inputs;
uGenPkgs = lib.genPkgs inputs.nixpkgs-unstable;
in in
{ {
packages = lib.genPkgs inputs.nixpkgs-unstable (import ./packages); packages = uGenPkgs (import ./packages);
nixosConfigurations = import ./packages/hosts inputs; nixosConfigurations = import ./packages/hosts inputs;
# homeConfigurations = import ./packages/users; # homeConfigurations = import ./packages/users;
@ -11,15 +14,15 @@
templates = import ./lib/templates; templates = import ./lib/templates;
diskoConfigurations = import ./lib/disko inputs; diskoConfigurations = import ./lib/disko inputs;
checks = import ./packages/checks; checks = uGenPkgs (import ./packages/checks inputs);
devShells = import ./packages/shells; devShells = uGenPkgs (import ./packages/shells inputs);
nixosModules = import ./lib/modules/nixos inputs; nixosModules = import ./lib/modules/nixos inputs;
homeManagerModules = import ./lib/modules/home inputs; homeManagerModules = import ./lib/modules/home inputs;
# overlays = import ./lib/overlays inputs; # overlays = import ./lib/overlays inputs;
formatter = lib.genPkgs inputs.nixpkgs-unstable (p: p.nixfmt-rfc-style); formatter = uGenPkgs (p: p.nixfmt-rfc-style);
/* /*
TODO: nix-on-droid for phone terminal usage? mobile-nixos? TODO: nix-on-droid for phone terminal usage? mobile-nixos?
@ -27,7 +30,10 @@
TODO: nixos ISO? TODO: nixos ISO?
*/ */
} }
// (import ./nix/constants.nix inputs); // (import ./nix/constants.nix inputs)
// {
flakeLib = lib;
};
inputs = { inputs = {
# stable inputs # stable inputs
@ -75,7 +81,10 @@
}; };
nixConfig = { nixConfig = {
extra-experimental-features = ["nix-command" "flakes"]; extra-experimental-features = [
"nix-command"
"flakes"
];
extra-substituters = [ extra-substituters = [
"https://cache.nixos.org/" "https://cache.nixos.org/"

View file

@ -1,8 +1,10 @@
{self, ...}: let { self, ... }:
let
inherit (self) outputs; inherit (self) outputs;
inherit (outputs) homeManagerModules constants; inherit (outputs) homeManagerModules constants;
inherit (constants) style; inherit (constants) style;
in { in
{
bat = { bat = {
programs.bat = { programs.bat = {
enable = true; enable = true;
@ -28,19 +30,24 @@ in {
}; };
}; };
eww = {config, ...}: { eww =
{ config, ... }:
{
# programs.eww = { # programs.eww = {
# enable = true; # enable = true;
# }; # };
home.file.".config/eww".source = config.lib.file.mkOutOfStoreSymlink /etc/nixos/flake/modules/home-manager/eww; home.file.".config/eww".source =
config.lib.file.mkOutOfStoreSymlink /etc/nixos/flake/modules/home-manager/eww;
}; };
mako = { mako =
{
config, config,
pkgs, pkgs,
... ...
}: { }:
{
services.mako = { services.mako = {
enable = true; enable = true;
extraConfig = with style.colors.withHashPrefix; '' extraConfig = with style.colors.withHashPrefix; ''
@ -73,11 +80,13 @@ in {
}; };
}; };
tofi = { tofi =
{
config, config,
pkgs, pkgs,
... ...
}: { }:
{
programs.tofi = { programs.tofi = {
enable = true; enable = true;
settings = { settings = {
@ -100,14 +109,18 @@ in {
broot = { }; broot = { };
emacs = {pkgs, ...}: { emacs =
{ pkgs, ... }:
{
programs.emacs = { programs.emacs = {
enable = false; enable = false;
/* /*
extraConfig = '' extraConfig = ''
''; '';
*/ */
extraPackages = epkgs: (with epkgs; [ extraPackages =
epkgs:
(with epkgs; [
magit magit
]); ]);
}; };
@ -119,7 +132,9 @@ in {
}; };
}; };
cargo = {config, ...}: { cargo =
{ config, ... }:
{
home.file."${config.home.homeDirectory}/.cargo/config.toml" = { home.file."${config.home.homeDirectory}/.cargo/config.toml" = {
enable = true; enable = true;
text = '' text = ''
@ -135,12 +150,14 @@ in {
*/ */
}; };
common = { common =
{
pkgs, pkgs,
lib, lib,
config, config,
... ...
}: { }:
{
imports = with homeManagerModules; [ imports = with homeManagerModules; [
# nix-colors.homeManagerModules.default # nix-colors.homeManagerModules.default
fish fish
@ -179,7 +196,6 @@ in {
packages = with pkgs; [ packages = with pkgs; [
# tools I use when editing nix code # tools I use when editing nix code
# kanidm # kanidm
nil
alejandra alejandra
gnupg gnupg
(pkgs.buildEnv { (pkgs.buildEnv {
@ -198,7 +214,11 @@ in {
# https://github.com/lotabout/skim/issues/494 # https://github.com/lotabout/skim/issues/494
enable = false; enable = false;
enableFishIntegration = true; enableFishIntegration = true;
defaultOptions = ["--no-clear-start" "--color=16" "--height=20"]; defaultOptions = [
"--no-clear-start"
"--color=16"
"--height=20"
];
}; };
programs.atuin = { programs.atuin = {
@ -260,7 +280,9 @@ in {
# ewwbar = {}; # ewwbar = {};
firefox = {pkgs, ...}: { firefox =
{ pkgs, ... }:
{
programs.firefox = { programs.firefox = {
/* /*
TODO: this should be able to work on macos, no? TODO: this should be able to work on macos, no?
@ -325,7 +347,9 @@ in {
}; };
}; };
fish = {pkgs, ...}: { fish =
{ pkgs, ... }:
{
home = { home = {
packages = [ packages = [
pkgs.gawk # used in prompt pkgs.gawk # used in prompt
@ -416,7 +440,9 @@ in {
}; };
}; };
jujutsu = {...}: { jujutsu =
{ ... }:
{
programs.jujutsu = { programs.jujutsu = {
enable = true; enable = true;
settings = { settings = {
@ -428,9 +454,12 @@ in {
}; };
}; };
git = {lib, ...}: let git =
{ lib, ... }:
let
email = lib.mkDefault "daniel@lyte.dev"; email = lib.mkDefault "daniel@lyte.dev";
in { in
{
programs.git = { programs.git = {
enable = true; enable = true;
@ -548,7 +577,9 @@ in {
}; };
}; };
gnome = {pkgs, ...}: { gnome =
{ pkgs, ... }:
{
dconf = { dconf = {
enable = true; enable = true;
settings = { settings = {
@ -625,11 +656,13 @@ in {
}; };
}; };
helix = { helix =
{
config, config,
pkgs, pkgs,
... ...
}: { }:
{
# helix rust debugger stuff # helix rust debugger stuff
# https://github.com/helix-editor/helix/wiki/Debugger-Configurations # https://github.com/helix-editor/helix/wiki/Debugger-Configurations
home.file."${config.xdg.configHome}/lldb_vscode_rustc_primer.py" = { home.file."${config.xdg.configHome}/lldb_vscode_rustc_primer.py" = {
@ -834,7 +867,10 @@ in {
soft-wrap.enable = true; soft-wrap.enable = true;
auto-pairs = false; auto-pairs = false;
bufferline = "multiple"; bufferline = "multiple";
rulers = [81 121]; rulers = [
81
121
];
cursorline = true; cursorline = true;
/* /*
@ -993,9 +1029,15 @@ in {
"markup.heading.5" = red; "markup.heading.5" = red;
"markup.heading.6" = fg3; "markup.heading.6" = fg3;
"markup.list" = purple; "markup.list" = purple;
"markup.bold" = {modifiers = ["bold"];}; "markup.bold" = {
"markup.italic" = {modifiers = ["italic"];}; modifiers = [ "bold" ];
"markup.strikethrough" = {modifiers = ["crossed_out"];}; };
"markup.italic" = {
modifiers = [ "italic" ];
};
"markup.strikethrough" = {
modifiers = [ "crossed_out" ];
};
"markup.link.url" = { "markup.link.url" = {
fg = red; fg = red;
modifiers = [ "underlined" ]; modifiers = [ "underlined" ];
@ -1007,8 +1049,12 @@ in {
"diff.minus" = red; "diff.minus" = red;
"diff.delta" = blue; "diff.delta" = blue;
"ui.linenr" = {fg = fgdim;}; "ui.linenr" = {
"ui.linenr.selected" = {fg = fg2;}; fg = fgdim;
};
"ui.linenr.selected" = {
fg = fg2;
};
"ui.statusline" = { "ui.statusline" = {
fg = fgdim; fg = fgdim;
@ -1038,7 +1084,9 @@ in {
fg = text; fg = text;
bg = bg2; bg = bg2;
}; };
"ui.window" = {fg = fgdim;}; "ui.window" = {
fg = fgdim;
};
"ui.help" = { "ui.help" = {
fg = fg2; fg = fg2;
bg = bg2; bg = bg2;
@ -1048,7 +1096,9 @@ in {
fg = fgdim; fg = fgdim;
bg = bg2; bg = bg2;
}; };
"ui.bufferline.background" = {bg = bg2;}; "ui.bufferline.background" = {
bg = bg2;
};
"ui.text" = text; "ui.text" = text;
"ui.text.focus" = { "ui.text.focus" = {
@ -1056,17 +1106,23 @@ in {
bg = bg3; bg = bg3;
modifiers = [ "bold" ]; modifiers = [ "bold" ];
}; };
"ui.text.inactive" = {fg = fg2;}; "ui.text.inactive" = {
fg = fg2;
};
"ui.virtual" = fg2; "ui.virtual" = fg2;
"ui.virtual.ruler" = {bg = bg3;}; "ui.virtual.ruler" = {
bg = bg3;
};
"ui.virtual.indent-guide" = bg3; "ui.virtual.indent-guide" = bg3;
"ui.virtual.inlay-hint" = { "ui.virtual.inlay-hint" = {
fg = bg3; fg = bg3;
bg = bg; bg = bg;
}; };
"ui.selection" = {bg = bg5;}; "ui.selection" = {
bg = bg5;
};
"ui.cursor" = { "ui.cursor" = {
fg = bg; fg = bg;
@ -1107,7 +1163,9 @@ in {
bg = fg; bg = fg;
}; };
"ui.cursorline.primary" = {bg = bg3;}; "ui.cursorline.primary" = {
bg = bg3;
};
"ui.highlight" = { "ui.highlight" = {
bg = bg3; bg = bg3;
@ -1163,8 +1221,12 @@ in {
"ui.cursorline.primary" = { bg = "default" } "ui.cursorline.primary" = { bg = "default" }
"ui.cursorline.secondary" = { bg = "default" } "ui.cursorline.secondary" = { bg = "default" }
*/ */
"ui.cursorcolumn.primary" = {bg = bg3;}; "ui.cursorcolumn.primary" = {
"ui.cursorcolumn.secondary" = {bg = bg3;}; bg = bg3;
};
"ui.cursorcolumn.secondary" = {
bg = bg3;
};
"ui.bufferline.active" = { "ui.bufferline.active" = {
fg = primary; fg = primary;
@ -1269,11 +1331,13 @@ in {
]; ];
}; };
niri = { niri =
{
pkgs, pkgs,
config, config,
... ...
}: { }:
{
home.packages = with pkgs; [ home.packages = with pkgs; [
niri niri
fuzzel fuzzel
@ -1342,7 +1406,9 @@ in {
# kitty = {}; # kitty = {};
linux = {pkgs, ...}: { linux =
{ pkgs, ... }:
{
home = { home = {
sessionVariables = { sessionVariables = {
MOZ_ENABLE_WAYLAND = "1"; MOZ_ENABLE_WAYLAND = "1";
@ -1377,11 +1443,13 @@ in {
]; ];
}; };
linux-desktop-environment-config = { linux-desktop-environment-config =
{
pkgs, pkgs,
# font, # font,
... ...
}: { }:
{
imports = with homeManagerModules; [ imports = with homeManagerModules; [
linux linux
desktop desktop
@ -1401,8 +1469,7 @@ in {
}; };
postUnpack = ""; postUnpack = "";
}) }).override
.override
{ {
accents = [ "sapphire" ]; accents = [ "sapphire" ];
variant = "mocha"; variant = "mocha";
@ -1428,7 +1495,9 @@ in {
# nnn = {}; # nnn = {};
password-manager = {pkgs, ...}: { password-manager =
{ pkgs, ... }:
{
imports = with homeManagerModules; [ imports = with homeManagerModules; [
pass pass
]; ];
@ -1443,20 +1512,27 @@ in {
]; ];
}; };
pass = {pkgs, ...}: { pass =
{ pkgs, ... }:
{
programs.password-store = { programs.password-store = {
enable = true; enable = true;
package = pkgs.pass.withExtensions (exts: [ exts.pass-otp ]); package = pkgs.pass.withExtensions (exts: [ exts.pass-otp ]);
}; };
}; };
senpai = {config, ...}: { senpai =
{ config, ... }:
{
programs.senpai = { programs.senpai = {
enable = true; enable = true;
config = { config = {
address = "irc+insecure://beefcake.hare-cod.ts.net:6667"; address = "irc+insecure://beefcake.hare-cod.ts.net:6667";
nickname = "lytedev"; nickname = "lytedev";
password-cmd = ["pass" "soju"]; password-cmd = [
"pass"
"soju"
];
}; };
}; };
@ -1491,11 +1567,13 @@ in {
waybar = {}; waybar = {};
*/ */
wezterm = { wezterm =
{
pkgs, pkgs,
config, config,
... ...
}: { }:
{
home.packages = with pkgs; [ home.packages = with pkgs; [
wezterm wezterm
]; ];
@ -1505,11 +1583,13 @@ in {
}; };
}; };
ghostty = { ghostty =
{
pkgs, pkgs,
config, config,
... ...
}: { }:
{
home.packages = with pkgs; [ home.packages = with pkgs; [
ghostty ghostty
]; ];
@ -1519,7 +1599,9 @@ in {
}; };
}; };
zellij = {lib, ...}: { zellij =
{ lib, ... }:
{
# zellij does not support modern terminal keyboard input: # zellij does not support modern terminal keyboard input:
# https://github.com/zellij-org/zellij/issues/735 # https://github.com/zellij-org/zellij/issues/735
programs.zellij = { programs.zellij = {

View file

@ -6,4 +6,4 @@ scope = "source.nix"
[language.formatter] [language.formatter]
args = ["-"] args = ["-"]
command = "alejandra" command = "nixfmt"

View file

@ -4,31 +4,42 @@
inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
inputs.pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs"; inputs.pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
outputs = { outputs =
{
self, self,
nixpkgs, nixpkgs,
pre-commit-hooks, pre-commit-hooks,
... ...
}: let }:
systems = ["aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-linux"]; let
systems = [
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
"x86_64-linux"
];
forSystems = nixpkgs.lib.genAttrs systems; forSystems = nixpkgs.lib.genAttrs systems;
pkgsFor = system: (import nixpkgs { inherit system; }); pkgsFor = system: (import nixpkgs { inherit system; });
genPkgs = func: (forSystems (system: func (pkgsFor system))); genPkgs = func: (forSystems (system: func (pkgsFor system)));
in { in
formatter = genPkgs (pkgs: pkgs.alejandra); {
formatter = genPkgs (pkgs: pkgs.nixfmt-rfc-style);
checks = genPkgs (pkgs: { checks = genPkgs (pkgs: {
pre-commit-check = pre-commit-hooks.lib.${pkgs.system}.run { pre-commit-check = pre-commit-hooks.lib.${pkgs.system}.run {
src = ./.; src = ./.;
hooks = { hooks = {
alejandra.enable = true; nixfmt-rfc-style.enable = true;
}; };
}; };
}); });
devShells = genPkgs (pkgs: { devShells = genPkgs (pkgs: {
nix = pkgs.mkShell { nix = pkgs.mkShell {
packages = with pkgs; [nil alejandra]; packages = with pkgs; [
nixd
nixfmt-rfc-style
];
inherit (self.outputs.checks.${pkgs.system}.pre-commit-check) shellHook; inherit (self.outputs.checks.${pkgs.system}.pre-commit-check) shellHook;
}; };

View file

@ -1,12 +1,10 @@
{ git-hooks, ... }:
{ pkgs, ... }:
{ {
pkgs,
git-hooks,
...
}: {
git-hooks = git-hooks.lib.${pkgs.system}.run { git-hooks = git-hooks.lib.${pkgs.system}.run {
src = ./.; src = ./.;
hooks = { hooks = {
alejandra.enable = true; nixfmt-rfc-style.enable = true;
}; };
}; };
} }

View file

@ -1,8 +1,6 @@
{ self, ... }:
{ pkgs, ... }:
{ {
self,
pkgs,
...
}: {
default = pkgs.mkShell { default = pkgs.mkShell {
inherit (self.outputs.checks.${pkgs.system}.git-hooks) shellHook; inherit (self.outputs.checks.${pkgs.system}.git-hooks) shellHook;
packages = with pkgs; [ packages = with pkgs; [