mirror of
https://codeberg.org/icewind/prometheus-mdns-rs.git
synced 2026-06-03 09:54:21 +02:00
flake reorg
This commit is contained in:
parent
f5630c7960
commit
d7fde02c00
10 changed files with 140 additions and 140 deletions
35
.github/workflows/ci.yaml
vendored
35
.github/workflows/ci.yaml
vendored
|
|
@ -1,34 +1,17 @@
|
|||
on: [push, pull_request]
|
||||
|
||||
name: CI
|
||||
name: "CI"
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
checks:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v25
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v26
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build
|
||||
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v25
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build .#docker
|
||||
- name: Push image
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
skopeo copy --dest-creds="${{ secrets.DOCKERHUB_USERNAME }}:${{ secrets.DOCKERHUB_TOKEN }}" "docker-archive:$(nix build .#docker --print-out-paths)" "docker://icewind1991/prometheus-mdns-sd"
|
||||
authToken: "${{ secrets.ATTIC_TOKEN }}"
|
||||
- run: nix flake check --keep-going
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# mDNS service discovery for Prometheus
|
||||
|
||||
Discovers mDNS/ZeroConf/Bonjour service announcements under _prometheus-http._tcp for ad-hoc discovery of devices on LAN networks.
|
||||
Discovers mDNS/ZeroConf/Bonjour service announcements under \_prometheus-http.\_tcp for ad-hoc discovery of devices on LAN networks.
|
||||
|
||||
## Usage
|
||||
|
||||
|
|
|
|||
16
docker.nix
16
docker.nix
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
dockerTools,
|
||||
prometheus-mdns-sd,
|
||||
}:
|
||||
dockerTools.buildLayeredImage {
|
||||
name = "icewind1991/prometheus-mdns-sd";
|
||||
tag = "latest";
|
||||
maxLayers = 5;
|
||||
contents = [
|
||||
prometheus-mdns-sd
|
||||
dockerTools.caCertificates
|
||||
];
|
||||
config = {
|
||||
Cmd = ["prometheus-mdns-sd-rs"];
|
||||
};
|
||||
}
|
||||
95
flake.lock
generated
95
flake.lock
generated
|
|
@ -1,56 +1,103 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1701680307,
|
||||
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
|
||||
"lastModified": 1733688869,
|
||||
"narHash": "sha256-KrhxxFj1CjESDrL5+u/zsVH0K+Ik9tvoac/oFPoxSB8=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "604637106e420ad99907cae401e13ab6b452e7d9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flakelight": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1733748390,
|
||||
"narHash": "sha256-UqTETFjEkwu7WAtlRJPoM7rZpkMnvM9LeupKes+Breg=",
|
||||
"owner": "nix-community",
|
||||
"repo": "flakelight",
|
||||
"rev": "3b6d1f0651f7cf4f4dc17c45e12782778a11520b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "flakelight",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"mill-scale": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"flakelight": [
|
||||
"flakelight"
|
||||
],
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1734188451,
|
||||
"narHash": "sha256-bLsT74oXirSNn2oaSRd61/V/+OZ4jRKEkdBpzSZkBbM=",
|
||||
"owner": "icewind1991",
|
||||
"repo": "mill-scale",
|
||||
"rev": "d8e263916aa788a98e28fce06e26940001f38d5b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "icewind1991",
|
||||
"repo": "mill-scale",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1705183652,
|
||||
"narHash": "sha256-rnfkyUH0x72oHfiSDhuCHDHg3gFgF+lF8zkkg5Zihsw=",
|
||||
"lastModified": 1734083684,
|
||||
"narHash": "sha256-5fNndbndxSx5d+C/D0p/VF32xDiJCJzyOqorOYW4JEo=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "428544ae95eec077c7f823b422afae5f174dee4b",
|
||||
"rev": "314e12ba369ccdb9b352a4db26ff419f7c49fa84",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-23.11",
|
||||
"ref": "nixos-24.11",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"flakelight": "flakelight",
|
||||
"mill-scale": "mill-scale",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"mill-scale",
|
||||
"flakelight",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"lastModified": 1733884434,
|
||||
"narHash": "sha256-8GXR9kC07dyOIshAyfZhG11xfvBRSZzYghnZ2weOKJU=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "d0483df44ddf0fd1985f564abccbe568e020ddf2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
52
flake.nix
52
flake.nix
|
|
@ -1,47 +1,29 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-23.11";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nixpkgs.url = "nixpkgs/nixos-24.11";
|
||||
flakelight = {
|
||||
url = "github:nix-community/flakelight";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
overlays = [
|
||||
(import ./overlay.nix)
|
||||
];
|
||||
pkgs = (import nixpkgs) {
|
||||
inherit system overlays;
|
||||
mill-scale = {
|
||||
url = "github:icewind1991/mill-scale";
|
||||
inputs.flakelight.follows = "flakelight";
|
||||
};
|
||||
in rec {
|
||||
packages = rec {
|
||||
prometheus-mdns-sd = pkgs.prometheus-mdns-sd;
|
||||
docker = pkgs.callPackage ./docker.nix {};
|
||||
default = prometheus-mdns-sd;
|
||||
};
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [rustc cargo bacon cargo-edit cargo-outdated clippy];
|
||||
};
|
||||
}
|
||||
)
|
||||
// {
|
||||
overlays.default = import ./overlay.nix;
|
||||
nixosModules.default = {
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
outputs = { mill-scale, ... }: mill-scale ./. {
|
||||
nixosModules = { outputs, ... }: {
|
||||
default =
|
||||
{ pkgs
|
||||
, config
|
||||
, lib
|
||||
, ...
|
||||
}: {
|
||||
imports = [./module.nix];
|
||||
imports = [ ./module.nix ];
|
||||
config = lib.mkIf config.services.prometheus-mdns-sd.enable {
|
||||
nixpkgs.overlays = [self.overlays.default];
|
||||
nixpkgs.overlays = [ outputs.overlays.default ];
|
||||
services.prometheus-mdns-sd.package = lib.mkDefault pkgs.prometheus-mdns-sd;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
{ config
|
||||
, lib
|
||||
, pkgs
|
||||
, ...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.services.prometheus-mdns-sd;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.services.prometheus-mdns-sd = {
|
||||
enable = mkEnableOption "WiFi prometheus exporter";
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ in {
|
|||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services."prometheus-mdns-sd" = {
|
||||
wantedBy = ["multi-user.target"];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${cfg.package}/bin/prometheus-mdns-sd-rs ${cfg.target}";
|
||||
|
|
@ -50,9 +50,9 @@ in {
|
|||
RestrictAddressFamilies = "AF_INET";
|
||||
RestrictRealtime = true;
|
||||
ProtectProc = "invisible";
|
||||
SystemCallFilter = ["@system-service" "~@resources" "~@privileged"];
|
||||
SystemCallFilter = [ "@system-service" "~@resources" "~@privileged" ];
|
||||
IPAddressDeny = "any";
|
||||
IPAddressAllow = ["multicast" "192.168.0.0/16"];
|
||||
IPAddressAllow = [ "multicast" "192.168.0.0/16" ];
|
||||
PrivateUsers = true;
|
||||
ProcSubset = "pid";
|
||||
RuntimeDirectory = "prometheus-mdns-sd";
|
||||
3
nix/overlay.nix
Normal file
3
nix/overlay.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
final: prev: {
|
||||
prometheus-mdns-sd = final.callPackage ./package.nix { };
|
||||
}
|
||||
22
nix/package.nix
Normal file
22
nix/package.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{ stdenv
|
||||
, rustPlatform
|
||||
, lib
|
||||
,
|
||||
}:
|
||||
let
|
||||
inherit (lib.sources) sourceByRegex;
|
||||
inherit (builtins) fromTOML readFile;
|
||||
src = sourceByRegex ../. [ "Cargo.*" "(src)(/.*)?" ];
|
||||
cargoPackage = (fromTOML (readFile ../Cargo.toml)).package;
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
inherit (cargoPackage) version;
|
||||
|
||||
pname = cargoPackage.name;
|
||||
|
||||
inherit src;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ../Cargo.lock;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
final: prev: {
|
||||
prometheus-mdns-sd = final.callPackage ./package.nix {};
|
||||
}
|
||||
18
package.nix
18
package.nix
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
stdenv,
|
||||
rustPlatform,
|
||||
lib,
|
||||
}: let
|
||||
inherit (lib.sources) sourceByRegex;
|
||||
src = sourceByRegex ./. ["Cargo.*" "(src)(/.*)?"];
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "prometheus-mdns-sd";
|
||||
version = "0.1.0";
|
||||
|
||||
inherit src;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue