This repository has been archived on 2024-07-08. You can view files and clone it, but cannot push or open issues or pull requests.
nix-config-tn/docs/monitoring/warnings.md
Truxnell ccd8e800df
Feat: docs (#98)
* hacking at dns

* hack

* hax

* start dics!

* hacking

* feat: docs!

---------

Co-authored-by: Truxnell <9149206+truxnell@users.noreply.github.com>
2024-04-16 05:14:06 +00:00

1.5 KiB

I've added warnings and assertations to code using nix to help me avoid misconfigurations. For example, if a module needs a database enabled, it can abort a deployment if it is not enabled. Similary, I have added warnings if I have disabled backups for production machines.

!!! question "But why, when its not being shared with others?"

Because I guarentee ill somehow stuff it up down the track and accidently disable things I didnt mean to. Roll your eyes, Ill thank myself later.

Learnt from: Nix Manual

Warnings

Warnings will print a warning message duyring a nix build or deployment, but NOT stop the action. Great for things like reminders on disabled features

To add a warning inside a module:

    # Warn if backups are disable and machine isn't a dev box
    config.warnings = [
      (mkIf (!cfg.local.enable && config.mySystem.purpose != "Development")
        "WARNING: Local backups are disabled!")
      (mkIf (!cfg.remote.enable && config.mySystem.purpose != "Development")
        "WARNING: Remote backups are disabled!")
    ];

![Alt text](../includes/assets/no-backup-warning.png)
Oh THATS what I forgot to re-enable...

Abort/assert

Warnings bigger and meaner brother. Stops a nix build/deploy dead in its tracks. Only useful for when deployment is incompatiable with running - i.e. a dependency not met in options.