forked from DGNum/stateless-uptime-kuma
style: format
This commit is contained in:
parent
0c6aa5730a
commit
4537c86d4d
6 changed files with 86 additions and 74 deletions
24
default.nix
24
default.nix
|
@ -1,6 +1,7 @@
|
||||||
{ sources ? import ./npins
|
{
|
||||||
, nixpkgs ? sources.nixpkgs
|
sources ? import ./npins,
|
||||||
, pkgs ? import nixpkgs { overlays = [ (import ./overlay.nix) ]; }
|
nixpkgs ? sources.nixpkgs,
|
||||||
|
pkgs ? import nixpkgs { overlays = [ (import ./overlay.nix) ]; },
|
||||||
}:
|
}:
|
||||||
rec {
|
rec {
|
||||||
shell = pkgs.mkShell {
|
shell = pkgs.mkShell {
|
||||||
|
@ -9,13 +10,22 @@ rec {
|
||||||
pkgs.ruff
|
pkgs.ruff
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
python = pkgs.python3.withPackages (ps: [ ps.mypy ps.click ps.click-log ps.uptime-kuma-api ]);
|
python = pkgs.python3.withPackages (ps: [
|
||||||
evalModules = (pkgs.lib.evalModules {
|
ps.mypy
|
||||||
|
ps.click
|
||||||
|
ps.click-log
|
||||||
|
ps.uptime-kuma-api
|
||||||
|
]);
|
||||||
|
evalModules =
|
||||||
|
(pkgs.lib.evalModules {
|
||||||
modules = [
|
modules = [
|
||||||
./nixos/module.nix
|
./nixos/module.nix
|
||||||
({ lib, ... }: {
|
(
|
||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
_module.args.pkgs = lib.mkDefault pkgs;
|
_module.args.pkgs = lib.mkDefault pkgs;
|
||||||
})
|
}
|
||||||
|
)
|
||||||
];
|
];
|
||||||
}).extendModules;
|
}).extendModules;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
probesFormat = pkgs.formats.json {};
|
probesFormat = pkgs.formats.json { };
|
||||||
cfg = config.statelessUptimeKuma;
|
cfg = config.statelessUptimeKuma;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -13,15 +18,15 @@ in
|
||||||
probesConfig = {
|
probesConfig = {
|
||||||
monitors = lib.mkOption {
|
monitors = lib.mkOption {
|
||||||
inherit (probesFormat) type;
|
inherit (probesFormat) type;
|
||||||
default = [];
|
default = [ ];
|
||||||
};
|
};
|
||||||
tags = lib.mkOption {
|
tags = lib.mkOption {
|
||||||
inherit (probesFormat) type;
|
inherit (probesFormat) type;
|
||||||
default = [];
|
default = [ ];
|
||||||
};
|
};
|
||||||
notifications = lib.mkOption {
|
notifications = lib.mkOption {
|
||||||
inherit (probesFormat) type;
|
inherit (probesFormat) type;
|
||||||
default = [];
|
default = [ ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,22 +3,26 @@ let
|
||||||
data = builtins.fromJSON (builtins.readFile ./sources.json);
|
data = builtins.fromJSON (builtins.readFile ./sources.json);
|
||||||
version = data.version;
|
version = data.version;
|
||||||
|
|
||||||
mkSource = spec:
|
mkSource =
|
||||||
assert spec ? type; let
|
spec:
|
||||||
|
assert spec ? type;
|
||||||
|
let
|
||||||
path =
|
path =
|
||||||
if spec.type == "Git"
|
if spec.type == "Git" then
|
||||||
then mkGitSource spec
|
mkGitSource spec
|
||||||
else if spec.type == "GitRelease"
|
else if spec.type == "GitRelease" then
|
||||||
then mkGitSource spec
|
mkGitSource spec
|
||||||
else if spec.type == "PyPi"
|
else if spec.type == "PyPi" then
|
||||||
then mkPyPiSource spec
|
mkPyPiSource spec
|
||||||
else if spec.type == "Channel"
|
else if spec.type == "Channel" then
|
||||||
then mkChannelSource spec
|
mkChannelSource spec
|
||||||
else builtins.throw "Unknown source type ${spec.type}";
|
else
|
||||||
|
builtins.throw "Unknown source type ${spec.type}";
|
||||||
in
|
in
|
||||||
spec // {outPath = path;};
|
spec // { outPath = path; };
|
||||||
|
|
||||||
mkGitSource = {
|
mkGitSource =
|
||||||
|
{
|
||||||
repository,
|
repository,
|
||||||
revision,
|
revision,
|
||||||
url ? null,
|
url ? null,
|
||||||
|
@ -28,8 +32,7 @@ let
|
||||||
assert repository ? type;
|
assert repository ? type;
|
||||||
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
|
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
|
||||||
# In the latter case, there we will always be an url to the tarball
|
# In the latter case, there we will always be an url to the tarball
|
||||||
if url != null
|
if url != null then
|
||||||
then
|
|
||||||
(builtins.fetchTarball {
|
(builtins.fetchTarball {
|
||||||
inherit url;
|
inherit url;
|
||||||
sha256 = hash; # FIXME: check nix version & use SRI hashes
|
sha256 = hash; # FIXME: check nix version & use SRI hashes
|
||||||
|
@ -42,26 +45,21 @@ let
|
||||||
# hash = hash;
|
# hash = hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
mkPyPiSource = {
|
mkPyPiSource =
|
||||||
url,
|
{ url, hash, ... }:
|
||||||
hash,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
builtins.fetchurl {
|
builtins.fetchurl {
|
||||||
inherit url;
|
inherit url;
|
||||||
sha256 = hash;
|
sha256 = hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
mkChannelSource = {
|
mkChannelSource =
|
||||||
url,
|
{ url, hash, ... }:
|
||||||
hash,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
builtins.fetchTarball {
|
builtins.fetchTarball {
|
||||||
inherit url;
|
inherit url;
|
||||||
sha256 = hash;
|
sha256 = hash;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
if version == 3
|
if version == 3 then
|
||||||
then builtins.mapAttrs (_: mkSource) data.pins
|
builtins.mapAttrs (_: mkSource) data.pins
|
||||||
else throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"
|
else
|
||||||
|
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
(import ./. {}).shell
|
(import ./. { }).shell
|
||||||
|
|
|
@ -11,6 +11,4 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
((import ../. {}).evalModules {
|
((import ../. { }).evalModules { modules = [ module ]; }).config.statelessUptimeKuma.build.json
|
||||||
modules = [ module ];
|
|
||||||
}).config.statelessUptimeKuma.build.json
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
{ lib
|
{
|
||||||
, buildPythonPackage
|
lib,
|
||||||
, fetchFromGitHub
|
buildPythonPackage,
|
||||||
, setuptools
|
fetchFromGitHub,
|
||||||
, wheel
|
setuptools,
|
||||||
, packaging
|
wheel,
|
||||||
, python-socketio
|
packaging,
|
||||||
, requests
|
python-socketio,
|
||||||
|
requests,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
|
|
Loading…
Reference in a new issue