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 = {
@ -98,16 +107,20 @@ in {
};
};
broot = {};
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,12 +196,11 @@ in {
packages = with pkgs; [
# tools I use when editing nix code
# kanidm
nil
alejandra
gnupg
(pkgs.buildEnv {
name = "my-common-scripts";
paths = [./scripts/common];
paths = [ ./scripts/common ];
})
];
};
@ -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
@ -376,7 +400,7 @@ in {
has_command = "command --quiet --search $argv[1]";
};
shellAbbrs = {};
shellAbbrs = { };
shellAliases = {
# TODO: an alias that wraps `rm` such that if we run it without git committing first (when in a git repo)
ls = "eza --group-directories-first --classify";
@ -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;
@ -439,7 +468,7 @@ in {
delta = {
enable = true;
options = {};
options = { };
};
lfs = {
@ -548,13 +577,15 @@ in {
};
};
gnome = {pkgs, ...}: {
gnome =
{ pkgs, ... }:
{
dconf = {
enable = true;
settings = {
"org/gnome/settings-daemon/plugins/media-keys" = {
screensaver = ["<Shift><Control><Super>l"]; # lock screen
mic-mute = ["<Shift><Super>v"];
screensaver = [ "<Shift><Control><Super>l" ]; # lock screen
mic-mute = [ "<Shift><Super>v" ];
};
"org/gnome/desktop/peripherals/keyboard" = {
@ -567,12 +598,12 @@ in {
# mouse-button-modifier = '<Super>'; # default
};
"org/gnome/desktop/wm/keybindings" = {
minimize = ["<Shift><Control><Super>h"];
show-desktop = ["<Super>d"];
move-to-workspace-left = ["<Super><Shift>h"];
move-to-workspace-right = ["<Super><Shift>l"];
switch-to-workspace-left = ["<Super><Control>h"];
switch-to-workspace-right = ["<Super><Control>l"];
minimize = [ "<Shift><Control><Super>h" ];
show-desktop = [ "<Super>d" ];
move-to-workspace-left = [ "<Super><Shift>h" ];
move-to-workspace-right = [ "<Super><Shift>l" ];
switch-to-workspace-left = [ "<Super><Control>h" ];
switch-to-workspace-right = [ "<Super><Control>l" ];
# mouse-button-modifier = '<Super>'; # default
};
"org/gnome/desktop/interface" = {
@ -584,7 +615,7 @@ in {
# scaling-factor = 1.75;
};
"org/gnome/mutter" = {
experimental-features = ["variable-refresh-rate"];
experimental-features = [ "variable-refresh-rate" ];
};
"org/gnome/shell" = {
@ -601,10 +632,10 @@ in {
outer-gaps = 8;
window-border-width = 2;
window-border-color = "rgba(116,199,236,0.47)";
focus-window-right = ["<Super>l"];
focus-window-left = ["<Super>h"];
focus-window-up = ["<Super>k"];
focus-window-down = ["<Super>j"];
focus-window-right = [ "<Super>l" ];
focus-window-left = [ "<Super>h" ];
focus-window-up = [ "<Super>k" ];
focus-window-down = [ "<Super>j" ];
};
};
};
@ -617,19 +648,21 @@ in {
programs.gnome-shell = {
enable = true;
extensions = [{package = pkgs.gnomeExtensions.gsconnect;}];
extensions = [ { package = pkgs.gnomeExtensions.gsconnect; } ];
};
programs.firefox.package = pkgs.firefox.override {
nativeMessagingHosts = with pkgs; [bitwarden];
nativeMessagingHosts = with pkgs; [ bitwarden ];
};
};
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" = {
@ -663,7 +696,7 @@ in {
language-server = {
lexical = {
command = "lexical";
args = ["start"];
args = [ "start" ];
};
/*
@ -724,7 +757,7 @@ in {
];
args = {
program = "{0}";
initCommands = ["command script import ${config.xdg.configHome}/lldb_vscode_rustc_primer.py"];
initCommands = [ "command script import ${config.xdg.configHome}/lldb_vscode_rustc_primer.py" ];
};
}
];
@ -732,23 +765,23 @@ in {
}
{
name = "html";
file-types = ["html"];
file-types = [ "html" ];
scope = "source.html";
auto-format = false;
}
{
name = "nix";
file-types = ["nix"];
file-types = [ "nix" ];
scope = "source.nix";
auto-format = true;
formatter = {
command = "alejandra";
args = ["-"];
args = [ "-" ];
};
}
{
name = "fish";
file-types = ["fish"];
file-types = [ "fish" ];
scope = "source.fish";
auto-format = true;
indent = {
@ -758,7 +791,7 @@ in {
}
{
name = "toml";
file-types = ["toml"];
file-types = [ "toml" ];
scope = "source.toml";
auto-format = true;
}
@ -834,7 +867,10 @@ in {
soft-wrap.enable = true;
auto-pairs = false;
bufferline = "multiple";
rulers = [81 121];
rulers = [
81
121
];
cursorline = true;
/*
@ -944,13 +980,13 @@ in {
"comment" = {
fg = fgdim;
modifiers = ["italic"];
modifiers = [ "italic" ];
};
"variable" = text;
"variable.parameter" = {
fg = red;
modifiers = ["italic"];
modifiers = [ "italic" ];
};
"variable.builtin" = red;
"variable.other.member" = text;
@ -964,7 +1000,7 @@ in {
"keyword.storage.modifier.ref" = yellow;
"keyword.control.conditional" = {
fg = purple;
modifiers = ["italic"];
modifiers = [ "italic" ];
};
"operator" = blue;
@ -977,14 +1013,14 @@ in {
"namespace" = {
fg = blue;
modifiers = ["italic"];
modifiers = [ "italic" ];
};
"special" = blue;
"markup.heading.marker" = {
fg = orange;
modifiers = ["bold"];
modifiers = [ "bold" ];
};
"markup.heading.1" = blue;
"markup.heading.2" = yellow;
@ -993,12 +1029,18 @@ 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"];
modifiers = [ "underlined" ];
};
"markup.link.text" = blue;
"markup.raw" = red;
@ -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;
@ -1021,24 +1067,26 @@ in {
"ui.statusline.normal" = {
fg = bg;
bg = purple;
modifiers = ["bold"];
modifiers = [ "bold" ];
};
"ui.statusline.insert" = {
fg = bg;
bg = green;
modifiers = ["bold"];
modifiers = [ "bold" ];
};
"ui.statusline.select" = {
fg = bg;
bg = red;
modifiers = ["bold"];
modifiers = [ "bold" ];
};
"ui.popup" = {
fg = text;
bg = bg2;
};
"ui.window" = {fg = fgdim;};
"ui.window" = {
fg = fgdim;
};
"ui.help" = {
fg = fg2;
bg = bg2;
@ -1048,25 +1096,33 @@ in {
fg = fgdim;
bg = bg2;
};
"ui.bufferline.background" = {bg = bg2;};
"ui.bufferline.background" = {
bg = bg2;
};
"ui.text" = text;
"ui.text.focus" = {
fg = text;
bg = bg3;
modifiers = ["bold"];
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;
@ -1078,7 +1134,7 @@ in {
};
"ui.cursor.match" = {
fg = orange;
modifiers = ["bold"];
modifiers = [ "bold" ];
};
"ui.cursor.primary.normal" = {
@ -1107,12 +1163,14 @@ in {
bg = fg;
};
"ui.cursorline.primary" = {bg = bg3;};
"ui.cursorline.primary" = {
bg = bg3;
};
"ui.highlight" = {
bg = bg3;
fg = bg;
modifiers = ["bold"];
modifiers = [ "bold" ];
};
"ui.menu" = {
@ -1122,7 +1180,7 @@ in {
"ui.menu.selected" = {
fg = text;
bg = bg3;
modifiers = ["bold"];
modifiers = [ "bold" ];
};
"diagnostic.error" = {
@ -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";
@ -1372,16 +1438,18 @@ in {
home.packages = [
(pkgs.buildEnv {
name = "my-linux-scripts";
paths = [./scripts/linux];
paths = [ ./scripts/linux ];
})
];
};
linux-desktop-environment-config = {
linux-desktop-environment-config =
{
pkgs,
# font,
...
}: {
}:
{
imports = with homeManagerModules; [
linux
desktop
@ -1401,10 +1469,9 @@ in {
};
postUnpack = "";
})
.override
}).override
{
accents = ["sapphire"];
accents = [ "sapphire" ];
variant = "mocha";
size = "compact";
};
@ -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]);
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;});
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; [