{"id":26743016,"url":"https://github.com/psub/phare-nix","last_synced_at":"2025-09-13T19:46:45.080Z","repository":{"id":284838249,"uuid":"954294523","full_name":"pSub/phare-nix","owner":"pSub","description":"NixOS module for phare.io monitor declarations","archived":false,"fork":false,"pushed_at":"2025-09-04T08:04:11.000Z","size":59,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-04T10:24:54.569Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://phare-nix.quine.de/nixos-options/","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pSub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-24T21:30:03.000Z","updated_at":"2025-09-04T08:04:15.000Z","dependencies_parsed_at":"2025-04-12T22:20:15.897Z","dependency_job_id":"0487d033-06ca-4271-8bc7-a972e7fa9dbe","html_url":"https://github.com/pSub/phare-nix","commit_stats":null,"previous_names":["psub/phare-nix"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pSub/phare-nix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pSub%2Fphare-nix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pSub%2Fphare-nix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pSub%2Fphare-nix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pSub%2Fphare-nix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pSub","download_url":"https://codeload.github.com/pSub/phare-nix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pSub%2Fphare-nix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275020167,"owners_count":25391650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-28T06:33:45.285Z","updated_at":"2025-09-13T19:46:45.054Z","avatar_url":"https://github.com/pSub.png","language":"Nix","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Documentation](https://img.shields.io/badge/Documentation-Online-green)](https://phare-nix.quine.de/nixos-options/)\n\n# phare-nix\nA NixOS module for [phare.io](https://phare.io) monitor declarations.\n\n## Motivation\nNixOS provides you with tools to setup a web-service in a simple manner\nand even takes care of SSL certificates for you. This module extends\nthe capabilities to monitoring web-services. You no longer have to\nclick through a web-interface each time you create / modify a web-service,\nbut instead turn on monitoring for a web-service by flicking a switch. As\nthere is (to my knowledge) no standardized API for monitoring, this module\nuses the monitoring service [phare.io](https://phare.io).\n\n## Installation\n\u003e [!NOTE]  \n\u003e This NixOS module requires [flakes](https://wiki.nixos.org/wiki/Flakes).\n\nInstallation is straightforward and does not differ from other flakes. A\nbasic flake with phare-nix cloud look like this:\n\n``` nix\n{\n  inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;\n  inputs.phare-nix.url = github:pSub/phare-nix;\n  outputs = { self, nixpkgs }: {\n    nixosConfigurations.some-server = nixpkgs.lib.nixosSystem {\n      modules = [\n          ./configuration.nix\n          phare-nix.nixosModules.phare\n      ];\n    };\n  };\n}\n```\n\n## Usage\n\nThe following code snippet demonstrates how you can use the `phare-nix` module in\nyour configuration.\n\n``` nix\nservices.phare = {\n    enable = true; # enables the script that interacts with phare.io\n    tokenFile = \"/run/secrets/phare-token\"; # path to a file containing the API token\n    alertPolicyId = 1234; # default alert-policy-id for monitors\n    regions = [ \"eu-deu-fra\" ]; # default regions for monitors\n\n    # the attribute sets for this option are converted to JSON and send to the phare.io\n    # API, therefor you can use all fields provided by the phare.io API.\n    # Note: The Nix option names are in camel case and are converted to snake case before\n    # they are sent to phare.io.\n    monitors = {\n        tcp-monitor = { # name of the monitor\n            protocol = \"tcp\";\n            request = {\n                host = \"example.org\";\n                port = \"22\";\n            };\n        }\n        \n        http-monitor = {\n            protocol = \"http\";\n            request = {\n                url = \"https://example.org\";\n                method = \"GET\";\n                keyword = \"pong\";\n            };\n        };\n    };\n}\n\nservices.nginx.virtualHosts.\"example.org\" = {\n    # This option will generate a http-monitor for the virtual host. Depending on whether\n    # forceSSL or addSSL is enabled for the virtual host the url for the monitor uses https.\n    enablePhare = true;\n    \n    # You can overwrite each attribute of the monitor configuration.\n    phare = {\n        request = {\n            url = \"example.org/redirect\";\n            method = \"GET\";\n        }\n    };\n};\n```\n\nYou can find the documentation of all available options at [phare-nix.quine.de/nixos-options](https://phare-nix.quine.de/nixos-options/).\n\nOnce you rebuild your system (eg. with `nixos-rebuiold`) the configuration of the monitors is\napplied by a systemd service to phare.io. Depending on the state of phare.io different actions are performed:\n\n- If there is a monitor in your configuration but not on phare.io, then the monitor created on phare.io.\n- If there is a monitor in your configuration and on phare.io, then the monitor is updated on phare.io.\n- If there is a monitor in your configuration but paused on phare.io, then the monitor is resumed on phare.io.\n- If there is a monitor on phare.io but not in your configuration, then the monitor is paused on phare.io.\n\nThe test on whether there is a monitor on phare.io or not is done using the name of the monitor.\n\nYou can find the phare.io API documentation at https://docs.phare.io/api-reference/introduction.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsub%2Fphare-nix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsub%2Fphare-nix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsub%2Fphare-nix/lists"}