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
username = "ryan";
userfullname = "Ryan Yin";
useremail = "xiaoyin_c@qq.com";
# 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";
allSystems = [x64_system riscv64_system aarch64_system x64_darwin aarch64_darwin];
allSystems = builtins.attrValues systemAttrs;
}

View File

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

View File

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