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
|
||||
, pkgs ? import nixpkgs { overlays = [ (import ./overlay.nix) ]; }
|
||||
{
|
||||
sources ? import ./npins,
|
||||
nixpkgs ? sources.nixpkgs,
|
||||
pkgs ? import nixpkgs { overlays = [ (import ./overlay.nix) ]; },
|
||||
}:
|
||||
rec {
|
||||
shell = pkgs.mkShell {
|
||||
|
@ -9,13 +10,22 @@ rec {
|
|||
pkgs.ruff
|
||||
];
|
||||
};
|
||||
python = pkgs.python3.withPackages (ps: [ ps.mypy ps.click ps.click-log ps.uptime-kuma-api ]);
|
||||
evalModules = (pkgs.lib.evalModules {
|
||||
python = pkgs.python3.withPackages (ps: [
|
||||
ps.mypy
|
||||
ps.click
|
||||
ps.click-log
|
||||
ps.uptime-kuma-api
|
||||
]);
|
||||
evalModules =
|
||||
(pkgs.lib.evalModules {
|
||||
modules = [
|
||||
./nixos/module.nix
|
||||
({ lib, ... }: {
|
||||
(
|
||||
{ lib, ... }:
|
||||
{
|
||||
_module.args.pkgs = lib.mkDefault pkgs;
|
||||
})
|
||||
}
|
||||
)
|
||||
];
|
||||
}).extendModules;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
probesFormat = pkgs.formats.json { };
|
||||
cfg = config.statelessUptimeKuma;
|
||||
|
|
|
@ -3,22 +3,26 @@ let
|
|||
data = builtins.fromJSON (builtins.readFile ./sources.json);
|
||||
version = data.version;
|
||||
|
||||
mkSource = spec:
|
||||
assert spec ? type; let
|
||||
mkSource =
|
||||
spec:
|
||||
assert spec ? type;
|
||||
let
|
||||
path =
|
||||
if spec.type == "Git"
|
||||
then mkGitSource spec
|
||||
else if spec.type == "GitRelease"
|
||||
then mkGitSource spec
|
||||
else if spec.type == "PyPi"
|
||||
then mkPyPiSource spec
|
||||
else if spec.type == "Channel"
|
||||
then mkChannelSource spec
|
||||
else builtins.throw "Unknown source type ${spec.type}";
|
||||
if spec.type == "Git" then
|
||||
mkGitSource spec
|
||||
else if spec.type == "GitRelease" then
|
||||
mkGitSource spec
|
||||
else if spec.type == "PyPi" then
|
||||
mkPyPiSource spec
|
||||
else if spec.type == "Channel" then
|
||||
mkChannelSource spec
|
||||
else
|
||||
builtins.throw "Unknown source type ${spec.type}";
|
||||
in
|
||||
spec // { outPath = path; };
|
||||
|
||||
mkGitSource = {
|
||||
mkGitSource =
|
||||
{
|
||||
repository,
|
||||
revision,
|
||||
url ? null,
|
||||
|
@ -28,8 +32,7 @@ let
|
|||
assert repository ? type;
|
||||
# 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
|
||||
if url != null
|
||||
then
|
||||
if url != null then
|
||||
(builtins.fetchTarball {
|
||||
inherit url;
|
||||
sha256 = hash; # FIXME: check nix version & use SRI hashes
|
||||
|
@ -42,26 +45,21 @@ let
|
|||
# hash = hash;
|
||||
};
|
||||
|
||||
mkPyPiSource = {
|
||||
url,
|
||||
hash,
|
||||
...
|
||||
}:
|
||||
mkPyPiSource =
|
||||
{ url, hash, ... }:
|
||||
builtins.fetchurl {
|
||||
inherit url;
|
||||
sha256 = hash;
|
||||
};
|
||||
|
||||
mkChannelSource = {
|
||||
url,
|
||||
hash,
|
||||
...
|
||||
}:
|
||||
mkChannelSource =
|
||||
{ url, hash, ... }:
|
||||
builtins.fetchTarball {
|
||||
inherit url;
|
||||
sha256 = hash;
|
||||
};
|
||||
in
|
||||
if version == 3
|
||||
then builtins.mapAttrs (_: mkSource) data.pins
|
||||
else throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"
|
||||
if version == 3 then
|
||||
builtins.mapAttrs (_: mkSource) data.pins
|
||||
else
|
||||
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"
|
||||
|
|
|
@ -11,6 +11,4 @@ let
|
|||
};
|
||||
};
|
||||
in
|
||||
((import ../. {}).evalModules {
|
||||
modules = [ module ];
|
||||
}).config.statelessUptimeKuma.build.json
|
||||
((import ../. { }).evalModules { modules = [ module ]; }).config.statelessUptimeKuma.build.json
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
{ lib
|
||||
, buildPythonPackage
|
||||
, fetchFromGitHub
|
||||
, setuptools
|
||||
, wheel
|
||||
, packaging
|
||||
, python-socketio
|
||||
, requests
|
||||
{
|
||||
lib,
|
||||
buildPythonPackage,
|
||||
fetchFromGitHub,
|
||||
setuptools,
|
||||
wheel,
|
||||
packaging,
|
||||
python-socketio,
|
||||
requests,
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
|
|
Loading…
Reference in a new issue