switch nixfmt to alejandra to format nix code

This commit is contained in:
ulic-youthlic 2025-04-28 21:20:32 +08:00
parent 582bdb783c
commit e44894c666
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
120 changed files with 1163 additions and 1237 deletions

230
flake.nix
View file

@ -170,47 +170,47 @@
};
};
};
outputs =
{
self,
nixpkgs,
flake-parts,
flake-utils,
...
}@inputs:
let
inherit (self) outputs;
rootPath = ./.;
in
flake-parts.lib.mkFlake { inherit inputs; } {
outputs = {
self,
nixpkgs,
flake-parts,
flake-utils,
...
} @ inputs: let
inherit (self) outputs;
rootPath = ./.;
in
flake-parts.lib.mkFlake {inherit inputs;} {
systems = flake-utils.lib.defaultSystems;
imports = [
inputs.home-manager.flakeModules.home-manager
];
perSystem =
{ pkgs, system, ... }@args:
{
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
config = {
allowUnfree = true;
};
perSystem = {
pkgs,
system,
...
} @ args: {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
config = {
allowUnfree = true;
};
packages = import ./pkgs (
args
// {
inherit inputs;
}
);
};
formatter = pkgs.alejandra;
packages = import ./pkgs (
args
// {
inherit inputs;
}
);
};
flake =
{
nix.settings = {
# substituters shared in home-manager and nixos configuration
substituters =
let
cachix = x: "https://${x}.cachix.org";
in
substituters = let
cachix = x: "https://${x}.cachix.org";
in
nixpkgs.lib.flatten [
(cachix "nix-community")
"https://cache.nixos.org"
@ -221,30 +221,30 @@
nixosModules.default = import ./nixos/modules;
overlays = {
modifications = (import ./overlays/modifications { inherit inputs outputs; });
additions = (import ./overlays/additions { inherit inputs outputs; });
modifications = import ./overlays/modifications {inherit inputs outputs;};
additions = import ./overlays/additions {inherit inputs outputs;};
};
nixosConfigurations =
let
nixosConfigDir = ./nixos/configurations;
makeNixConfiguration =
hostName:
nixpkgs.lib.nixosSystem {
modules =
[ outputs.nixosModules.default ]
++ [
(
let
dirPath = nixosConfigDir + "/${hostName}";
filePath = nixosConfigDir + "/${hostName}.nix";
in
if builtins.pathExists dirPath then dirPath else filePath
)
];
specialArgs = { inherit inputs outputs rootPath; };
};
in
nixosConfigurations = let
nixosConfigDir = ./nixos/configurations;
makeNixConfiguration = hostName:
nixpkgs.lib.nixosSystem {
modules =
[outputs.nixosModules.default]
++ [
(
let
dirPath = nixosConfigDir + "/${hostName}";
filePath = nixosConfigDir + "/${hostName}.nix";
in
if builtins.pathExists dirPath
then dirPath
else filePath
)
];
specialArgs = {inherit inputs outputs rootPath;};
};
in
nixosConfigDir
|> builtins.readDir
|> builtins.attrNames
@ -257,45 +257,42 @@
}
// (
let
mkHomeConfig =
{
hostName,
unixName ? "david",
system ? "x86_64-linux",
nixpkgs ? inputs.nixpkgs,
home-manager ? inputs.home-manager,
}:
{
"${unixName}@${hostName}" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages."${system}";
modules =
[
"${toString ./home}/${unixName}/configurations/${hostName}"
]
++ (with outputs.homeModules; [
default
extra
])
++ [
outputs.homeModules."${unixName}"
];
extraSpecialArgs = {
inherit
inputs
outputs
unixName
hostName
system
rootPath
;
};
mkHomeConfig = {
hostName,
unixName ? "david",
system ? "x86_64-linux",
nixpkgs ? inputs.nixpkgs,
home-manager ? inputs.home-manager,
}: {
"${unixName}@${hostName}" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages."${system}";
modules =
[
"${toString ./home}/${unixName}/configurations/${hostName}"
]
++ (with outputs.homeModules; [
default
extra
])
++ [
outputs.homeModules."${unixName}"
];
extraSpecialArgs = {
inherit
inputs
outputs
unixName
hostName
system
rootPath
;
};
};
in
{
};
in {
homeConfigurations =
nixpkgs.lib.foldr (a: b: a // b) { } (
map (hostName: mkHomeConfig { inherit hostName; }) [
nixpkgs.lib.foldr (a: b: a // b) {} (
map (hostName: mkHomeConfig {inherit hostName;}) [
"Tytonidae"
"Akun"
]
@ -315,10 +312,10 @@
|> nixpkgs.lib.filterAttrs (key: value: value == "directory")
|> nixpkgs.lib.filterAttrs (
key: value:
!builtins.elem key [
"modules"
"extra"
]
!builtins.elem key [
"modules"
"extra"
]
)
|> builtins.attrNames
|> map (name: {
@ -331,30 +328,27 @@
)
// (
let
mkDeployNode =
{
hostName,
unixName ? "deploy",
system ? "x86_64-linux",
sshName ? hostName,
}:
{
"${hostName}" = {
hostname = "${sshName}";
sshUser = "${unixName}";
interactiveSudo = true;
profiles = {
system = {
user = "root";
path =
inputs.deploy-rs.lib."${system}".activate.nixos
self.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 =
inputs.deploy-rs.lib."${system}".activate.nixos
self.outputs.nixosConfigurations."${hostName}";
};
};
};
in
{
};
in {
deploy.nodes =
[
"Cape"
@ -362,11 +356,11 @@
]
|> map (
hostName:
mkDeployNode {
inherit hostName;
}
mkDeployNode {
inherit hostName;
}
)
|> nixpkgs.lib.foldr (a: b: a // b) { };
|> nixpkgs.lib.foldr (a: b: a // b) {};
}
);
};