Minimal example clan service that greets the world
This service is for demonstration purpose only and may change in the future.
The Hello-World Clan Service is a minimal example showing how to build and register your own service.
It serves as a reference implementation and is used in clan-core CI tests to ensure compatibility.
This service demonstrates two levels of testing to ensure quality and stability across releases:
nix-unitWe highly advocate following the Practical Testing Pyramid:
NixOS is untyped and frequently changes; tests are the safest way to ensure long-term stability of services.
/ \
/ \
/ E2E \
/-------\
/ \
/Integration\
/-------------\
/ \
/ Unit Tests \
------------------- We highly advocate the usage of
Example in: tests/eval-tests.nix
If you use flake-parts you can use the native integration
If nix-unit succeeds, your NixOS evaluation should be mostly correct.
The testing system around vars is experimental
clanTest is still experimental and enables container virtualization by default.
This is still early and might have some limitations.
Some minimal boilerplate is needed to use clanTest
nixosLib = import (inputs.nixpkgs + "/nixos/lib") { }
nixosLib.runTest (
{ ... }:
{
imports = [
self.modules.nixosTest.clanTest
# Example in tests/vm/default.nix
testModule
];
hostPkgs = pkgs;
# Uncomment if you don't want or cannot use containers
# test.useContainers = false;
}
) The hello-world service has the following roles:
evening roleThe greeting to use
Type: string
Default:
"Good evening" Declared in: clanServices/hello-world/default.nix
morning roleThe greeting to use
Type: string
Default:
"Good morning" Declared in: clanServices/hello-world/default.nix