Added status page

This commit is contained in:
Julien Malka 2021-12-26 00:21:23 +01:00
parent 48c36bbd4c
commit a42a771ece
No known key found for this signature in database
GPG key ID: 3C68E13964FEA07F
7 changed files with 88 additions and 0 deletions

View file

@ -30,6 +30,7 @@
rxvt_unicode
xorg.xbacklight
neovim
tinystatus
];
environment.variables.EDITOR = "nvim";

View file

@ -31,6 +31,7 @@
outputs = { self, home-manager, nixpkgs, unstable, sops-nix, neovim-nightly-overlay, nur, ... }@inputs:
let
utils = import ./utils.nix { inherit nixpkgs sops-nix home-manager inputs; nixpkgs-unstable = unstable; };
pkgs = import nixpkgs { system = "x86_64-linux"; };
in
with utils;
{
@ -42,5 +43,6 @@
(builtins.attrNames (builtins.readDir ./modules)));
nixosConfigurations = builtins.mapAttrs (name: value: (mkMachine name value self.nixosModules)) (importConfig ./machines);
packages."x86_64-linux".tinystatus = import ./packages/tinystatus { inherit pkgs; };
};
}

View file

@ -25,6 +25,13 @@
subdomain = "ci";
};
};
status = {
enable = true;
nginx = {
enable = true;
subdomain = "status";
};
};
};
nix.maxJobs = lib.mkDefault 8;

View file

@ -0,0 +1,4 @@
http, 200, Homepage, https://julienmalka.me
http, 200, CI, https://ci.julienmalka.me
ping, 0, Newton, newton.julienmalka.me
1 http 200 Homepage https://julienmalka.me
2 http 200 CI https://ci.julienmalka.me
3 ping 0 Newton newton.julienmalka.me

View file

@ -0,0 +1,48 @@
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.luj.status;
in
{
options.luj.jackett = {
enable = mkEnableOption "activate status page";
nginx.enable = mkEnableOption "activate nginx";
nginx.subdomain = mkOption {
type = types.str;
};
};
config = mkIf cfg.enable (
mkMerge [{
systemd = {
timers.simple-timer = {
wantedBy = [ "timers.target" ];
partOf = [ "tinystatus.service" ];
timerConfig.OnCalendar = "minutely";
};
services.tinystatus = {
serviceConfig.Type = "oneshot";
script = ''
mkdir -p /var/www/status
${pkgs.tinystatus}/bin/tinystatus ${./checks.csv} > /var/www/status/index.html
'';
};
};
}
(mkIf cfg.nginx.enable {
luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
root = "/var/www/status/";
};
})]);
}

View file

@ -0,0 +1,25 @@
{ pkgs, ... }:
with pkgs;
stdenv.mkDerivation rec {
pname = "tinystatus";
version = "1.0.0";
src = fetchFromGitHub{
owner = "bderenzo";
repo = "tinystatus";
rev="fc128adf240261ac99ea3e3be8d65a92eda52a73";
sha256= "FvQwibm6F10l9/U3RnNTGu+C2JjHOwbv62VxXAfI7/s=";
};
postPatch = ''
patchShebangs .
'';
installPhase = ''
mkdir -p $out/bin/
mv tinystatus $out/bin/
'';
}

View file

@ -25,6 +25,7 @@ in
overlay-unstable
(final: prev:
{
tinystatus = prev.pkgs.callPackage ./packages/tinystatus {};
mosh = prev.mosh.overrideAttrs (old: {
patches = (prev.lib.take 1 old.patches) ++ (prev.lib.sublist 4 4 old.patches);
postPatch = '''';