refactor: systems

This commit is contained in:
Ryan Yin
2023-12-22 00:33:35 +08:00
parent c49a96ae29
commit 05aa451895
3 changed files with 46 additions and 33 deletions

View File

@@ -1,15 +1,18 @@
rec { let
systemAttrs = {
# linux systems
x64_system = "x86_64-linux";
riscv64_system = "riscv64-linux";
aarch64_system = "aarch64-linux";
# darwin systems
x64_darwin = "x86_64-darwin";
aarch64_darwin = "aarch64-darwin";
};
in systemAttrs // {
# user information # user information
username = "ryan"; username = "ryan";
userfullname = "Ryan Yin"; userfullname = "Ryan Yin";
useremail = "xiaoyin_c@qq.com"; useremail = "xiaoyin_c@qq.com";
# linux systems allSystems = builtins.attrValues systemAttrs;
x64_system = "x86_64-linux";
riscv64_system = "riscv64-linux";
aarch64_system = "aarch64-linux";
# darwin systems
x64_darwin = "x86_64-darwin";
aarch64_darwin = "aarch64-darwin";
allSystems = [x64_system riscv64_system aarch64_system x64_darwin aarch64_darwin];
} }

View File

@@ -18,14 +18,20 @@
} }
// inputs; // inputs;
allSystemSpecialArgs = with constants; { allSystemSpecialArgs = builtins.listToAttrs (
x64_system_specialArgs = specialArgsForSystem x64_system; map
aarch64_system_specialArgs = specialArgsForSystem aarch64_system; (attr: {
riscv64_system_specialArgs = specialArgsForSystem riscv64_system; name = attr + "_specialArgs";
value = specialArgsForSystem constants.${attr};
x64_darwin_specialArgs = specialArgsForSystem x64_darwin; })
aarch64_darwin_specialArgs = specialArgsForSystem aarch64_darwin; [
}; "x64_system"
"aarch64_system"
"riscv64_system"
"x64_darwin"
"aarch64_darwin"
]
);
args = lib.attrsets.mergeAttrsList [ args = lib.attrsets.mergeAttrsList [
inputs inputs

View File

@@ -1,5 +1,6 @@
args: args:
with args; let with args; let
lib = nixpkgs.lib;
nixosSystem = import ../lib/nixosSystem.nix; nixosSystem = import ../lib/nixosSystem.nix;
base_args = { base_args = {
@@ -23,25 +24,28 @@ in {
# take system images for idols # take system images for idols
# https://github.com/nix-community/nixos-generators # https://github.com/nix-community/nixos-generators
packages."${x64_system}" = packages."${x64_system}" = lib.attrsets.mergeAttrsList [
# genAttrs returns an attribute set with the given keys and values(host => image).
nixpkgs.lib.genAttrs [
"ai_i3"
"ai_hyprland"
]
( (
# lib.genAttrs [ "foo" "bar" ] (name: "x_" + name)
# => { foo = "x_foo"; bar = "x_bar"; }
nixpkgs.lib.genAttrs
[
"ai_i3"
"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
) )
// nixpkgs.lib.genAttrs [
"aquamarine"
"ruby"
"kana"
]
( (
nixpkgs.lib.genAttrs
[
"aquamarine"
"ruby"
"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 )
); ];
} }