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
lib = import ./lib inputs;
in
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,23 +14,26 @@
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?
TODO: nix-darwin for work?
TODO: nixos ISO?
TODO: nix-on-droid for phone terminal usage? mobile-nixos?
TODO: nix-darwin for work?
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/"

File diff suppressed because it is too large Load diff

View file

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

View file

@ -4,45 +4,56 @@
inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
inputs.pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
outputs = {
self,
nixpkgs,
pre-commit-hooks,
...
}: 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);
outputs =
{
self,
nixpkgs,
pre-commit-hooks,
...
}:
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.nixfmt-rfc-style);
checks = genPkgs (pkgs: {
pre-commit-check = pre-commit-hooks.lib.${pkgs.system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
checks = genPkgs (pkgs: {
pre-commit-check = pre-commit-hooks.lib.${pkgs.system}.run {
src = ./.;
hooks = {
nixfmt-rfc-style.enable = true;
};
};
};
});
});
devShells = genPkgs (pkgs: {
nix = pkgs.mkShell {
packages = with pkgs; [nil alejandra];
inherit (self.outputs.checks.${pkgs.system}.pre-commit-check) shellHook;
};
devShells = genPkgs (pkgs: {
nix = pkgs.mkShell {
packages = with pkgs; [
nixd
nixfmt-rfc-style
];
inherit (self.outputs.checks.${pkgs.system}.pre-commit-check) shellHook;
};
default = self.outputs.devShells.${pkgs.system}.nix;
});
default = self.outputs.devShells.${pkgs.system}.nix;
});
/*
packages = genPkgs (pkgs: import ./pkgs {inherit pkgs;});
overlays = import ./overlays self;
nixosModules = import ./modules/nixos;
homeManagerModules = import ./modules/home-manager;
nixosConfigurations = import ./nixos;
homeConfigurations = import ./home
templates = import ./templates;
*/
};
/*
packages = genPkgs (pkgs: import ./pkgs {inherit pkgs;});
overlays = import ./overlays self;
nixosModules = import ./modules/nixos;
homeManagerModules = import ./modules/home-manager;
nixosConfigurations = import ./nixos;
homeConfigurations = import ./home
templates = import ./templates;
*/
};
}

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; [