Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrVanDalo/nixos-healthchecks
Write health checks as NixOS options to quickly verify if your services are properly running.
https://github.com/mrVanDalo/nixos-healthchecks
flake-parts healthchecks nixos
Last synced: 5 days ago
JSON representation
Write health checks as NixOS options to quickly verify if your services are properly running.
- Host: GitHub
- URL: https://github.com/mrVanDalo/nixos-healthchecks
- Owner: mrVanDalo
- License: mit
- Created: 2024-09-30T02:54:12.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-24T04:41:01.000Z (2 months ago)
- Last Synced: 2024-12-22T23:04:12.806Z (13 days ago)
- Topics: flake-parts, healthchecks, nixos
- Language: Nix
- Homepage:
- Size: 333 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - mrVanDalo/nixos-healthchecks - Write health checks as NixOS options to quickly verify if your services are properly running. (Nix)
- awesome-starred - mrVanDalo/nixos-healthchecks - Write health checks as NixOS options to quickly verify if your services are properly running. (Nix)
README
# NixOS health checks
NixOS flake to write health checks as options, intended to be written right next
to the service definitions to verify right after deployment or whenever you like
if your services are running correctly.![](example.gif)
## How to define checks
You can define checks using the (newly introduced) `healthchecks`
[NixOS Option](https://search.nixos.org/options).### Check the http responses
```nix
healthchecks.http.nextcloud = {
url = "https://example.com/login";
expectedContent = "Login";
};
```### check if a port is actually closed
```nix
healthchecks.closed.public.host = "example.com";
healthchecks.closed.public.ports.opentelemetry = [ 4317 ];
```### custom command
```nix
healthchecks.localCommand.bashTest = pkgs.writers.writeBash "test" ''
echo "this is a bash test"
'';
healthchecks.localCommand.pythonTest = pkgs.writers.writePython "test" {} ''
print("this is a python test")
'';
```**Failure** or **Success** is decided on **exit code** of the script. The output
of the command will only be printed if the **exit code** is not 0.## How to set up with flake parts
You have to import the `healthchecks.flakeModule` and the
`healthchecks.nixosModules.default`.```nix
{inputs = {
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
flake-parts.url = "github:hercules-ci/flake-parts";
healthchecks.inputs.nixpkgs.follows = "nixpkgs";
healthchecks.url = "github:mrvandalo/nixos-healthchecks";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};outputs =
inputs@{
flake-parts,
healthchecks,
nixpkgs,
self,
}:flake-parts.lib.mkFlake { inherit inputs; } (
{ }:
{
systems = [ "x86_64-linux" ]; # feel free to use other systems# 1. import healthchecks flakeModule
imports = [ healthchecks.flakeModule ];flake = {
nixosConfigurations.example = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./configuration.nix
# 2. import healthchecks nixosModule
healthchecks.nixosModules.default
];
};
};
}
);
}
```