scrape: convert scrapers to flake input

This commit is contained in:
Astro 2021-03-06 03:11:43 +01:00
parent 4b8353c011
commit ae1c93404d
3 changed files with 28 additions and 10 deletions

View File

@ -34,10 +34,27 @@
"inputs": { "inputs": {
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"scrapers": "scrapers",
"secrets": "secrets", "secrets": "secrets",
"yammat": "yammat" "yammat": "yammat"
} }
}, },
"scrapers": {
"flake": false,
"locked": {
"lastModified": 1614995337,
"narHash": "sha256-0MvWFV+Kvd83hcX75Z/rghrUyTPRObGjch7/hKxvROY=",
"ref": "master",
"rev": "77c864b4d7e1ef4075ed115b036791c75176bef7",
"revCount": 24,
"type": "git",
"url": "https://gitea.c3d2.de/astro/scrapers.git"
},
"original": {
"type": "git",
"url": "https://gitea.c3d2.de/astro/scrapers.git"
}
},
"secrets": { "secrets": {
"locked": { "locked": {
"lastModified": 1614994700, "lastModified": 1614994700,

View File

@ -6,9 +6,11 @@
secrets.url = "git+ssh://git@gitea.c3d2.de:2222/c3d2-admins/secrets.git"; secrets.url = "git+ssh://git@gitea.c3d2.de:2222/c3d2-admins/secrets.git";
yammat.url = "git+https://gitea.c3d2.de/astro/yammat.git?ref=nix"; yammat.url = "git+https://gitea.c3d2.de/astro/yammat.git?ref=nix";
yammat.flake = false; yammat.flake = false;
scrapers.url = "git+https://gitea.c3d2.de/astro/scrapers.git";
scrapers.flake = false;
}; };
outputs = { self, nixpkgs, secrets, nixos-hardware, yammat }: outputs = { self, nixpkgs, secrets, nixos-hardware, yammat, scrapers }:
let let
forAllSystems = nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" ]; forAllSystems = nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" ];
@ -74,9 +76,11 @@
nixosConfigurations = let nixosConfigurations = let
nixosSystem' = nixosSystem' =
# Our custom NixOS builder # Our custom NixOS builder
{ ... }@args: { extraArgs ? {}, ... }@args:
nixpkgs.lib.nixosSystem (args // { nixpkgs.lib.nixosSystem (args // {
extraArgs = { inherit hostRegistry; }; extraArgs = extraArgs // {
inherit hostRegistry;
};
extraModules = [ extraModules = [
self.nixosModules.c3d2 self.nixosModules.c3d2
({ pkgs, ... }: { ({ pkgs, ... }: {
@ -157,6 +161,7 @@
nixpkgs.overlays = [ secrets.overlays.scrape ]; nixpkgs.overlays = [ secrets.overlays.scrape ];
}) })
]; ];
extraArgs = { inherit scrapers; };
system = "x86_64-linux"; system = "x86_64-linux";
}; };

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, modulesPath, ... }: { pkgs, scrapers, ... }:
let let
freifunkNodes = { freifunkNodes = {
@ -23,14 +23,10 @@ in {
environment.systemPackages = [ pkgs.git ]; environment.systemPackages = [ pkgs.git ];
systemd.services = let systemd.services = let
scrapers = import (pkgs.fetchgit { scraperPkgs = import scrapers { inherit pkgs; };
url = "https://gitea.c3d2.de/astro/scrapers.git";
rev = "77c864b4d7e1ef4075ed115b036791c75176bef7";
sha256 = "1rj4dyn89zqyfaiv2ffi6g4x86l2xfgybyy5hlvxzgcabwaxdjyh";
}) { inherit pkgs; };
makeService = { script, host, user ? "", password ? "" }: { makeService = { script, host, user ? "", password ? "" }: {
script = script =
"${scrapers.${script}}/bin/${script} ${host} ${user} ${password}"; "${scraperPkgs.${script}}/bin/${script} ${host} ${user} ${password}";
}; };
makeNodeScraper = nodeId: { makeNodeScraper = nodeId: {
name = "scrape-node${nodeId}"; name = "scrape-node${nodeId}";