mirror of
https://codeberg.org/privacy1st/nix-git
synced 2024-12-23 02:36:05 +01:00
50 lines
1.3 KiB
Nix
50 lines
1.3 KiB
Nix
|
# 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".
|
||
|
};
|
||
|
}
|