diff --git a/default.nix b/default.nix index f9e996a..6425f5e 100644 --- a/default.nix +++ b/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 { - modules = [ - ./nixos/module.nix - ({ lib, ... }: { - _module.args.pkgs = lib.mkDefault pkgs; - }) - ]; - }).extendModules; + 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, ... }: + { + _module.args.pkgs = lib.mkDefault pkgs; + } + ) + ]; + }).extendModules; } diff --git a/nixos/module.nix b/nixos/module.nix index 144d248..e7f1dd0 100644 --- a/nixos/module.nix +++ b/nixos/module.nix @@ -1,6 +1,11 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let - probesFormat = pkgs.formats.json {}; + probesFormat = pkgs.formats.json { }; cfg = config.statelessUptimeKuma; in { @@ -13,15 +18,15 @@ in probesConfig = { monitors = lib.mkOption { inherit (probesFormat) type; - default = []; + default = [ ]; }; tags = lib.mkOption { inherit (probesFormat) type; - default = []; + default = [ ]; }; notifications = lib.mkOption { inherit (probesFormat) type; - default = []; + default = [ ]; }; }; }; diff --git a/npins/default.nix b/npins/default.nix index e5e274a..ae29155 100644 --- a/npins/default.nix +++ b/npins/default.nix @@ -3,65 +3,63 @@ 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;}; + spec // { outPath = path; }; - mkGitSource = { - repository, - revision, - url ? null, - hash, - ... - }: + mkGitSource = + { + repository, + revision, + url ? null, + hash, + ... + }: 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 - (builtins.fetchTarball { - inherit url; - sha256 = hash; # FIXME: check nix version & use SRI hashes - }) - else - assert repository.type == "Git"; - builtins.fetchGit { - url = repository.url; - rev = revision; - # hash = hash; - }; + if url != null then + (builtins.fetchTarball { + inherit url; + sha256 = hash; # FIXME: check nix version & use SRI hashes + }) + else + assert repository.type == "Git"; + builtins.fetchGit { + url = repository.url; + rev = revision; + # 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`" diff --git a/shell.nix b/shell.nix index 0d9af5e..a6bdf20 100644 --- a/shell.nix +++ b/shell.nix @@ -1 +1 @@ -(import ./. {}).shell +(import ./. { }).shell diff --git a/tests/testmodule.nix b/tests/testmodule.nix index 8b1fef0..cc9ae5f 100644 --- a/tests/testmodule.nix +++ b/tests/testmodule.nix @@ -11,6 +11,4 @@ let }; }; in -((import ../. {}).evalModules { - modules = [ module ]; -}).config.statelessUptimeKuma.build.json +((import ../. { }).evalModules { modules = [ module ]; }).config.statelessUptimeKuma.build.json diff --git a/uptime-kuma-api.nix b/uptime-kuma-api.nix index 75baeba..e9e3b33 100644 --- a/uptime-kuma-api.nix +++ b/uptime-kuma-api.nix @@ -1,11 +1,12 @@ -{ lib -, buildPythonPackage -, fetchFromGitHub -, setuptools -, wheel -, packaging -, python-socketio -, requests +{ + lib, + buildPythonPackage, + fetchFromGitHub, + setuptools, + wheel, + packaging, + python-socketio, + requests, }: buildPythonPackage rec {