diff --git a/examples/module.nix b/examples/module.nix new file mode 100644 index 0000000..faac340 --- /dev/null +++ b/examples/module.nix @@ -0,0 +1,49 @@ +# https://nixos.wiki/wiki/NixOS_modules + +# This module can be used as follows: +# { +# imports = [ ./module.nix ]; +# services.example = { +# enable = true; +# message = "Hello :)"; +# }; +# } + +{ lib, config, options, pkgs, modulesPath, ... }: +with lib; +let + # cfg is a typical convention. + cfg = config.services.example; +in +{ + imports = [ + # Paths to other modules. + # Compose this module out of smaller ones. + ]; + + options = { + # Option declarations. + # Declare what settings a user of this module module can set. + # Usually this includes an "enable" option to let a user of this module choose. + + services.example = { + enable = mkEnableOption "example service"; + message = mkOption { + type = types.str; + default = "Hello, world!"; + example = "Hi!"; + # A textual description of the option, in DocBook format. + description = '' + You can set any message you want here. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + # Option definitions. + # Define what other settings, services and resources should be active. + # These are depend on whether a user of this module chose to "enable" it using the "option" above. + # You also set options here for modules that you imported in "imports". + }; +} diff --git a/examples/systemd-timer-example.nix b/examples/systemd-timer.nix similarity index 100% rename from examples/systemd-timer-example.nix rename to examples/systemd-timer.nix