mirror of
https://github.com/Jokiller230/puzzlevision.git
synced 2025-02-07 11:43:06 +01:00
✨ (modules/flake) implement recursively loaded libraries
This commit is contained in:
parent
e54b87a835
commit
c322461fe1
4 changed files with 56 additions and 2 deletions
|
@ -16,7 +16,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs@{ flake-parts, ... }:
|
outputs = { flake-parts, ... }@inputs:
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
debug = true;
|
debug = true;
|
||||||
|
|
||||||
|
|
16
lib/module/default.nix
Normal file
16
lib/module/default.nix
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
## Create a NixOS module option as a one-liner.
|
||||||
|
##
|
||||||
|
## ```nix
|
||||||
|
## lib.mkOpt nixpkgs.lib.types.str "My default" "Option description"
|
||||||
|
## ```
|
||||||
|
##
|
||||||
|
#@ Type -> Any -> String
|
||||||
|
mkOpt =
|
||||||
|
type: default: description:
|
||||||
|
lib.mkOption { inherit type default description; };
|
||||||
|
}
|
|
@ -1,13 +1,44 @@
|
||||||
{
|
{
|
||||||
|
lib,
|
||||||
inputs,
|
inputs,
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
# Recursive function to load all `default.nix` files and merge them into a single attr. set
|
||||||
|
loadLibs = directory:
|
||||||
|
builtins.foldl' (acc: name:
|
||||||
|
let
|
||||||
|
path = "${directory}/${name}";
|
||||||
|
isDir = (builtins.getAttr name (builtins.readDir directory)) == "directory";
|
||||||
|
in
|
||||||
|
if isDir then
|
||||||
|
lib.mergeAttrs acc (loadLibs path)
|
||||||
|
else if name == "default.nix" then
|
||||||
|
lib.mergeAttrs acc (import path { inherit lib; })
|
||||||
|
else
|
||||||
|
acc
|
||||||
|
) {} (builtins.attrNames (builtins.readDir directory));
|
||||||
|
in
|
||||||
{
|
{
|
||||||
# Overwrite and add new arguments to all flake modules.
|
# Overwrite and add new arguments to all flake modules.
|
||||||
_module.args = {
|
_module.args = {
|
||||||
namespace = config.flake.namespace;
|
namespace = config.flake.namespace;
|
||||||
|
|
||||||
|
## Recursive loading of libraries, similar to snowfall lib.
|
||||||
|
## Logical flow: read files => merge all file outputs to single attr. set
|
||||||
|
## The directory in question is flake-root => lib
|
||||||
|
## The directory structure is:
|
||||||
|
## lib/
|
||||||
|
## => libname
|
||||||
|
## => default.nix
|
||||||
|
## => libname2
|
||||||
|
## => default.nix
|
||||||
|
##
|
||||||
|
## The structure of multiple libs is simply for organization and the attrs. of all default.nix files should still be merged
|
||||||
|
## into a single set.
|
||||||
|
puzzlelib = loadLibs ../../lib;
|
||||||
|
|
||||||
# Initialize nixpkgs instance with custom overlays.
|
# Initialize nixpkgs instance with custom overlays.
|
||||||
pkgs = import inputs.nixpkgs {
|
pkgs = import inputs.nixpkgs {
|
||||||
overlays = [
|
overlays = [
|
||||||
|
|
|
@ -7,6 +7,13 @@
|
||||||
./hardware.nix
|
./hardware.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
virtualisation.vmVariant = {
|
||||||
|
virtualisation = {
|
||||||
|
cores = 6;
|
||||||
|
memorySize = 2048;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
# Todo: pass a set of users to enable from within easy-hosts and automatically map the corresponding home-manager configurations
|
# Todo: pass a set of users to enable from within easy-hosts and automatically map the corresponding home-manager configurations
|
||||||
# ${namespace} = {
|
# ${namespace} = {
|
||||||
# mainUser = "jo";
|
# mainUser = "jo";
|
||||||
|
@ -18,7 +25,7 @@
|
||||||
|
|
||||||
# Enable Plasma6
|
# Enable Plasma6
|
||||||
services.xserver.enable = true;
|
services.xserver.enable = true;
|
||||||
services.displayManager.sddm.wayland.enable = true;
|
services.displayManager.sddm.enable = true;
|
||||||
services.desktopManager.plasma6.enable = true;
|
services.desktopManager.plasma6.enable = true;
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
|
|
Loading…
Reference in a new issue