diff --git a/lib/default.nix b/lib/default.nix index bff242e2..1694b51f 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -110,6 +110,9 @@ rec { invalidUsernames = [ "config" "modules" ]; in lib.filterAttrs (n: _: !lib.elem n invalidUsernames) userModules; + # Return the path of `secrets` from `../secrets`. + getSecret = path: ../secrets/${path}; + /* Create an attribute set from two lists (or a zip). Examples: diff --git a/modules/README.adoc b/modules/README.adoc index b869d120..6746f8ed 100644 --- a/modules/README.adoc +++ b/modules/README.adoc @@ -1,22 +1,71 @@ = Modules :toc: -This directory contains modules for different components such as link:https://nixos.org/manual/nixos/stable/index.html#sec-writing-modules[NixOS modules] and link:https://github.com/nix-community/home-manager/[home-manager modules]. +These are various modules ranging from link:https://nixos.org/manual/nixos/stable/index.html#sec-writing-modules[NixOS modules] and link:https://github.com/nix-community/home-manager[home-manager] modules. +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... +[source, tree] +---- +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 +---- -== Importing the modules - -Usually, you'll see no `default.nix` in place since it is imported through other means. -One of the most common way is through `filesToAttr` defined in link:../lib[my custom library]. - -For example, to easily get a list of imported custom NixOS modules, here's one way with the custom library. +...should have the following attribute set. [source, nix] ---- -lib.map (path: import path) (lib.modulesToList (lib.filesToAttr ./modules/nixos)) +{ + 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; +} ---- -Each modules may have to be imported differently. -Please see the respective documentation (i.e., `man:configuration.nix(5)`, `man:home-configuration.nix` ) for more details. +The resulting attribute set can be easily be used for importing. +Here's an example of a NixOS system created with the modules which can used for shared configuration between hosts. + +[source, nix] +---- +lib.nixosSystem { + system = "x86_64-linux"; + modules = lib.mapAttrsToList (name: path: import path) (lib.filesToAttr ./modules); +} +---- + + + + +== Flake outputs + +Various modules are then exported to the project flake as the following output: + +* `nixosModules` exports modules from link:./nixos/[`./nixos/`]. +* `homeManagerModules` exports modules from link:./home-manager/[`./home-manager/`]. diff --git a/modules/home-manager/bleachbit.nix b/modules/home-manager/bleachbit.nix index b7e4dd3d..c0a4e2f0 100644 --- a/modules/home-manager/bleachbit.nix +++ b/modules/home-manager/bleachbit.nix @@ -80,8 +80,11 @@ in { Unit = { Description = "Periodic clean with Bleachbit"; Documentation = [ "man:bleachbit(1)" "https://www.bleachbit.org" ]; + PartOf = [ "default.target" ]; }; + Install.WantedBy = [ "default.target" ]; + Timer = { OnCalendar = cfg.dates; Persistent = cfg.persistent; diff --git a/modules/nixos/README.adoc b/modules/nixos/README.adoc deleted file mode 100644 index 6746f8ed..00000000 --- a/modules/nixos/README.adoc +++ /dev/null @@ -1,71 +0,0 @@ -= Modules -:toc: - -These are various modules ranging from link:https://nixos.org/manual/nixos/stable/index.html#sec-writing-modules[NixOS modules] and link:https://github.com/nix-community/home-manager[home-manager] modules. - -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... - -[source, tree] ----- -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. - -[source, nix] ----- -{ - 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. -Here's an example of a NixOS system created with the modules which can used for shared configuration between hosts. - -[source, nix] ----- -lib.nixosSystem { - system = "x86_64-linux"; - modules = lib.mapAttrsToList (name: path: import path) (lib.filesToAttr ./modules); -} ----- - - - - -== Flake outputs - -Various modules are then exported to the project flake as the following output: - -* `nixosModules` exports modules from link:./nixos/[`./nixos/`]. -* `homeManagerModules` exports modules from link:./home-manager/[`./home-manager/`]. diff --git a/modules/nixos/desktop.nix b/modules/nixos/desktop.nix index bae98ff5..04fcbee6 100644 --- a/modules/nixos/desktop.nix +++ b/modules/nixos/desktop.nix @@ -95,9 +95,6 @@ in { # Enable tablet support with OpenTabletDriver. hardware.opentabletdriver.enable = true; - # More power optimizations! - powerManagement.powertop.enable = true; - # Welp, this is surprising... services.printing.enable = true; })