feat: nix fmt

This commit is contained in:
Ryan Yin
2023-12-18 00:44:18 +08:00
parent b2f75a37dc
commit 74cec7dd8e
4 changed files with 389 additions and 231 deletions
+1
View File
@@ -1,3 +1,4 @@
result result
result/ result/
.DS_Store .DS_Store
.pre-commit-config.yaml
Generated
+125
View File
@@ -274,6 +274,22 @@
"type": "github" "type": "github"
} }
}, },
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
@@ -334,6 +350,24 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_2": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": { "gitignore": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@@ -356,6 +390,27 @@
"type": "github" "type": "github"
} }
}, },
"gitignore_2": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@@ -664,6 +719,22 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-stable_2": {
"locked": {
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1702312524, "lastModified": 1702312524,
@@ -760,6 +831,22 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_7": {
"locked": {
"lastModified": 1689261696,
"narHash": "sha256-LzfUtFs9MQRvIoQ3MfgSuipBVMXslMPH/vZ+nM40LkA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "df1eee2aa65052a18121ed4971081576b25d6b5c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nur-ryan4yin": { "nur-ryan4yin": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs_6" "nixpkgs": "nixpkgs_6"
@@ -795,6 +882,28 @@
"type": "github" "type": "github"
} }
}, },
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_2",
"gitignore": "gitignore_2",
"nixpkgs": "nixpkgs_7",
"nixpkgs-stable": "nixpkgs-stable_2"
},
"locked": {
"lastModified": 1702456155,
"narHash": "sha256-I2XhXGAecdGlqi6hPWYT83AQtMgL+aa3ulA85RAEgOk=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "007a45d064c1c32d04e1b8a0de5ef00984c419bc",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"pre-commit-hooks-nix": { "pre-commit-hooks-nix": {
"inputs": { "inputs": {
"flake-compat": [ "flake-compat": [
@@ -854,6 +963,7 @@
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",
"nur-ryan4yin": "nur-ryan4yin", "nur-ryan4yin": "nur-ryan4yin",
"nushell-scripts": "nushell-scripts", "nushell-scripts": "nushell-scripts",
"pre-commit-hooks": "pre-commit-hooks",
"wallpapers": "wallpapers" "wallpapers": "wallpapers"
} }
}, },
@@ -912,6 +1022,21 @@
"type": "github" "type": "github"
} }
}, },
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"thead-kernel": { "thead-kernel": {
"flake": false, "flake": false,
"locked": { "locked": {
+69 -36
View File
@@ -13,17 +13,19 @@
# parameters in `outputs` are defined in `inputs` and can be referenced by their names. # parameters in `outputs` are defined in `inputs` and can be referenced by their names.
# However, `self` is an exception, this special parameter points to the `outputs` itself (self-reference) # However, `self` is an exception, this special parameter points to the `outputs` itself (self-reference)
# The `@` syntax here is used to alias the attribute set of the inputs's parameter, making it convenient to use inside the function. # The `@` syntax here is used to alias the attribute set of the inputs's parameter, making it convenient to use inside the function.
outputs = inputs @ { outputs =
self, inputs @ { self
nixpkgs, , nixpkgs
nixpkgs-unstable, , nixpkgs-unstable
nix-darwin, , pre-commit-hooks
home-manager, , nix-darwin
nixos-generators, , home-manager
nixos-licheepi4a, , nixos-generators
nixos-rk3588, , nixos-licheepi4a
... , nixos-rk3588
}: let , ...
}:
let
username = "ryan"; username = "ryan";
userfullname = "Ryan Yin"; userfullname = "Ryan Yin";
useremail = "xiaoyin_c@qq.com"; useremail = "xiaoyin_c@qq.com";
@@ -32,7 +34,7 @@
x64_darwin = "x86_64-darwin"; x64_darwin = "x86_64-darwin";
riscv64_system = "riscv64-linux"; riscv64_system = "riscv64-linux";
aarch64_system = "aarch64-linux"; aarch64_system = "aarch64-linux";
allSystems = [x64_system x64_darwin riscv64_system aarch64_system]; allSystems = [ x64_system x64_darwin riscv64_system aarch64_system ];
nixosSystem = import ./lib/nixosSystem.nix; nixosSystem = import ./lib/nixosSystem.nix;
macosSystem = import ./lib/macosSystem.nix; macosSystem = import ./lib/macosSystem.nix;
@@ -61,7 +63,7 @@
]; ];
home-module = import ./home/linux/server.nix; home-module = import ./home/linux/server.nix;
}; };
idol_aquamarine_tags = ["dist-build" "aqua"]; idol_aquamarine_tags = [ "dist-build" "aqua" ];
# 星野 瑠美衣, Hoshino Rubii # 星野 瑠美衣, Hoshino Rubii
idol_ruby_modules = { idol_ruby_modules = {
@@ -70,7 +72,7 @@
]; ];
home-module = import ./home/linux/server.nix; home-module = import ./home/linux/server.nix;
}; };
idol_ruby_tags = ["dist-build" "ruby"]; idol_ruby_tags = [ "dist-build" "ruby" ];
# 有馬 かな, Arima Kana # 有馬 かな, Arima Kana
idol_kana_modules = { idol_kana_modules = {
@@ -79,7 +81,7 @@
]; ];
home-module = import ./home/linux/server.nix; home-module = import ./home/linux/server.nix;
}; };
idol_kana_tags = ["dist-build" "kana"]; idol_kana_tags = [ "dist-build" "kana" ];
# 森友 望未, Moritomo Nozomi # 森友 望未, Moritomo Nozomi
rolling_nozomi_modules = { rolling_nozomi_modules = {
@@ -88,7 +90,7 @@
]; ];
# home-module = import ./home/linux/server-riscv64.nix; # home-module = import ./home/linux/server-riscv64.nix;
}; };
rolling_nozomi_tags = ["riscv" "nozomi"]; rolling_nozomi_tags = [ "riscv" "nozomi" ];
# 小坂 結季奈, Kosaka Yukina # 小坂 結季奈, Kosaka Yukina
rolling_yukina_modules = { rolling_yukina_modules = {
@@ -97,7 +99,7 @@
]; ];
# home-module = import ./home/linux/server-riscv64.nix; # home-module = import ./home/linux/server-riscv64.nix;
}; };
rolling_yukina_tags = ["riscv" "yukina"]; rolling_yukina_tags = [ "riscv" "yukina" ];
# 大木 鈴, Ōki Suzu # 大木 鈴, Ōki Suzu
_12kingdoms_suzu_modules = { _12kingdoms_suzu_modules = {
@@ -106,7 +108,7 @@
]; ];
# home-module = import ./home/linux/server.nix; # home-module = import ./home/linux/server.nix;
}; };
_12kingdoms_suzu_tags = ["aarch" "suzu"]; _12kingdoms_suzu_tags = [ "aarch" "suzu" ];
x64_specialArgs = x64_specialArgs =
{ {
@@ -119,15 +121,18 @@
}; };
} }
// inputs; // inputs;
in { in
nixosConfigurations = let {
nixosConfigurations =
let
base_args = { base_args = {
inherit home-manager nixos-generators; inherit home-manager nixos-generators;
nixpkgs = nixpkgs; # or nixpkgs-unstable nixpkgs = nixpkgs; # or nixpkgs-unstable
system = x64_system; system = x64_system;
specialArgs = x64_specialArgs; specialArgs = x64_specialArgs;
}; };
in { in
{
# ai with i3 window manager # ai with i3 window manager
ai_i3 = nixosSystem (idol_ai_modules_i3 // base_args); ai_i3 = nixosSystem (idol_ai_modules_i3 // base_args);
# ai with hyprland compositor # ai with hyprland compositor
@@ -140,7 +145,8 @@
}; };
# colmena - remote deployment via SSH # colmena - remote deployment via SSH
colmena = let colmena =
let
# x86_64 related # x86_64 related
x64_base_args = { x64_base_args = {
inherit home-manager; inherit home-manager;
@@ -150,7 +156,7 @@
# riscv64 related # riscv64 related
# using the same nixpkgs as nixos-licheepi4a to utilize the cross-compilation cache. # using the same nixpkgs as nixos-licheepi4a to utilize the cross-compilation cache.
lpi4a_pkgs = import nixos-licheepi4a.inputs.nixpkgs {system = x64_system;}; lpi4a_pkgs = import nixos-licheepi4a.inputs.nixpkgs { system = x64_system; };
lpi4a_specialArgs = lpi4a_specialArgs =
{ {
inherit username userfullname useremail; inherit username userfullname useremail;
@@ -166,7 +172,7 @@
# aarch64 related # aarch64 related
# using the same nixpkgs as nixos-rk3588 to utilize the cross-compilation cache. # using the same nixpkgs as nixos-rk3588 to utilize the cross-compilation cache.
rk3588_pkgs = import nixos-rk3588.inputs.nixpkgs {system = x64_system;}; rk3588_pkgs = import nixos-rk3588.inputs.nixpkgs { system = x64_system; };
rk3588_specialArgs = rk3588_specialArgs =
{ {
inherit username userfullname useremail; inherit username userfullname useremail;
@@ -178,9 +184,10 @@
specialArgs = rk3588_specialArgs; specialArgs = rk3588_specialArgs;
targetUser = "root"; targetUser = "root";
}; };
in { in
{
meta = { meta = {
nixpkgs = import nixpkgs {system = x64_system;}; nixpkgs = import nixpkgs { system = x64_system; };
specialArgs = x64_specialArgs; specialArgs = x64_specialArgs;
nodeSpecialArgs = { nodeSpecialArgs = {
@@ -201,16 +208,16 @@
}; };
# proxmox virtual machines(x86_64) # proxmox virtual machines(x86_64)
aquamarine = colmenaSystem (idol_aquamarine_modules // x64_base_args // {host_tags = idol_aquamarine_tags;}); aquamarine = colmenaSystem (idol_aquamarine_modules // x64_base_args // { host_tags = idol_aquamarine_tags; });
ruby = colmenaSystem (idol_ruby_modules // x64_base_args // {host_tags = idol_ruby_tags;}); ruby = colmenaSystem (idol_ruby_modules // x64_base_args // { host_tags = idol_ruby_tags; });
kana = colmenaSystem (idol_kana_modules // x64_base_args // {host_tags = idol_kana_tags;}); kana = colmenaSystem (idol_kana_modules // x64_base_args // { host_tags = idol_kana_tags; });
# riscv64 SBCs # riscv64 SBCs
nozomi = colmenaSystem (rolling_nozomi_modules // lpi4a_base_args // {host_tags = rolling_nozomi_tags;}); nozomi = colmenaSystem (rolling_nozomi_modules // lpi4a_base_args // { host_tags = rolling_nozomi_tags; });
yukina = colmenaSystem (rolling_yukina_modules // lpi4a_base_args // {host_tags = rolling_yukina_tags;}); yukina = colmenaSystem (rolling_yukina_modules // lpi4a_base_args // { host_tags = rolling_yukina_tags; });
# aarch64 SBCs # aarch64 SBCs
suzu = colmenaSystem (_12kingdoms_suzu_modules // rk3588_base_args // {host_tags = _12kingdoms_suzu_tags;}); suzu = colmenaSystem (_12kingdoms_suzu_modules // rk3588_base_args // { host_tags = _12kingdoms_suzu_tags; });
}; };
# take system images for idols # take system images for idols
@@ -220,7 +227,8 @@
nixpkgs.lib.genAttrs [ nixpkgs.lib.genAttrs [
"ai_i3" "ai_i3"
"ai_hyprland" "ai_hyprland"
] ( ]
(
# generate iso image for hosts with desktop environment # generate iso image for hosts with desktop environment
host: host:
self.nixosConfigurations.${host}.config.formats.iso self.nixosConfigurations.${host}.config.formats.iso
@@ -229,14 +237,16 @@
"aquamarine" "aquamarine"
"ruby" "ruby"
"kana" "kana"
] ( ]
(
# generate proxmox image for virtual machines without desktop environment # generate proxmox image for virtual machines without desktop environment
host: host:
self.nixosConfigurations.${host}.config.formats.proxmox self.nixosConfigurations.${host}.config.formats.proxmox
); );
# macOS's configuration, for work. # macOS's configuration, for work.
darwinConfigurations = let darwinConfigurations =
let
system = x64_darwin; system = x64_darwin;
specialArgs = specialArgs =
{ {
@@ -252,7 +262,8 @@
base_args = { base_args = {
inherit nix-darwin home-manager system specialArgs nixpkgs; inherit nix-darwin home-manager system specialArgs nixpkgs;
}; };
in { in
{
harmonica = macosSystem (base_args harmonica = macosSystem (base_args
// { // {
darwin-modules = [ darwin-modules = [
@@ -268,6 +279,25 @@
system: system:
nixpkgs.legacyPackages.${system}.alejandra nixpkgs.legacyPackages.${system}.alejandra
); );
# pre-commit hooks for nix code
checks = nixpkgs.lib.genAttrs allSystems (
system: {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
};
};
}
);
devShells = nixpkgs.lib.genAttrs allSystems (
system: {
default = nixpkgs.legacyPackages.${system}.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
}
);
}; };
# This is the standard format for flake.nix. `inputs` are the dependencies of the flake, # This is the standard format for flake.nix. `inputs` are the dependencies of the flake,
@@ -281,6 +311,9 @@
# nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; # nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
# add git hooks to format nix code before commit
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
# for macos # for macos
nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-23.11-darwin"; nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-23.11-darwin";
nix-darwin = { nix-darwin = {
-1
View File
@@ -3,7 +3,6 @@
./base/i18n.nix ./base/i18n.nix
./base/misc.nix ./base/misc.nix
./base/networking.nix ./base/networking.nix
./base/peripherals.nix
./base/remote-building.nix ./base/remote-building.nix
./base/user-group.nix ./base/user-group.nix
./base/visualisation.nix ./base/visualisation.nix