flake reorg

This commit is contained in:
Robin Appelman 2024-09-28 21:58:19 +02:00
commit 84c096372e
6 changed files with 133 additions and 102 deletions

View file

@ -1,9 +1,10 @@
on: [ push, pull_request ] name: "CI"
on:
name: CI pull_request:
push:
jobs: jobs:
build: checks:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -12,5 +13,5 @@ jobs:
with: with:
name: ci name: ci
instance: https://cache.icewind.me instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}' authToken: "${{ secrets.ATTIC_TOKEN }}"
- run: nix build - run: nix flake check --keep-going

95
flake.lock generated
View file

@ -1,56 +1,103 @@
{ {
"nodes": { "nodes": {
"flake-utils": { "crane": {
"inputs": {
"systems": "systems"
},
"locked": { "locked": {
"lastModified": 1710146030, "lastModified": 1727060013,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "narHash": "sha256-/fC5YlJy4IoAW9GhkJiwyzk0K/gQd9Qi4rRcoweyG9E=",
"owner": "numtide", "owner": "ipetkov",
"repo": "flake-utils", "repo": "crane",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "rev": "6b40cc876c929bfe1e3a24bf538ce3b5622646ba",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "ipetkov",
"repo": "flake-utils", "repo": "crane",
"type": "github"
}
},
"flakelight": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1727095190,
"narHash": "sha256-eZfUxkPefTP5fknpr2/X+snNysEj830Ft1IaW7VafFE=",
"owner": "nix-community",
"repo": "flakelight",
"rev": "9e0f7e360688187ed3d7d8b033028e0d3473aa2c",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "flakelight",
"type": "github"
}
},
"mill-scale": {
"inputs": {
"crane": "crane",
"flakelight": [
"flakelight"
],
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1727556185,
"narHash": "sha256-pEUzAE5WRpPGQYeG/U2mftfHAn2q4aO1pefJNY2EoVw=",
"owner": "icewind1991",
"repo": "mill-scale",
"rev": "823fb3493cb4838c81627821f383af918db33a7f",
"type": "github"
},
"original": {
"owner": "icewind1991",
"repo": "mill-scale",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1719092257, "lastModified": 1727397532,
"narHash": "sha256-nGoolnNxcIfP3rYA7U9Z/wjufVKzGEcQ2zRuKBEzN9k=", "narHash": "sha256-pojbL/qteElw/nIXlN8kmHn/w6PQbEHr7Iz+WOXs0EM=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "df56ee013dc9cf5f1f614d119c006217f9bf3b54", "rev": "f65141456289e81ea0d5a05af8898333cab5c53d",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "id": "nixpkgs",
"ref": "release-24.05", "ref": "nixos-24.05",
"type": "indirect" "type": "indirect"
} }
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flakelight": "flakelight",
"mill-scale": "mill-scale",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
}, },
"systems": { "rust-overlay": {
"inputs": {
"nixpkgs": [
"mill-scale",
"flakelight",
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1681028828, "lastModified": 1727058553,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "narHash": "sha256-tY/UU3Qk5gP/J0uUM4DZ6wo4arNLGAVqLKBotILykfQ=",
"owner": "nix-systems", "owner": "oxalica",
"repo": "default", "repo": "rust-overlay",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "rev": "edc5b0f896170f07bd39ad59d6186fcc7859bbb2",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nix-systems", "owner": "oxalica",
"repo": "default", "repo": "rust-overlay",
"type": "github" "type": "github"
} }
} }

View file

@ -1,46 +1,31 @@
{ {
inputs = { inputs = {
nixpkgs.url = "nixpkgs/release-24.05"; nixpkgs.url = "nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils"; flakelight = {
url = "github:nix-community/flakelight";
inputs.nixpkgs.follows = "nixpkgs";
}; };
mill-scale = {
url = "github:icewind1991/mill-scale";
inputs.flakelight.follows = "flakelight";
};
};
outputs = { mill-scale, ... }: mill-scale ./. {
packages.wifi-prometheus-exporter = import ./package.nix;
outputs = { nixosModules = { outputs, ... }: {
self, default =
nixpkgs, { pkgs
flake-utils, , config
}: , lib
flake-utils.lib.eachDefaultSystem ( , ...
system: let
overlays = [
(import ./overlay.nix)
];
pkgs = (import nixpkgs) {
inherit system overlays;
};
in rec {
packages = rec {
inherit (pkgs) wifi-prometheus-exporter;
default = wifi-prometheus-exporter;
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [rustc cargo bacon cargo-edit cargo-outdated openssl pkg-config clippy];
};
}
)
// {
overlays.default = import ./overlay.nix;
nixosModules.default = {
pkgs,
config,
lib,
...
}: { }: {
imports = [./module.nix]; imports = [ ./module.nix ];
config = lib.mkIf config.services.wifi-prometheus-exporter.enable { config = lib.mkIf config.services.wifi-prometheus-exporter.enable {
nixpkgs.overlays = [self.overlays.default]; nixpkgs.overlays = [ outputs.overlays.default ];
services.wifi-prometheus-exporter.package = lib.mkDefault pkgs.wifi-prometheus-exporter; services.wifi-prometheus-exporter.package = lib.mkDefault pkgs.wifi-prometheus-exporter;
}; };
}; };
}; };
};
} }

View file

@ -1,12 +1,11 @@
{ { config
config, , lib
lib, , pkgs
pkgs, , ...
...
}: }:
with lib; let with lib; let
cfg = config.services.wifi-prometheus-exporter; cfg = config.services.wifi-prometheus-exporter;
format = pkgs.formats.toml {}; format = pkgs.formats.toml { };
configFile = format.generate "wifi-prometheus-exporter-config.toml" { configFile = format.generate "wifi-prometheus-exporter-config.toml" {
ssh = { ssh = {
inherit (cfg.ssh) address; inherit (cfg.ssh) address;
@ -22,7 +21,8 @@ with lib; let
}; };
}; };
in { in
{
options.services.wifi-prometheus-exporter = { options.services.wifi-prometheus-exporter = {
enable = mkEnableOption "WiFi prometheus exporter"; enable = mkEnableOption "WiFi prometheus exporter";
@ -95,7 +95,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
systemd.services."wifi-prometheus-exporter" = { systemd.services."wifi-prometheus-exporter" = {
wantedBy = ["multi-user.target"]; wantedBy = [ "multi-user.target" ];
environment = { environment = {
RUST_LOG = cfg.log; RUST_LOG = cfg.log;
}; };
@ -129,9 +129,9 @@ in {
RestrictAddressFamilies = "AF_INET AF_INET6"; RestrictAddressFamilies = "AF_INET AF_INET6";
RestrictRealtime = true; RestrictRealtime = true;
ProtectProc = "noaccess"; ProtectProc = "noaccess";
SystemCallFilter = ["@system-service" "~@resources" "~@privileged"]; SystemCallFilter = [ "@system-service" "~@resources" "~@privileged" ];
IPAddressDeny = "any"; IPAddressDeny = "any";
IPAddressAllow = ["192.168.0.0/16" "localhost"]; IPAddressAllow = [ "192.168.0.0/16" "localhost" ];
PrivateUsers = true; PrivateUsers = true;
ProcSubset = "pid"; ProcSubset = "pid";
}; };

View file

@ -1,3 +0,0 @@
final: prev: {
wifi-prometheus-exporter = final.callPackage ./package.nix {};
}

View file

@ -1,13 +1,14 @@
{ { rustPlatform
rustPlatform, , openssl
openssl, , pkg-config
pkg-config, , lib
lib, ,
}: let }:
let
inherit (lib.sources) sourceByRegex; inherit (lib.sources) sourceByRegex;
src = sourceByRegex ./. ["Cargo.*" "(src)(/.*)?"]; src = sourceByRegex ./. [ "Cargo.*" "(src)(/.*)?" ];
in in
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage rec {
pname = "wifi-prometheus-exporter"; pname = "wifi-prometheus-exporter";
version = "0.1.0"; version = "0.1.0";
@ -26,4 +27,4 @@ in
cargoLock = { cargoLock = {
lockFile = ./Cargo.lock; lockFile = ./Cargo.lock;
}; };
} }