mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-07-15 00:52:39 +02:00
refactor: Use haumea for filesystem-based module system for flake outputs
refactor: Use hyphen(`-`) for variable names & folder names(except Python), replace all unserscore(`_`) with hyphen(`-`).
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
{
|
||||
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.
|
||||
# unit-tests = haumea.lib.loadEvalTests {
|
||||
# src = ./tests;
|
||||
# inputs = args;
|
||||
# };
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
# 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 = "fern";
|
||||
|
||||
modules = {
|
||||
darwin-modules =
|
||||
(map mylib.relativeToRoot [
|
||||
# common
|
||||
"secrets/darwin.nix"
|
||||
"modules/darwin"
|
||||
# host specific
|
||||
"hosts/darwin-${name}"
|
||||
])
|
||||
++ [];
|
||||
home-module.imports = map mylib.relativeToRoot [
|
||||
"hosts/darwin-${name}/home.nix"
|
||||
"home/darwin"
|
||||
];
|
||||
};
|
||||
|
||||
systemArgs = modules // args;
|
||||
in {
|
||||
# macOS's configuration
|
||||
darwinConfigurations.${name} = mylib.macosSystem systemArgs;
|
||||
}
|
||||
Reference in New Issue
Block a user