feat: refactoring configuration with options to make it more modular

This commit is contained in:
Ryan Yin
2023-12-23 19:34:13 +08:00
parent 1f08d10ac7
commit b75b79057b
106 changed files with 289 additions and 279 deletions

View File

@@ -1,7 +1,7 @@
args:
with args;
with mylib;
with allSystemAttrs; let
colmenaSystem = import ../lib/colmenaSystem.nix;
# x86_64 related
x64_base_args = {
inherit home-manager;
@@ -65,36 +65,36 @@ in {
};
# proxmox virtual machines(x86_64)
aquamarine = colmenaSystem (libAttrs.mergeAttrsList [
aquamarine = colmenaSystem (attrs.mergeAttrsList [
x64_base_args
idol_aquamarine_modules
{host_tags = idol_aquamarine_tags;}
]);
ruby = colmenaSystem (libAttrs.mergeAttrsList [
ruby = colmenaSystem (attrs.mergeAttrsList [
x64_base_args
idol_ruby_modules
{host_tags = idol_ruby_tags;}
]);
kana = colmenaSystem (libAttrs.mergeAttrsList [
kana = colmenaSystem (attrs.mergeAttrsList [
x64_base_args
idol_kana_modules
{host_tags = idol_kana_tags;}
]);
# riscv64 SBCs
nozomi = colmenaSystem (libAttrs.mergeAttrsList [
nozomi = colmenaSystem (attrs.mergeAttrsList [
lpi4a_base_args
rolling_nozomi_modules
{host_tags = rolling_nozomi_tags;}
]);
yukina = colmenaSystem (libAttrs.mergeAttrsList [
yukina = colmenaSystem (attrs.mergeAttrsList [
lpi4a_base_args
rolling_yukina_modules
{host_tags = rolling_yukina_tags;}
]);
# aarch64 SBCs
suzu = colmenaSystem (libAttrs.mergeAttrsList [
suzu = colmenaSystem (attrs.mergeAttrsList [
rk3588_base_args
_12kingdoms_suzu_modules
{host_tags = _12kingdoms_suzu_tags;}

View File

@@ -1,7 +1,7 @@
args:
with args;
with mylib;
with allSystemAttrs; let
macosSystem = import ../lib/macosSystem.nix;
base_args = {
inherit nix-darwin home-manager;
nixpkgs = nixpkgs-darwin;
@@ -10,7 +10,7 @@ in {
# macOS's configuration
darwinConfigurations = {
harmonica = macosSystem (
libAttrs.mergeAttrsList [
attrs.mergeAttrsList [
base_args
darwin_harmonica_modules
{
@@ -21,7 +21,7 @@ in {
);
fern = macosSystem (
libAttrs.mergeAttrsList [
attrs.mergeAttrsList [
base_args
darwin_fern_modules
{

View File

@@ -4,13 +4,13 @@
constants,
}: let
inherit (inputs.nixpkgs) lib;
libAttrs = import ../lib/attrs.nix {inherit lib;};
mylib = import ../lib { inherit lib; };
vars = import ./vars.nix;
specialArgsForSystem = system:
{
inherit (constants) username userfullname useremail;
inherit libAttrs;
inherit mylib;
# use unstable branch for some packages to get the latest updates
pkgs-unstable = import inputs.nixpkgs-unstable {
inherit system; # refer the `system` parameter form outer scope recursively
@@ -21,18 +21,18 @@
// inputs;
allSystemSpecialArgs =
libAttrs.mapAttrs
mylib.attrs.mapAttrs
(_: specialArgsForSystem)
constants.allSystemAttrs;
args = libAttrs.mergeAttrsList [
args = mylib.attrs.mergeAttrsList [
inputs
constants
vars
{inherit self lib libAttrs allSystemSpecialArgs;}
{inherit self lib mylib allSystemSpecialArgs;}
];
in
libAttrs.mergeAttrsList [
mylib.attrs.mergeAttrsList [
(import ./nixos.nix args)
(import ./darwin.nix args)
(import ./colmena.nix args)

View File

@@ -1,8 +1,7 @@
args:
with args;
with mylib;
with allSystemAttrs; let
nixosSystem = import ../lib/nixosSystem.nix;
base_args = {
inherit home-manager nixos-generators;
inherit nixpkgs; # or nixpkgs-unstable
@@ -24,9 +23,9 @@ in {
# take system images for idols
# https://github.com/nix-community/nixos-generators
packages."${x64_system}" = libAttrs.mergeAttrsList [
packages."${x64_system}" = attrs.mergeAttrsList [
(
libAttrs.listToAttrs
attrs.listToAttrs
[
"ai_i3"
"ai_hyprland"
@@ -36,7 +35,7 @@ in {
)
(
libAttrs.listToAttrs
attrs.listToAttrs
[
"aquamarine"
"ruby"

View File

@@ -1,30 +1,30 @@
{
rec {
# 星野 アイ, Hoshino Ai
__idol_ai_base_nixos_modules = [
../hosts/idols/ai
../secrets/nixos.nix
../modules/nixos/desktop.nix
];
__idol_ai_base_home_modules = [
../home/linux/desktop.nix
];
idol_ai_modules_i3 = {
nixos-modules = [
../hosts/idols/ai
../secrets/nixos.nix
../modules/nixos/xorg.nix
];
home-module = {
imports = [
../home/linux/desktop.nix
../home/linux/i3
];
};
nixos-modules =
[{modules.desktop.xorg.enable = true;}]
++ __idol_ai_base_nixos_modules;
home-module.imports =
[{modules.desktop.i3.enable = true;}]
++ __idol_ai_base_home_modules;
};
idol_ai_modules_hyprland = {
nixos-modules = [
../hosts/idols/ai
../secrets/nixos.nix
../modules/nixos/wayland.nix
];
home-module = {
imports = [
../home/linux/desktop.nix
../home/linux/hyprland
];
};
nixos-modules =
[{modules.desktop.wayland.enable = true;}]
++ __idol_ai_base_nixos_modules;
home-module.imports =
[{modules.desktop.hyprland.enable = true;}]
++ __idol_ai_base_home_modules;
};
# 星野 愛久愛海, Hoshino Akuamarin