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
name: "CI"
on:
pull_request:
push:
jobs:
build:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@ -12,5 +13,5 @@ jobs:
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build
authToken: "${{ secrets.ATTIC_TOKEN }}"
- run: nix flake check --keep-going

95
flake.lock generated
View file

@ -1,56 +1,103 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"crane": {
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"lastModified": 1727060013,
"narHash": "sha256-/fC5YlJy4IoAW9GhkJiwyzk0K/gQd9Qi4rRcoweyG9E=",
"owner": "ipetkov",
"repo": "crane",
"rev": "6b40cc876c929bfe1e3a24bf538ce3b5622646ba",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"owner": "ipetkov",
"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"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1719092257,
"narHash": "sha256-nGoolnNxcIfP3rYA7U9Z/wjufVKzGEcQ2zRuKBEzN9k=",
"lastModified": 1727397532,
"narHash": "sha256-pojbL/qteElw/nIXlN8kmHn/w6PQbEHr7Iz+WOXs0EM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "df56ee013dc9cf5f1f614d119c006217f9bf3b54",
"rev": "f65141456289e81ea0d5a05af8898333cab5c53d",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "release-24.05",
"ref": "nixos-24.05",
"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": 1727058553,
"narHash": "sha256-tY/UU3Qk5gP/J0uUM4DZ6wo4arNLGAVqLKBotILykfQ=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "edc5b0f896170f07bd39ad59d6186fcc7859bbb2",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}

View file

@ -1,46 +1,31 @@
{
inputs = {
nixpkgs.url = "nixpkgs/release-24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
}:
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];
config = lib.mkIf config.services.wifi-prometheus-exporter.enable {
nixpkgs.overlays = [self.overlays.default];
services.wifi-prometheus-exporter.package = lib.mkDefault pkgs.wifi-prometheus-exporter;
};
};
nixpkgs.url = "nixpkgs/nixos-24.05";
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;
nixosModules = { outputs, ... }: {
default =
{ pkgs
, config
, lib
, ...
}: {
imports = [ ./module.nix ];
config = lib.mkIf config.services.wifi-prometheus-exporter.enable {
nixpkgs.overlays = [ outputs.overlays.default ];
services.wifi-prometheus-exporter.package = lib.mkDefault pkgs.wifi-prometheus-exporter;
};
};
};
};
}

View file

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

View file

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

View file

@ -1,29 +1,30 @@
{
rustPlatform,
openssl,
pkg-config,
lib,
}: let
{ rustPlatform
, openssl
, pkg-config
, lib
,
}:
let
inherit (lib.sources) sourceByRegex;
src = sourceByRegex ./. ["Cargo.*" "(src)(/.*)?"];
src = sourceByRegex ./. [ "Cargo.*" "(src)(/.*)?" ];
in
rustPlatform.buildRustPackage rec {
pname = "wifi-prometheus-exporter";
version = "0.1.0";
rustPlatform.buildRustPackage rec {
pname = "wifi-prometheus-exporter";
version = "0.1.0";
inherit src;
inherit src;
buildInputs = [
openssl
];
buildInputs = [
openssl
];
nativeBuildInputs = [
pkg-config
];
nativeBuildInputs = [
pkg-config
];
doCheck = false;
doCheck = false;
cargoLock = {
lockFile = ./Cargo.lock;
};
}
cargoLock = {
lockFile = ./Cargo.lock;
};
}