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;
uGenPkgs = lib.genPkgs inputs.nixpkgs-unstable;
in
{
packages = lib.genPkgs inputs.nixpkgs-unstable (import ./packages);
packages = uGenPkgs (import ./packages);
nixosConfigurations = import ./packages/hosts inputs;
# homeConfigurations = import ./packages/users;
@ -11,15 +14,15 @@
templates = import ./lib/templates;
diskoConfigurations = import ./lib/disko inputs;
checks = import ./packages/checks;
devShells = import ./packages/shells;
checks = uGenPkgs (import ./packages/checks inputs);
devShells = uGenPkgs (import ./packages/shells inputs);
nixosModules = import ./lib/modules/nixos inputs;
homeManagerModules = import ./lib/modules/home 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?
@ -27,7 +30,10 @@
TODO: nixos ISO?
*/
}
// (import ./nix/constants.nix inputs);
// (import ./nix/constants.nix inputs)
// {
flakeLib = lib;
};
inputs = {
# stable inputs
@ -75,7 +81,10 @@
};
nixConfig = {
extra-experimental-features = ["nix-command" "flakes"];
extra-experimental-features = [
"nix-command"
"flakes"
];
extra-substituters = [
"https://cache.nixos.org/"

View file

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

View file

@ -6,4 +6,4 @@ scope = "source.nix"
[language.formatter]
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.inputs.nixpkgs.follows = "nixpkgs";
outputs = {
outputs =
{
self,
nixpkgs,
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;
pkgsFor = system: (import nixpkgs { inherit system; });
genPkgs = func: (forSystems (system: func (pkgsFor system)));
in {
formatter = genPkgs (pkgs: pkgs.alejandra);
in
{
formatter = genPkgs (pkgs: pkgs.nixfmt-rfc-style);
checks = genPkgs (pkgs: {
pre-commit-check = pre-commit-hooks.lib.${pkgs.system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
nixfmt-rfc-style.enable = true;
};
};
});
devShells = genPkgs (pkgs: {
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;
};

View file

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

View file

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