Skip to content

Instantly share code, notes, and snippets.

@ElvishJerricco
Last active June 26, 2018 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ElvishJerricco/fedfd0df1e0e7e191013af691fba7876 to your computer and use it in GitHub Desktop.
Save ElvishJerricco/fedfd0df1e0e7e191013af691fba7876 to your computer and use it in GitHub Desktop.
{ ... }: {
imports = [./myservice.nix];
services.example-hserv.enable = true;
# Normal configuration.nix stuff here...
}
{ config, pkgs, lib, ... }:
{
# Typically, your module only *sets* options.
# By specifying an `options` field, we are telling it we'd like to make our own options.
options = {
services.example-hserv.enable = lib.mkOption {
description = "Serve the valgrind docs with hserve";
type = lib.types.bool;
default = false;
};
};
# Since we specified `options`, our typical configuration options must now be nested under `config`.
config = {
# `config` refers to the final values of all configuration.
# We can refer to the option that we declared above to get the user's definition.
# We use `mkIf` to only do this configuration when that value is `true`.
systemd.services.example-hserv = lib.mkIf config.services.example-hserv.enable {
description = "Example hserv service";
path = [pkgs.haskellPackages.hserv];
script = ''
(cd ${pkgs.valgrind.doc}/share/doc/valgrind/html && hserv)
'';
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment