refactor: move modules to their own dir

This commit is contained in:
Jalil David Salamé Messina 2025-03-16 16:10:02 +01:00
parent dda72854df
commit addf563bfc
Signed by: jalil
GPG key ID: F016B9E770737A0B
26 changed files with 86 additions and 60 deletions

View file

@ -5,17 +5,18 @@
{ {
packages = packages =
let let
modules = ../modules;
filterVisible = filterVisible =
toplevelOption: option: toplevelOption: option:
option // { visible = option.visible && builtins.elemAt option.loc 0 == toplevelOption; }; option // { visible = option.visible && builtins.elemAt option.loc 0 == toplevelOption; };
home-eval = lib.evalModules { home-eval = lib.evalModules {
modules = [ ../home/options.nix ]; modules = [ (modules + "/hm/options.nix") ];
specialArgs = { specialArgs = {
inherit pkgs; inherit pkgs;
}; };
}; };
nvim-eval = lib.evalModules { modules = [ ../nvim/options.nix ]; }; nvim-eval = lib.evalModules { modules = [ (modules + "/nixvim/options.nix") ]; };
nixos-eval = lib.evalModules { modules = [ ../system/options.nix ]; }; nixos-eval = lib.evalModules { modules = [ (modules + "/nixos/options.nix") ]; };
home-markdown = home-markdown =
(pkgs.nixosOptionsDoc { (pkgs.nixosOptionsDoc {
inherit (home-eval) options; inherit (home-eval) options;

View file

@ -1,45 +1,82 @@
{ inputs, lib, ... }:
{ {
flake.nixosModules = self,
let inputs,
nvim-config = { lib,
imports = [ ...
inputs.nixvim.homeManagerModules.nixvim }:
../nvim let
]; modules = ../modules;
}; in
homeManagerModuleSandalone = import ../home { {
inherit nvim-config; flake = {
inherit (inputs) stylix; nixvimModules =
}; let
homeManagerModuleNixOS = import ../home { inherit nvim-config; }; standalone = modules + "/nixvim/standalone.nix";
nixosModule = { homeManager = {
imports = [ imports = [
(import ../system { inherit (inputs) stylix; }) inputs.nixvim.homeManagerModules.nixvim
inputs.home-manager.nixosModules.home-manager (modules + "/nixvim")
] ++ lib.optional (inputs.lix-module != null) inputs.lix-module.nixosModules.default; ];
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
sharedModules = [ homeManagerModuleNixOS ];
}; };
# Pin nixpkgs in
nix.registry.nixpkgs.flake = inputs.nixpkgs; {
inherit standalone homeManager;
}; };
homeManagerModules =
machines = [ "vm" ]; let
mkMachine = hostname: { defaultModules = [
imports = [ self.nixvimModules.homeManager
nixosModule (modules + "/hm")
(import (../machines + "/${hostname}"))
]; ];
home-manager.sharedModules = [ { jhome.hostName = hostname; } ]; nixos = {
imports = defaultModules;
};
standalone = {
imports = defaultModules ++ [
inputs.stylix.homeManagerModules.stilyx
(
{ config, ... }:
{
stylix.image = config.jhome.sway.background;
}
)
];
};
in
{
inherit standalone nixos;
}; };
machineModules = lib.genAttrs machines mkMachine; nixosModules =
in let
{ nixosModule = {
default = nixosModule; imports = [
inherit nixosModule homeManagerModuleNixOS homeManagerModuleSandalone; inputs.stylix.nixosModules.stylix
} inputs.home-manager.nixosModules.home-manager
// machineModules; (modules + "/nixos")
] ++ lib.optional (inputs.lix-module != null) inputs.lix-module.nixosModules.default;
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
sharedModules = [ self.homeManagerModules.nixos ];
};
# Pin nixpkgs
nix.registry.nixpkgs.flake = inputs.nixpkgs;
};
machines = [ "vm" ];
mkMachine = hostname: {
imports = [
nixosModule
(import (../machines + "/${hostname}"))
];
home-manager.sharedModules = [ { jhome.hostName = hostname; } ];
};
machineModules = lib.genAttrs machines mkMachine;
in
{
default = nixosModule;
inherit nixosModule;
}
// machineModules;
};
} }

View file

@ -9,7 +9,7 @@
nvimModule = extraConfig: { nvimModule = extraConfig: {
pkgs = inputs.unstable.legacyPackages.${system}; pkgs = inputs.unstable.legacyPackages.${system};
module = { module = {
imports = [ ../nvim/standalone.nix ]; imports = [ ../modules/nixvim/standalone.nix ];
config = lib.mkMerge [ config = lib.mkMerge [
{ performance.combinePlugins.enable = true; } { performance.combinePlugins.enable = true; }
extraConfig extraConfig

View file

@ -1,7 +1,3 @@
{
nvim-config,
stylix ? null,
}:
{ {
config, config,
pkgs, pkgs,
@ -17,17 +13,11 @@ let
path: default: if osConfig == null then default else lib.attrsets.attrByPath path default osConfig; path: default: if osConfig == null then default else lib.attrsets.attrByPath path default osConfig;
in in
{ {
imports = imports = [
[ ./options.nix
nvim-config ./gui
./options.nix ./users.nix
./gui ];
./users.nix
]
++ lib.optionals (stylix != null) [
stylix.homeManagerModules.stylix
{ stylix.image = cfg.sway.background; }
];
config = lib.mkMerge [ config = lib.mkMerge [
(lib.mkIf (cfg.enable && cfg.styling.enable) { (lib.mkIf (cfg.enable && cfg.styling.enable) {

View file

@ -1,4 +1,3 @@
{ stylix }:
{ {
config, config,
pkgs, pkgs,
@ -22,7 +21,6 @@ in
imports = [ imports = [
./options.nix ./options.nix
./gui ./gui
stylix.nixosModules.stylix
{ stylix = import ./stylix-config.nix { inherit config pkgs; }; } { stylix = import ./stylix-config.nix { inherit config pkgs; }; }
]; ];