mirror of
https://github.com/Jokiller230/puzzlevision.git
synced 2025-09-09 12:20:04 +00:00
🚧 Initial work on generating homeConfigurations output + syntax changes
This commit is contained in:
parent
f139b88c0b
commit
f89cbcc552
12 changed files with 131 additions and 106 deletions
|
@ -1,8 +1,4 @@
|
|||
{
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
{config, ...}: {
|
||||
# Apply some useful module arguments.
|
||||
_module.args = {
|
||||
namespace = config.flake.namespace;
|
||||
|
|
|
@ -11,5 +11,8 @@
|
|||
|
||||
# Automagically imports systems from "/systems/arch-classname/system-name".
|
||||
./systems.nix
|
||||
|
||||
# Automagically imports homes from "/homes/user-name".
|
||||
./homes.nix
|
||||
];
|
||||
}
|
||||
|
|
22
modules/flake/homes.nix
Normal file
22
modules/flake/homes.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
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
|
||||
};
|
||||
}
|
|
@ -2,53 +2,49 @@
|
|||
lib,
|
||||
puzzlelib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
}: let
|
||||
# Utility function to read a directory and return its contents.
|
||||
readDirectory = directory: builtins.readDir directory;
|
||||
|
||||
# Utility function to handle each filesystem entity (file or directory).
|
||||
filesystemEntityToAttrSet = directory: importArgs: name: type:
|
||||
if type == "directory" then
|
||||
dirToAttrSet "${directory}/${name}" importArgs
|
||||
else if name == "default.nix" then
|
||||
import "${directory}/${name}" importArgs
|
||||
else
|
||||
{};
|
||||
if type == "directory"
|
||||
then dirToAttrSet "${directory}/${name}" importArgs
|
||||
else if name == "default.nix"
|
||||
then import "${directory}/${name}" importArgs
|
||||
else {};
|
||||
|
||||
filesystemEntityToList = directory: name: type:
|
||||
if type == "directory" then
|
||||
dirToModuleList "${directory}/${name}"
|
||||
else if name == "default.nix" then
|
||||
[ "${directory}/${name}" ]
|
||||
else
|
||||
[];
|
||||
if type == "directory"
|
||||
then dirToModuleList "${directory}/${name}"
|
||||
else if name == "default.nix"
|
||||
then ["${directory}/${name}"]
|
||||
else [];
|
||||
|
||||
dirToModuleList = directory:
|
||||
let
|
||||
readDir = readDirectory directory;
|
||||
in
|
||||
builtins.foldl' (acc: name:
|
||||
dirToModuleList = directory: let
|
||||
readDir = readDirectory directory;
|
||||
in
|
||||
builtins.foldl' (
|
||||
acc: name:
|
||||
acc ++ (filesystemEntityToList directory name (builtins.getAttr name readDir))
|
||||
) [] (builtins.attrNames readDir);
|
||||
) [] (builtins.attrNames readDir);
|
||||
|
||||
# Utility function to recursively load modules from a directory.
|
||||
dirToAttrSet = directory: importArgs:
|
||||
let
|
||||
# Read provided directory only once at the very start and save the result.
|
||||
readDir = readDirectory directory;
|
||||
in
|
||||
# Iterate over the attr names of a readDir operation.
|
||||
builtins.foldl' (acc: name:
|
||||
# Merge outputs of handling a filesystem entity (file or directory) into accumulator.
|
||||
# Files return attribute sets with their resulting expressions, directories return the result of multiple file handling operations.
|
||||
dirToAttrSet = directory: importArgs: let
|
||||
# Read provided directory only once at the very start and save the result.
|
||||
readDir = readDirectory directory;
|
||||
in
|
||||
# Iterate over the attr names of a readDir operation.
|
||||
builtins.foldl' (
|
||||
acc: name:
|
||||
# Merge outputs of handling a filesystem entity (file or directory) into accumulator.
|
||||
# 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);
|
||||
in
|
||||
{
|
||||
) {} (builtins.attrNames readDir);
|
||||
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; };
|
||||
puzzlelib = dirToAttrSet ../../lib {inherit lib puzzlelib;} // {inherit dirToAttrSet dirToModuleList filesystemEntityToList filesystemEntityToAttrSet;};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,9 +4,8 @@
|
|||
namespace,
|
||||
puzzlelib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [ inputs.easy-hosts.flakeModule ];
|
||||
}: {
|
||||
imports = [inputs.easy-hosts.flakeModule];
|
||||
|
||||
easyHosts = {
|
||||
autoConstruct = true;
|
||||
|
@ -19,11 +18,11 @@
|
|||
};
|
||||
|
||||
perClass = class: {
|
||||
modules = [
|
||||
modules =
|
||||
(lib.optionals (class == "nixos") [
|
||||
inputs.home-manager.nixosModules.default
|
||||
])
|
||||
] ++ (puzzlelib.dirToModuleList ../${class}); # Import modules based on current classname.
|
||||
++ (puzzlelib.dirToModuleList ../${class}); # Import modules based on current classname.
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
2
modules/home/desktop/gnome.nix
Normal file
2
modules/home/desktop/gnome.nix
Normal file
|
@ -0,0 +1,2 @@
|
|||
{}: {
|
||||
}
|
|
@ -3,13 +3,11 @@
|
|||
config,
|
||||
namespace,
|
||||
...
|
||||
}:
|
||||
let
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkIf;
|
||||
cfg = config.${namespace}.desktop.gnome;
|
||||
in
|
||||
{
|
||||
options.${namespace}.desktop.gnome = { enable = mkEnableOption "Enable the gnome desktop environment ${namespace}"; };
|
||||
in {
|
||||
options.${namespace}.desktop.gnome = {enable = mkEnableOption "Enable the gnome desktop environment ${namespace}";};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.xserver.enable = true;
|
||||
|
|
|
@ -4,14 +4,12 @@
|
|||
namespace,
|
||||
puzzlelib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
}: let
|
||||
inherit (lib) mkIf mkMerge;
|
||||
inherit (puzzlelib) mkOpt mkBool;
|
||||
|
||||
cfg = config.${namespace}.utils.vm;
|
||||
in
|
||||
{
|
||||
in {
|
||||
options.${namespace}.utils.vm = {
|
||||
enable = mkBool true "Whether to enable custom vm presets";
|
||||
preset = mkOpt lib.types.str "performance" "Specify the prefered vm settings preset: performance, balance or powersave";
|
||||
|
@ -19,25 +17,28 @@ in
|
|||
|
||||
config = mkIf cfg.enable {
|
||||
virtualisation.vmVariant = mkMerge [
|
||||
(mkIf cfg.preset == "performance" {
|
||||
virtualisation = {
|
||||
cores = 6;
|
||||
memorySize = 4096;
|
||||
graphics = true;
|
||||
};
|
||||
})
|
||||
(mkIf cfg.preset == "balance" {
|
||||
virtualisation = {
|
||||
cores = 4;
|
||||
memorySize = 2048;
|
||||
};
|
||||
})
|
||||
(mkIf cfg.preset == "powersave" {
|
||||
virtualisation = {
|
||||
cores = 2;
|
||||
memorySize = 1024;
|
||||
};
|
||||
})
|
||||
(mkIf cfg.preset
|
||||
== "performance" {
|
||||
virtualisation = {
|
||||
cores = 6;
|
||||
memorySize = 4096;
|
||||
graphics = true;
|
||||
};
|
||||
})
|
||||
(mkIf cfg.preset
|
||||
== "balance" {
|
||||
virtualisation = {
|
||||
cores = 4;
|
||||
memorySize = 2048;
|
||||
};
|
||||
})
|
||||
(mkIf cfg.preset
|
||||
== "powersave" {
|
||||
virtualisation = {
|
||||
cores = 2;
|
||||
memorySize = 1024;
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue