nixos-config/modules
Gabriel Arazas 40cca61bbe Update library and custom modules
- Add custom GNOME configurations with dconf keyfiles.
- Refactoring in certain parts of files especially with handling merging
  and importing of modules.
2021-12-02 21:45:49 +08:00
..
themes Update library and custom modules 2021-12-02 21:45:49 +08:00
agenix.nix Update user-specific config 2021-11-29 13:30:57 +08:00
archiving.nix Format the Nix files properly 2021-11-25 21:45:48 +08:00
desktop.nix Format the Nix files 2021-11-29 17:58:02 +08:00
dev.nix Update config and format the files 2021-11-30 09:03:05 +08:00
editors.nix Update user-specific config 2021-11-29 13:30:57 +08:00
README.adoc Update home-manager modules and related configs 2021-11-29 17:56:24 +08:00
users.nix Update library and custom modules 2021-12-02 21:45:49 +08:00

These are the modules to be used for the system configuration. For easier modularization, any user-specific configurations such as from home-manager should be placed in ../users/ directory.

The modules are imported usually through lib.filesToAttr, allowing for easier structuring without modifying the index file of each module (i.e., default.nix). (See the implementation for more details.)

For example, take the following module folder structure…

modules/
├── themes/
│   ├── a-happy-gnome/
│   │   ├── default.nix
│   │   └── README.adoc
│   ├── a-sad-gnome/
│   │   ├── default.nix
│   │   └── README.adoc
│   └── default.nix
├── specific/
│   ├── borg.nix
│   └── prometheus.nix
├── agenix.nix
├── archiving.nix
├── desktop.nix
├── dev.nix
├── editors.nix
└── users.nix

should have the following attribute set.

{
  agenix = path/to/agenix.nix;
  archiving = path/to/archiving.nix;
  desktop = path/to/desktop.nix;
  dev = path/to/dev.nix;
  editors = path/to/editors.nix;
  specific = {
    borg = path/to/specific/borg.nix;
    prometheus = path/to/specific/prometheus.nix;
  };
  themes = path/to/themes; # Since it has a 'default.nix' detected, we're using it instead.
  users = path/to/users.nix;
}

The resulting attribute set can be easily be used for importing. Heres an example of a NixOS system created with the modules which can used for shared configuration between hosts.

lib.nixosSystem {
  system = "x86_64-linux";
  modules = lib.mapAttrsToList (name: path: import path) (lib.filesToAttr ./modules);
}