Add a function to interpret nonstandard modules
diff --git a/README.md b/README.md
index 8f2f30a..0c54eb5 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,24 @@
#### Configuration format
+
This is a group of NixOS modules that control user and system configuration for
a single-user machine. In order to avoid confusion with other modules, all
user-facing options that I provide will be under the namespace `minion.` and all
internal options that I provide will be under the namespace `internal.`
+#### Directory usages
+
+| Directory | Description |
+| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| `modules` | modules, used to provide user-facing options and configuration |
+| `internal` | internal modules, used to provide configuration-agnostic options to user-facing modules. These should do nothing unless they are triggered by a user-facing module setting an option |
+| `utils` | internal utilities for writing these modules; intended to be imported by nix files in here, and probably nothing else. These may be refactored into another repo at some point |
+| `overlays` | package overlays, each in files named with the package they are intended to overlay |
+| `patches` | patch files, each in a directory named with the package that they are intended to patch |
+| `packages` | package expressions, each named with the package they wish to occupy |
+| `switching` | a program for switching on and off options, as well as rebuilding the configuration. Currently A WIP |
+
+##### Modules
+
All files directly under `/modules/` will be `.nix` modules, and related files
(such as assets) may be contained in `/modules/name/` (where `name` is the name
of the module with the `.nix` extension omitted). Similarly, any options the
@@ -13,24 +28,22 @@
directory. Some modules with stricter layouts may decide to keep a README in
their assets directory to ensure a standard is kept.
-These are *not* standard NixOS modules, in that they can have some extra
+These are _not_ standard NixOS modules, in that they can have some extra
properties outside of the traditional `imports`, `options`, and `config`, and
-these properties *will not be* treated as config. These properties are described
+these properties _will not be_ treated as config. These properties are described
below.
-##### Additional options
-| Options | Type | Description |
-| --- | --- | --- |
-| `home` | home-manager configuration | configuration that will be used for the
-home-manager user; will also be passed as the variable `home` to your modules |
+###### Additional properties
-#### Special directories
+| Options | Type | Description |
+| ------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------- |
+| `home` | home-manager configuration | configuration that will be used for the home-manager user; will also be passed as the variable `home` to your modules |
-
-#### Licensing Unless otherwise specified, all files in this repo while this
-message is in the readme were written or otherwise created by me, Skyler Grey,
-and are released under [GNUAGPLv3](https://www.gnu.org/licenses/agpl-3.0.html).
-A full copy of this license may be found at the provided URL or in [the license
+#### Licensing
+Unless otherwise specified, all files in this repo while this message is in the
+readme were written or otherwise created by me, Skyler Grey, and are released
+under [GNUAGPLv3](https://www.gnu.org/licenses/agpl-3.0.html). A full copy of
+this license may be found at the provided URL or in [the license
file](./LICENSE).
Despite the licensing, only the files in this repo are licensed. This config
diff --git a/utils/interpretNonstandardModule.nix b/utils/interpretNonstandardModule.nix
new file mode 100644
index 0000000..533cf6c
--- /dev/null
+++ b/utils/interpretNonstandardModule.nix
@@ -0,0 +1,30 @@
+# As our modules have nonstandard properties, we need to have some way of
+# properly intepreting them
+# This function takes a list of modules, as well as arguments to import them
+# with, and returns a list of modules, each with the standard NixOS module
+# properties as well as with custom properties as described in /README.md
+modules: args: let
+ resolver = module: let
+ importedModule =
+ if builtins.typeOf module == "path"
+ then import module
+ else module;
+ resolvedModule =
+ if builtins.typeOf importedModule == "lambda"
+ then
+ resolvedModule
+ args
+ else resolvedModule;
+ in {
+ home = module.home or {};
+ module = {
+ module.config or {};
+ module.imports or {};
+ module.options or {};
+ };
+ };
+in (
+ if modules.typeOf == "list"
+ then builtins.map resolver modules
+ else (resolver modules)
+)