This commit is contained in:
2025-04-25 23:10:55 +08:00
commit ccf46b865e
114 changed files with 6419 additions and 0 deletions

8
libs/default.nix Normal file
View File

@@ -0,0 +1,8 @@
let
# 导入mkNixosSystem函数
mkNixosSystemLib = import ./mkNixosSystem.nix;
in
{
# 导出mkNixosSystem函数
inherit (mkNixosSystemLib) mkNixosSystem;
}

22
libs/mkNixosSystem.nix Normal file
View File

@@ -0,0 +1,22 @@
# 这个文件提供了一个通用函数用于创建nixosSystem
{
# 创建nixosSystem的通用函数
# 这个函数只负责创建nixosSystem不处理nixpkgs的选择
# args: 从flake.nix传递的所有参数
# profile: 要使用的nixpkgs (由profile的default.nix决定)
# path: profile目录的路径
mkNixosSystem = { args, nixpkgs, path }:
let
# 获取profile名称目录名
profile = builtins.baseNameOf path;
specialArgs = args // { hostname = profile; }; # 添加hostname
in
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
inherit specialArgs;
modules = [
# 导入configuration.nix模块其中包含了实际的配置
"${path}/configuration.nix"
];
};
}