feat: Change nix formatter to alejandra

This commit is contained in:
ulic-youthlic 2025-11-09 06:25:03 +08:00
parent 0b8b647f05
commit b4c3dfec42
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
229 changed files with 2528 additions and 2884 deletions

View file

@ -4,32 +4,28 @@
flake-parts-lib,
self,
...
}:
let
}: let
inherit (self) outputs;
inherit (inputs) deploy-rs;
mkDeployNode =
{
hostName,
unixName ? "deploy",
system ? "x86_64-linux",
sshName ? hostName,
}:
{
"${hostName}" = {
hostname = "${sshName}";
sshUser = "${unixName}";
interactiveSudo = true;
profiles = {
system = {
user = "root";
path = deploy-rs.lib."${system}".activate.nixos outputs.nixosConfigurations."${hostName}";
};
mkDeployNode = {
hostName,
unixName ? "deploy",
system ? "x86_64-linux",
sshName ? hostName,
}: {
"${hostName}" = {
hostname = "${sshName}";
sshUser = "${unixName}";
interactiveSudo = true;
profiles = {
system = {
user = "root";
path = deploy-rs.lib."${system}".activate.nixos outputs.nixosConfigurations."${hostName}";
};
};
};
in
{
};
in {
options = {
flake = flake-parts-lib.mkSubmoduleOptions {
deploy = lib.mkOption {
@ -38,21 +34,20 @@ in
};
};
config = {
flake.deploy.nodes =
with lib;
flake.deploy.nodes = with lib;
pipe
[
"Cape"
"Akun"
]
[
(map (
hostName:
[
"Cape"
"Akun"
]
[
(map (
hostName:
mkDeployNode {
inherit hostName;
}
))
(foldr (a: b: a // b) { })
];
))
(foldr (a: b: a // b) {})
];
};
}

View file

@ -4,44 +4,42 @@
self,
rootPath,
...
}:
let
}: let
inherit (self) outputs;
homeModules =
(
with lib;
pipe (rootPath + "/home") [
builtins.readDir
(filterAttrs (_key: value: value == "directory"))
(filterAttrs (
key: _value:
!builtins.elem key [
"modules"
"extra"
]
))
builtins.attrNames
(flip genAttrs (name: import (rootPath + "/home/${name}/modules")))
]
pipe (rootPath + "/home") [
builtins.readDir
(filterAttrs (_key: value: value == "directory"))
(filterAttrs (
key: _value:
!builtins.elem key [
"modules"
"extra"
]
))
builtins.attrNames
(flip genAttrs (name: import (rootPath + "/home/${name}/modules")))
]
)
// {
default = import "${toString rootPath}/home/modules";
extra = import "${toString rootPath}/home/extra";
};
makeHomeConfiguration =
{
hostName,
unixName ? "david",
system ? "x86_64-linux",
nixpkgs ? inputs.nixpkgs,
home-manager ? inputs.home-manager,
}:
{
"${unixName}@${hostName}" = home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs {
localSystem = { inherit system; };
};
modules = [
makeHomeConfiguration = {
hostName,
unixName ? "david",
system ? "x86_64-linux",
nixpkgs ? inputs.nixpkgs,
home-manager ? inputs.home-manager,
}: {
"${unixName}@${hostName}" = home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs {
localSystem = {inherit system;};
};
modules =
[
(rootPath + "/home/${unixName}/configurations/${hostName}")
]
++ (with homeModules; [
@ -53,32 +51,30 @@ let
]
++ [
{
lib = { inherit (lib) youthlic; };
lib = {inherit (lib) youthlic;};
}
];
extraSpecialArgs = {
inherit
inputs
outputs
unixName
hostName
system
rootPath
;
};
extraSpecialArgs = {
inherit
inputs
outputs
unixName
hostName
system
rootPath
;
};
};
in
{
};
in {
flake = {
homeConfigurations =
with lib;
foldr (a: b: a // b) { } (
homeConfigurations = with lib;
foldr (a: b: a // b) {} (
pipe
[
# Hostname
]
[ (map (hostName: makeHomeConfiguration { inherit hostName; })) ]
[
# Hostname
]
[(map (hostName: makeHomeConfiguration {inherit hostName;}))]
);
inherit homeModules;
};

View file

@ -4,39 +4,35 @@
self,
rootPath,
...
}:
let
}: let
inherit (self) outputs;
in
{
in {
flake = {
nixosModules = {
default = import (rootPath + "/nixos/modules/top-level");
gui = import (rootPath + "/nixos/modules/top-level/gui.nix");
};
nixosConfigurations =
let
makeNixosConfiguration =
hostName:
lib.nixosSystem {
modules = [ (rootPath + "/nixos/configurations/${hostName}") ];
specialArgs = {
inherit
inputs
outputs
rootPath
lib
;
};
nixosConfigurations = let
makeNixosConfiguration = hostName:
lib.nixosSystem {
modules = [(rootPath + "/nixos/configurations/${hostName}")];
specialArgs = {
inherit
inputs
outputs
rootPath
lib
;
};
in
};
in
with lib;
pipe
pipe
[
"Tytonidae"
"Cape"
"Akun"
]
[ (flip genAttrs makeNixosConfiguration) ];
[(flip genAttrs makeNixosConfiguration)];
};
}

View file

@ -4,18 +4,15 @@
lib,
rootPath,
...
}:
let
}: let
inherit (self) outputs;
importWithArgs = lib.flip import { inherit inputs outputs; };
in
{
flake.overlays =
with lib;
importWithArgs = lib.flip import {inherit inputs outputs;};
in {
flake.overlays = with lib;
pipe
[
"modifications"
"additions"
]
[ (flip genAttrs (name: importWithArgs (rootPath + "/overlays/${name}"))) ];
[
"modifications"
"additions"
]
[(flip genAttrs (name: importWithArgs (rootPath + "/overlays/${name}")))];
}

View file

@ -2,93 +2,87 @@
inputs,
rootPath,
...
}:
{
}: {
imports = [
(rootPath + "/treefmt.nix")
];
perSystem =
{
pkgs,
system,
lib,
self',
inputs',
...
}:
let
inherit (inputs) nixpkgs;
in
{
_module.args.pkgs = import nixpkgs {
localSystem = { inherit system; };
config = {
allowUnfree = true;
};
overlays = [ (_final: _prev: { inherit lib; }) ];
perSystem = {
pkgs,
system,
lib,
self',
inputs',
...
}: let
inherit (inputs) nixpkgs;
in {
_module.args.pkgs = import nixpkgs {
localSystem = {inherit system;};
config = {
allowUnfree = true;
};
devShells.default = pkgs.mkShell {
name = "nixos-shell";
packages = with pkgs; [
nixd
nil
typos
typos-lsp
just
nvfetcher
nixfmt-rfc-style
overlays = [(_final: _prev: {inherit lib;})];
};
devShells.default = pkgs.mkShell {
name = "nixos-shell";
packages = with pkgs; [
nixd
nil
typos
typos-lsp
just
nvfetcher
alejandra
lua-language-server
];
};
legacyPackages =
let
inputsScope = lib.makeScope pkgs.newScope (self: {
inherit inputs rootPath;
srcs = self.callPackage (rootPath + "/_sources/generated.nix") { };
inherit (inputs'.nixvim.legacyPackages) makeNixvim makeNixvimWithModule;
neovim_git = inputs'.neovim-nightly.packages.default;
});
in
inputsScope.overrideScope (
final: _prev:
lua-language-server
];
};
legacyPackages = let
inputsScope = lib.makeScope pkgs.newScope (self: {
inherit inputs rootPath;
srcs = self.callPackage (rootPath + "/_sources/generated.nix") {};
inherit (inputs'.nixvim.legacyPackages) makeNixvim makeNixvimWithModule;
neovim_git = inputs'.neovim-nightly.packages.default;
});
in
inputsScope.overrideScope (
final: _prev:
lib.packagesFromDirectoryRecursive {
inherit (final) callPackage;
directory = rootPath + "/pkgs";
}
);
packages =
let
flattenPkgs =
path: value:
if lib.isDerivation value then
{
${lib.concatStringsSep ":" path} = value;
}
else if lib.isAttrs value then
lib.concatMapAttrs (name: flattenPkgs (path ++ [ name ])) value
else
{ };
in
flattenPkgs [ ] (
lib.removeAttrs self'.legacyPackages [
"inputs"
);
packages = let
flattenPkgs = path: value:
if lib.isDerivation value
then {
${lib.concatStringsSep ":" path} = value;
}
else if lib.isAttrs value
then lib.concatMapAttrs (name: flattenPkgs (path ++ [name])) value
else {};
in
flattenPkgs [] (
lib.removeAttrs self'.legacyPackages [
"inputs"
"srcs"
"srcs"
"rootPath"
"rootPath"
"makeNixvim"
"makeNixvimWithModule"
"makeNixvim"
"makeNixvimWithModule"
"newScope"
"overrideScope"
"packages"
"callPackage"
]
);
checks = lib.concatMapAttrs (name: value: {
"newScope"
"overrideScope"
"packages"
"callPackage"
]
);
checks =
lib.concatMapAttrs (name: value: {
"package-${name}" = value;
}) self'.packages;
};
})
self'.packages;
};
}

View file

@ -3,8 +3,7 @@
lib,
rootPath,
...
}:
{
}: {
options = {
flake = flake-parts-lib.mkSubmoduleOptions {
templates = lib.mkOption {