finalize home configuration loading as nixos module, and more stuffs :3

This commit is contained in:
Jo 2025-04-24 03:01:52 +02:00
parent f89cbcc552
commit dc87b2c186
16 changed files with 192 additions and 87 deletions

View file

@ -1,6 +0,0 @@
{config, ...}: {
# Apply some useful module arguments.
_module.args = {
namespace = config.flake.namespace;
};
}

View file

@ -1,18 +1,18 @@
{
imports = [
# Applies some useful arguments, like namespace, to all flake modules.
./arguments.nix
# Exposes nixosModules and homeModules on flake outputs.
./modules.nix
# Automagically imports libs from "/lib/lib-name" and applies them to the `lib.${namespace}` or `puzzlevision.lib` module argument.
# Automagically imports libs from "/lib/lib-name" and exposes them to the `flake.lib` output.
./lib.nix
# Recursively imports overlays from "/overlays/overlay-name" and applies them to the `pkgs` or `puzzlevision.pkgs` module argument.
# ./overlays.nix
# Recursively imports overlays from "/overlays/overlay-name" and exposes them to the `flake.overlays` output.
#./overlays.nix
# Automagically imports systems from "/systems/arch-classname/system-name".
./systems.nix
# Automagically imports homes from "/homes/user-name".
./homes.nix
#./homes.nix
];
}

View file

@ -1,22 +0,0 @@
{
lib,
inputs,
puzzlelib,
...
}: let
HomeConfiguration = args: let
nixpkgs = inputs.nixpkgs;
in
inputs.home-manager.lib.homeManagerConfiguration {
modules = (puzzlelib.dirToModuleList ../home) ++ args.modules;
extraSpecialArgs =
{
inherit (args) nixpkgs;
}
// args.extraSpecialArgs;
};
in {
perSystem = {
# TODO Dynamically export homeConfigurations by consuming contents of /homes/user-name
};
}

View file

@ -1,6 +1,6 @@
{
lib,
puzzlelib,
self,
...
}: let
# Utility function to read a directory and return its contents.
@ -41,10 +41,9 @@
# Files return attribute sets with their resulting expressions, directories return the result of multiple file handling operations.
acc // (filesystemEntityToAttrSet directory importArgs name (builtins.getAttr name readDir))
) {} (builtins.attrNames readDir);
puzzlelib = dirToAttrSet ../../lib {inherit lib self;} // {inherit dirToAttrSet dirToModuleList filesystemEntityToList filesystemEntityToAttrSet;};
in {
# Add lib.${namespace} attribute to module arguments, for easy access.
# Additionally, pass on dirToAttrSet method on lib.${namespace} for reusability in other modules.
_module.args = {
puzzlelib = dirToAttrSet ../../lib {inherit lib puzzlelib;} // {inherit dirToAttrSet dirToModuleList filesystemEntityToList filesystemEntityToAttrSet;};
};
# Expose custom library on flake "lib" output
flake.lib = puzzlelib;
}

14
modules/flake/modules.nix Normal file
View file

@ -0,0 +1,14 @@
{ self, ... }:
{
flake = {
nixosModules.puzzlevision = self.lib.mkModule {
class = "nixos";
modules = self.lib.dirToModuleList ../nixos;
};
homeModules.puzzlevision = self.lib.mkModule {
class = "home";
modules = self.lib.dirToModuleList ../home;
};
};
}

View file

@ -1,28 +1,21 @@
{
lib,
inputs,
namespace,
puzzlelib,
self,
...
}: {
imports = [inputs.easy-hosts.flakeModule];
imports = [ inputs.easy-hosts.flakeModule ];
easyHosts = {
autoConstruct = true;
path = ../../systems;
shared = {
specialArgs = {
inherit namespace puzzlelib;
};
};
perClass = class: {
modules =
(lib.optionals (class == "nixos") [
inputs.home-manager.nixosModules.default
])
++ (puzzlelib.dirToModuleList ../${class}); # Import modules based on current classname.
++ (self.lib.dirToModuleList ../${class}); # Import modules based on current classname.
};
};
}