feat: remove x86_64-darwin, add new nixos host on macbook pro m2

This commit is contained in:
Ryan Yin
2025-07-12 16:51:48 +08:00
parent 77a792710a
commit db82d2d8c5
38 changed files with 308 additions and 387 deletions

View File

@@ -5,6 +5,7 @@
username = myvars.username;
hosts = [
"fern"
"frieren"
];
in
lib.genAttrs hosts (_: "/Users/${username}")

View File

@@ -6,6 +6,7 @@
username = myvars.username;
hosts = [
"fern"
"frieren"
];
in
lib.genAttrs

View File

@@ -0,0 +1,37 @@
{
lib,
inputs,
...
} @ args: let
inherit (inputs) haumea;
# Contains all the flake outputs of this system architecture.
data = haumea.lib.load {
src = ./src;
inputs = args;
};
# nix file names is redundant, so we remove it.
dataWithoutPaths = builtins.attrValues data;
# Merge all the machine's data into a single attribute set.
outputs = {
nixosConfigurations = lib.attrsets.mergeAttrsList (map (it: it.nixosConfigurations or {}) dataWithoutPaths);
packages = lib.attrsets.mergeAttrsList (map (it: it.packages or {}) dataWithoutPaths);
# colmena contains some meta info, which need to be merged carefully.
colmenaMeta = {
nodeNixpkgs = lib.attrsets.mergeAttrsList (map (it: it.colmenaMeta.nodeNixpkgs or {}) dataWithoutPaths);
nodeSpecialArgs = lib.attrsets.mergeAttrsList (map (it: it.colmenaMeta.nodeSpecialArgs or {}) dataWithoutPaths);
};
colmena = lib.attrsets.mergeAttrsList (map (it: it.colmena or {}) dataWithoutPaths);
};
in
outputs
// {
inherit data; # for debugging purposes
# NixOS's unit tests.
evalTests = haumea.lib.loadEvalTests {
src = ./tests;
inputs = args // {inherit outputs;};
};
}

View File

@@ -4,7 +4,7 @@
}: let
username = myvars.username;
hosts = [
"harmonica"
"shoukei-hyprland"
];
in
lib.genAttrs hosts (_: "/Users/${username}")
lib.genAttrs hosts (_: "/home/${username}")

View File

@@ -0,0 +1,15 @@
{
myvars,
lib,
outputs,
}: let
username = myvars.username;
hosts = [
"shoukei-hyprland"
];
in
lib.genAttrs
hosts
(
name: outputs.nixosConfigurations.${name}.config.home-manager.users.${username}.home.homeDirectory
)

View File

@@ -0,0 +1,14 @@
{
lib,
outputs,
}: let
specialExpected = {
"shoukei-hyprland" = "shoukei";
};
specialHostNames = builtins.attrNames specialExpected;
otherHosts = builtins.removeAttrs outputs.nixosConfigurations specialHostNames;
otherHostsNames = builtins.attrNames otherHosts;
# other hosts's hostName is the same as the nixosConfigurations name
otherExpected = lib.genAttrs otherHostsNames (name: name);
in (specialExpected // otherExpected)

View File

@@ -0,0 +1,9 @@
{
lib,
outputs,
}:
lib.genAttrs
(builtins.attrNames outputs.nixosConfigurations)
(
name: outputs.nixosConfigurations.${name}.config.networking.hostName
)

View File

@@ -0,0 +1,8 @@
{
lib,
outputs,
}: let
hostsNames = builtins.attrNames outputs.nixosConfigurations;
expected = lib.genAttrs hostsNames (_: "aarch64-linux");
in
expected

View File

@@ -0,0 +1,9 @@
{
lib,
outputs,
}:
lib.genAttrs
(builtins.attrNames outputs.nixosConfigurations)
(
name: outputs.nixosConfigurations.${name}.config.boot.kernelPackages.kernel.system
)

View File

@@ -34,12 +34,11 @@
# modules for each supported system
nixosSystems = {
x86_64-linux = import ./x86_64-linux (args // {system = "x86_64-linux";});
# aarch64-linux = import ./aarch64-linux (args // {system = "aarch64-linux";});
aarch64-linux = import ./aarch64-linux (args // {system = "aarch64-linux";});
# riscv64-linux = import ./riscv64-linux (args // {system = "riscv64-linux";});
};
darwinSystems = {
aarch64-darwin = import ./aarch64-darwin (args // {system = "aarch64-darwin";});
x86_64-darwin = import ./x86_64-darwin (args // {system = "x86_64-darwin";});
};
allSystems = nixosSystems // darwinSystems;
allSystemNames = builtins.attrNames allSystems;

View File

@@ -1,30 +0,0 @@
{
lib,
inputs,
...
} @ args: let
inherit (inputs) haumea;
# Contains all the flake outputs of this system architecture.
data = haumea.lib.load {
src = ./src;
inputs = args;
};
# nix file names is redundant, so we remove it.
dataWithoutPaths = builtins.attrValues data;
# Merge all the machine's data into a single attribute set.
outputs = {
darwinConfigurations = lib.attrsets.mergeAttrsList (map (it: it.darwinConfigurations or {}) dataWithoutPaths);
};
in
outputs
// {
inherit data; # for debugging purposes
# NixOS's unit tests.
evalTests = haumea.lib.loadEvalTests {
src = ./tests;
inputs = args // {inherit outputs;};
};
}

View File

@@ -1,36 +0,0 @@
{
# NOTE: the args not used in this file CAN NOT be removed!
# because haumea pass argument lazily,
# and these arguments are used in the functions like `mylib.nixosSystem`, `mylib.colmenaSystem`, etc.
inputs,
lib,
mylib,
myvars,
system,
genSpecialArgs,
...
} @ args: let
name = "harmonica";
modules = {
darwin-modules =
(map mylib.relativeToRoot [
# common
"secrets/darwin.nix"
"modules/darwin"
# host specific
"hosts/darwin-${name}"
])
++ [];
home-modules = map mylib.relativeToRoot [
"hosts/darwin-${name}/home.nix"
"home/darwin"
];
};
systemArgs = modules // args;
in {
# macOS's configuration
darwinConfigurations.${name} = mylib.macosSystem systemArgs;
}

View File

@@ -1,15 +0,0 @@
{
myvars,
lib,
outputs,
}: let
username = myvars.username;
hosts = [
"harmonica"
];
in
lib.genAttrs
hosts
(
name: outputs.darwinConfigurations.${name}.config.home-manager.users.${username}.home.homeDirectory
)

View File

@@ -1,8 +0,0 @@
{
lib,
outputs,
}: let
hostsNames = builtins.attrNames outputs.darwinConfigurations;
expected = lib.genAttrs hostsNames (name: name);
in
expected

View File

@@ -1,9 +0,0 @@
{
lib,
outputs,
}:
lib.genAttrs
(builtins.attrNames outputs.darwinConfigurations)
(
name: outputs.darwinConfigurations.${name}.config.networking.hostName
)

View File

@@ -5,7 +5,6 @@
username = myvars.username;
hosts = [
"ai-hyprland"
"shoukei-hyprland"
"ruby"
"k3s-prod-1-master-1"
];

View File

@@ -6,7 +6,6 @@
username = myvars.username;
hosts = [
"ai-hyprland"
"shoukei-hyprland"
"ruby"
"k3s-prod-1-master-1"
];

View File

@@ -4,7 +4,6 @@
}: let
specialExpected = {
"ai-hyprland" = "ai";
"shoukei-hyprland" = "shoukei";
};
specialHostNames = builtins.attrNames specialExpected;