Files
nix/libs/mkNixosSystem.nix
2025-04-25 23:10:55 +08:00

23 lines
767 B
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 这个文件提供了一个通用函数用于创建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"
];
};
}