mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-17 06:29:41 +02:00
feat: refactor flake.nix
This commit is contained in:
102
systems/colmena.nix
Normal file
102
systems/colmena.nix
Normal file
@@ -0,0 +1,102 @@
|
||||
args:
|
||||
with args; let
|
||||
lib = nixpkgs.lib;
|
||||
colmenaSystem = import ../lib/colmenaSystem.nix;
|
||||
# x86_64 related
|
||||
x64_base_args = {
|
||||
inherit home-manager;
|
||||
inherit nixpkgs; # or nixpkgs-unstable
|
||||
specialArgs = x64_system_specialArgs;
|
||||
};
|
||||
|
||||
# riscv64 related
|
||||
# using the same nixpkgs as nixos-licheepi4a to utilize the cross-compilation cache.
|
||||
lpi4a_pkgs = import nixos-licheepi4a.inputs.nixpkgs {system = x64_system;};
|
||||
lpi4a_specialArgs =
|
||||
{
|
||||
inherit username userfullname useremail;
|
||||
pkgsKernel = nixos-licheepi4a.packages.${x64_system}.pkgsKernelCross;
|
||||
}
|
||||
// args;
|
||||
lpi4a_base_args = {
|
||||
inherit home-manager;
|
||||
inherit (nixos-licheepi4a.inputs) nixpkgs; # or nixpkgs-unstable
|
||||
specialArgs = lpi4a_specialArgs;
|
||||
targetUser = "root";
|
||||
};
|
||||
|
||||
# aarch64 related
|
||||
# using the same nixpkgs as nixos-rk3588 to utilize the cross-compilation cache.
|
||||
rk3588_pkgs = import nixos-rk3588.inputs.nixpkgs {system = x64_system;};
|
||||
rk3588_specialArgs =
|
||||
{
|
||||
inherit username userfullname useremail;
|
||||
}
|
||||
// nixos-rk3588.inputs;
|
||||
rk3588_base_args = {
|
||||
inherit home-manager;
|
||||
inherit (nixos-rk3588.inputs) nixpkgs; # or nixpkgs-unstable
|
||||
specialArgs = rk3588_specialArgs;
|
||||
targetUser = "root";
|
||||
};
|
||||
in {
|
||||
# colmena - remote deployment via SSH
|
||||
colmena = {
|
||||
meta = {
|
||||
nixpkgs = import nixpkgs {system = x64_system;};
|
||||
specialArgs = x64_system_specialArgs;
|
||||
|
||||
nodeSpecialArgs = {
|
||||
# riscv64 SBCs
|
||||
nozomi = lpi4a_specialArgs;
|
||||
yukina = lpi4a_specialArgs;
|
||||
|
||||
# aarch64 SBCs
|
||||
suzu = rk3588_specialArgs;
|
||||
};
|
||||
nodeNixpkgs = {
|
||||
nozomi = lpi4a_pkgs;
|
||||
yukina = lpi4a_pkgs;
|
||||
|
||||
# aarch64 SBCs
|
||||
suzu = rk3588_pkgs;
|
||||
};
|
||||
};
|
||||
|
||||
# proxmox virtual machines(x86_64)
|
||||
aquamarine = colmenaSystem (lib.attrsets.mergeAttrsList [
|
||||
x64_base_args
|
||||
idol_aquamarine_modules
|
||||
{host_tags = idol_aquamarine_tags;}
|
||||
]);
|
||||
ruby = colmenaSystem (lib.attrsets.mergeAttrsList [
|
||||
x64_base_args
|
||||
idol_ruby_modules
|
||||
{host_tags = idol_ruby_tags;}
|
||||
]);
|
||||
kana = colmenaSystem (lib.attrsets.mergeAttrsList [
|
||||
x64_base_args
|
||||
idol_kana_modules
|
||||
{host_tags = idol_kana_tags;}
|
||||
]);
|
||||
|
||||
# riscv64 SBCs
|
||||
nozomi = colmenaSystem (lib.attrsets.mergeAttrsList [
|
||||
lpi4a_base_args
|
||||
rolling_nozomi_modules
|
||||
{host_tags = rolling_nozomi_tags;}
|
||||
]);
|
||||
yukina = colmenaSystem (lib.attrsets.mergeAttrsList [
|
||||
lpi4a_base_args
|
||||
rolling_yukina_modules
|
||||
{host_tags = rolling_yukina_tags;}
|
||||
]);
|
||||
|
||||
# aarch64 SBCs
|
||||
suzu = colmenaSystem (lib.attrsets.mergeAttrsList [
|
||||
rk3588_base_args
|
||||
_12kingdoms_suzu_modules
|
||||
{host_tags = _12kingdoms_suzu_tags;}
|
||||
]);
|
||||
};
|
||||
}
|
||||
17
systems/darwin.nix
Normal file
17
systems/darwin.nix
Normal file
@@ -0,0 +1,17 @@
|
||||
args:
|
||||
with args; let
|
||||
macosSystem = import ../lib/macosSystem.nix;
|
||||
system = x64_darwin;
|
||||
base_args = {
|
||||
inherit nix-darwin home-manager system;
|
||||
specialArgs = x64_darwin_specialArgs;
|
||||
nixpkgs = nixpkgs-darwin;
|
||||
};
|
||||
in {
|
||||
# macOS's configuration, for work.
|
||||
darwinConfigurations = {
|
||||
harmonica =
|
||||
macosSystem (base_args
|
||||
// darwin_harmonica_modules);
|
||||
};
|
||||
}
|
||||
42
systems/default.nix
Normal file
42
systems/default.nix
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
self,
|
||||
inputs,
|
||||
constants,
|
||||
}: let
|
||||
lib = inputs.nixpkgs.lib;
|
||||
vars = import ./vars.nix;
|
||||
|
||||
specialArgsForSystem = system:
|
||||
{
|
||||
inherit (constants) username userfullname useremail;
|
||||
# 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
|
||||
# To use chrome, we need to allow the installation of non-free software
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
}
|
||||
// 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;
|
||||
};
|
||||
|
||||
args = lib.attrsets.mergeAttrsList [
|
||||
inputs
|
||||
constants
|
||||
vars
|
||||
allSystemSpecialArgs
|
||||
{inherit self;}
|
||||
];
|
||||
in
|
||||
lib.attrsets.mergeAttrsList [
|
||||
(import ./nixos.nix args)
|
||||
(import ./darwin.nix args)
|
||||
(import ./colmena.nix args)
|
||||
]
|
||||
47
systems/nixos.nix
Normal file
47
systems/nixos.nix
Normal file
@@ -0,0 +1,47 @@
|
||||
args:
|
||||
with args; let
|
||||
nixosSystem = import ../lib/nixosSystem.nix;
|
||||
|
||||
base_args = {
|
||||
inherit home-manager nixos-generators;
|
||||
inherit nixpkgs; # or nixpkgs-unstable
|
||||
system = x64_system;
|
||||
specialArgs = x64_system_specialArgs;
|
||||
};
|
||||
in {
|
||||
nixosConfigurations = {
|
||||
# ai with i3 window manager
|
||||
ai_i3 = nixosSystem (idol_ai_modules_i3 // base_args);
|
||||
# ai with hyprland compositor
|
||||
ai_hyprland = nixosSystem (idol_ai_modules_hyprland // base_args);
|
||||
|
||||
# three virtual machines without desktop environment.
|
||||
aquamarine = nixosSystem (idol_aquamarine_modules // base_args);
|
||||
ruby = nixosSystem (idol_ruby_modules // base_args);
|
||||
kana = nixosSystem (idol_kana_modules // base_args);
|
||||
};
|
||||
|
||||
# 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"
|
||||
]
|
||||
(
|
||||
# generate iso image for hosts with desktop environment
|
||||
host:
|
||||
self.nixosConfigurations.${host}.config.formats.iso
|
||||
)
|
||||
// nixpkgs.lib.genAttrs [
|
||||
"aquamarine"
|
||||
"ruby"
|
||||
"kana"
|
||||
]
|
||||
(
|
||||
# generate proxmox image for virtual machines without desktop environment
|
||||
host:
|
||||
self.nixosConfigurations.${host}.config.formats.proxmox
|
||||
);
|
||||
}
|
||||
102
systems/vars.nix
Normal file
102
systems/vars.nix
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
# 星野 アイ, Hoshino Ai
|
||||
idol_ai_modules_i3 = {
|
||||
nixos-modules = [
|
||||
../hosts/idols/ai
|
||||
../secrets/nixos.nix
|
||||
../modules/nixos/i3.nix
|
||||
];
|
||||
home-module = import ../home/linux/desktop-i3.nix;
|
||||
};
|
||||
idol_ai_modules_hyprland = {
|
||||
nixos-modules = [
|
||||
../hosts/idols/ai
|
||||
../secrets/nixos.nix
|
||||
../modules/nixos/hyprland.nix
|
||||
];
|
||||
home-module = import ../home/linux/desktop-hyprland.nix;
|
||||
};
|
||||
|
||||
# 星野 愛久愛海, Hoshino Akuamarin
|
||||
idol_aquamarine_modules = {
|
||||
nixos-modules = [
|
||||
../hosts/idols/aquamarine
|
||||
../modules/nixos/server.nix
|
||||
../modules/nixos/proxmox-hardware-configuration.nix
|
||||
];
|
||||
home-module = import ../home/linux/server.nix;
|
||||
};
|
||||
idol_aquamarine_tags = ["dist-build" "aqua"];
|
||||
|
||||
# 星野 瑠美衣, Hoshino Rubii
|
||||
idol_ruby_modules = {
|
||||
nixos-modules = [
|
||||
../hosts/idols/ruby
|
||||
../modules/nixos/server.nix
|
||||
../modules/nixos/proxmox-hardware-configuration.nix
|
||||
];
|
||||
home-module = import ../home/linux/server.nix;
|
||||
};
|
||||
idol_ruby_tags = ["dist-build" "ruby"];
|
||||
|
||||
# 有馬 かな, Arima Kana
|
||||
idol_kana_modules = {
|
||||
nixos-modules = [
|
||||
../hosts/idols/kana
|
||||
../modules/nixos/server.nix
|
||||
../modules/nixos/proxmox-hardware-configuration.nix
|
||||
];
|
||||
home-module = import ../home/linux/server.nix;
|
||||
};
|
||||
idol_kana_tags = ["dist-build" "kana"];
|
||||
|
||||
# 森友 望未, Moritomo Nozomi
|
||||
rolling_nozomi_modules = {
|
||||
nixos-modules = [
|
||||
../hosts/rolling_girls/nozomi
|
||||
../modules/nixos/server-riscv64.nix
|
||||
|
||||
# cross-compilation this flake.
|
||||
{nixpkgs.crossSystem.system = "riscv64-linux";}
|
||||
];
|
||||
# home-module = import ../home/linux/server-riscv64.nix;
|
||||
};
|
||||
rolling_nozomi_tags = ["riscv" "nozomi"];
|
||||
|
||||
# 小坂 結季奈, Kosaka Yukina
|
||||
rolling_yukina_modules = {
|
||||
nixos-modules = [
|
||||
../hosts/rolling_girls/yukina
|
||||
../modules/nixos/server-riscv64.nix
|
||||
|
||||
# cross-compilation this flake.
|
||||
{nixpkgs.crossSystem.system = "riscv64-linux";}
|
||||
];
|
||||
# home-module = import ../home/linux/server-riscv64.nix;
|
||||
};
|
||||
rolling_yukina_tags = ["riscv" "yukina"];
|
||||
|
||||
# 大木 鈴, Ōki Suzu
|
||||
_12kingdoms_suzu_modules = {
|
||||
nixos-modules = [
|
||||
../hosts/12kingdoms/suzu
|
||||
../modules/nixos/server-riscv64.nix
|
||||
|
||||
# cross-compilation this flake.
|
||||
{nixpkgs.crossSystem.config = "aarch64-unknown-linux-gnu";}
|
||||
];
|
||||
# home-module = import ../home/linux/server.nix;
|
||||
};
|
||||
_12kingdoms_suzu_tags = ["aarch" "suzu"];
|
||||
|
||||
# darwin systems
|
||||
darwin_harmonica_modules = {
|
||||
darwin-modules = [
|
||||
../hosts/harmonica
|
||||
|
||||
../modules/darwin
|
||||
../secrets/darwin.nix
|
||||
];
|
||||
home-module = import ../home/darwin;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user