1
0
Fork 0

Manage Helix configuration through Nix

This commit is contained in:
Ethan Reece 2025-07-09 19:42:46 -05:00
parent d33867e255
commit 20e042c128
Signed by: me
GPG key ID: 198E9EB433DB1B28
4 changed files with 148 additions and 57 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
.direnv
.helix

View file

@ -1,25 +0,0 @@
# TODO: switch to "%{buffer_name}" when this feature makes it to Helix release
[[language]]
name = "nix"
language-servers = ["nil", "harper-ls"]
formatter = { command = "treefmt", args = ["--stdin", ".nix", "--quiet"] }
auto-format = true
[[language]]
name = "toml"
language-servers = ["taplo", "harper-ls"]
formatter = { command = "treefmt", args = ["--stdin", ".toml", "--quiet"] }
auto-format = true
[[language]]
name = "yaml"
language-servers = ["yaml-language-server", "harper-ls"]
formatter = { command = "treefmt", args = ["--stdin", ".yaml", "--quiet"] }
auto-format = true
[[language]]
name = "markdown"
language-servers = ["marksman", "ltex-ls", "vale-ls"]
formatter = { command = "treefmt", args = ["--stdin", ".md", "--quiet"] }
auto-format = true

165
flake.nix
View file

@ -68,6 +68,101 @@
inputs.nixgl.overlays.default
];
};
treefmt = config.treefmt.build.wrapper;
helixLanguages = {
language = [
{
name = "markdown";
language-servers = [
"marksman"
"ltex-ls-plus"
"vale-ls"
];
formatter = {
command = "${treefmt}/bin/treefmt";
args = [
"--stdin"
".md"
"--quiet"
];
};
auto-format = true;
}
{
name = "nix";
language-servers = [
"nil"
"harper-ls"
];
formatter = {
command = "${treefmt}/bin/treefmt";
args = [
"--stdin"
".nix"
"--quiet"
];
};
auto-format = true;
}
{
name = "toml";
language-servers = [
"taplo"
"harper-ls"
];
formatter = {
command = "${treefmt}/bin/treefmt";
args = [
"--stdin"
".toml"
"--quiet"
];
};
auto-format = true;
}
{
name = "yaml";
language-servers = [
"yaml-language-server"
"harper-ls"
];
formatter = {
command = "${treefmt}/bin/treefmt";
args = [
"--stdin"
".yaml"
"--quiet"
];
};
auto-format = true;
}
];
language-server = {
ltex-ls-plus = {
command = "${pkgs.ltex-ls-plus}/bin/ltex-ls-plus";
};
marksman = {
command = "${pkgs.marksman}/bin/marksman";
};
harper-ls = {
command = "${pkgs.harper}/bin/harper-ls";
};
nil = {
command = "${pkgs.nil}/bin/nil";
};
taplo = {
command = "${pkgs.taplo}/bin/taplo";
};
vale-ls = {
command = "${pkgs.vale-ls}/bin/vale-ls";
};
yaml-language-server = {
command = "${pkgs.yaml-language-server}/bin/yaml-language-server";
};
};
};
helixLanguagesFormat = pkgs.formats.toml { };
helixLanguagesFile = helixLanguagesFormat.generate "languages.toml" helixLanguages;
in
{
_module.args.pkgs = pkgs;
@ -76,53 +171,87 @@
{
help = "`home-manager switch` for asahi";
name = "switch-asahi";
command = "home-manager switch --flake .#asahi";
command = "${pkgs.home-manager}/bin/home-manager switch --flake .#asahi";
package = pkgs.home-manager;
}
{
help = "`home-manager switch` for asahi with backup";
name = "switch-asahi-backup";
command = "home-manager switch --flake .#asahi -b backup";
command = "${pkgs.home-manager}/bin/home-manager switch --flake .#asahi -b backup";
package = pkgs.home-manager;
}
{
help = "update dependencies";
name = "update";
command = "nix flake update";
command = "${pkgs.lix}/bin/nix flake update";
package = pkgs.lix;
}
{
help = "show home-manager documentation";
name = "man-home";
command = "man home-configuration.nix";
command = "${pkgs.man}/bin/man home-configuration.nix";
package = pkgs.man;
}
{
help = "generate Helix grammars";
name = "_helix-grammars";
command = "hx --grammar fetch && hx --grammar build";
command = "${pkgs.helix}/bin/hx --grammar fetch && hx --grammar build";
package = pkgs.helix;
}
{
help = "sync vale configuration";
name = "vale-sync";
command = "vale sync";
command = "${pkgs.vale}/bin/vale sync";
package = pkgs.vale;
}
{
help = "generate age key";
name = "_age-generate-key";
command = "${pkgs.uutils-coreutils-noprefix}/bin/mkdir -p ~/.config/sops/age && ${pkgs.age}/bin/age-keygen -o ~/.config/sops/age/keys.txt && ${pkgs.uutils-coreutils-noprefix}/bin/cat ~/.config/sops/age/keys.txt";
package = pkgs.age;
}
{
help = "edit secrets.yaml";
name = "sops-edit";
command = "${pkgs.sops}/bin/sops edit ./home/secrets/secrets.yaml";
package = pkgs.sops;
}
];
packages = [
config.treefmt.build.wrapper
pkgs.age
# pkgs.age
pkgs.forgejo-cli
pkgs.git
pkgs.harper
# pkgs.harper
pkgs.helix
# pkgs.home-manager
pkgs.jujutsu
pkgs.lix
pkgs.ltex-ls-plus
pkgs.marksman
pkgs.nil
pkgs.sops
pkgs.taplo
pkgs.uutils-coreutils
pkgs.vale
pkgs.vale-ls
pkgs.yaml-language-server
# pkgs.ltex-ls-plus
pkgs.man
# pkgs.marksman
# pkgs.nil
# pkgs.sops
# pkgs.taplo
pkgs.uutils-coreutils-noprefix
# pkgs.vale
# pkgs.vale-ls
# pkgs.yaml-language-server
];
devshell = {
motd = ''
{202}🔨 Nix Laptop Configuration{reset}
$(type -p menu &>/dev/null && menu)
'';
name = "Laptop Configuration";
startup = {
helix_config = {
text = ''
mkdir -p .helix
${pkgs.uutils-coreutils-noprefix}/bin/ln -fs ${helixLanguagesFile} ./.helix/languages.toml
'';
};
};
};
};
pre-commit.settings = {
hooks = {

View file

@ -1,14 +0,0 @@
default:
generate-key:
mkdir -p ~/.config/sops/age
age-keygen -o ~/.config/sops/age/keys.txt
cat ~/.config/sops/age/keys.txt
# use `sops edit` instead
# encrypt:
# sops --encrypt --in-place secrets.yaml
# decrypt:
# sops --decrypt --in-place secrets.yaml