nix-config/hosts/containers/oparl/default.nix

115 lines
2.8 KiB
Nix
Raw Normal View History

2022-05-28 00:12:18 +02:00
{ zentralwerk, config, pkgs, ... }:
let
ratsinfo-scraper = import (pkgs.fetchFromGitHub {
owner = "offenesdresden";
repo = "ratsinfo-scraper";
rev = "oparl";
2022-05-28 03:46:59 +02:00
sha256 = "sha256-RZ+IHeyVJp/b40ZXEdG1UuyXcr8xGJyyDPv8/qJu2CM=";
2022-05-28 00:12:18 +02:00
}) { inherit pkgs; };
2022-05-28 01:25:54 +02:00
netConfig = zentralwerk.lib.config.site.net.serv;
2022-05-28 00:12:18 +02:00
in
{
microvm = {
2022-05-28 00:46:49 +02:00
hypervisor = "qemu";
2022-05-28 00:12:18 +02:00
shares = [ {
source = "/nix/store";
mountPoint = "/nix/.ro-store";
tag = "store";
2022-05-28 00:46:49 +02:00
proto = "virtiofs";
2022-05-28 00:12:18 +02:00
socket = "store.socket";
} ] ++ map (dir: {
2022-05-28 00:39:15 +02:00
source = "/var/lib/microvms/${config.networking.hostName}/${dir}";
2022-05-28 00:12:18 +02:00
mountPoint = "/${dir}";
tag = dir;
2022-05-28 00:46:49 +02:00
proto = "virtiofs";
2022-05-28 00:12:18 +02:00
socket = "${dir}.socket";
}) [ "etc" "home" "var"];
interfaces = [ {
type = "tap";
id = "oparl";
mac = "00:de:9a:ce:38:79";
} ];
};
2022-05-28 01:56:33 +02:00
networking = {
hostName = "oparl";
2022-05-28 00:12:18 +02:00
useDHCP = false;
2022-05-28 01:56:33 +02:00
interfaces.eth0 = {
useDHCP = false;
ipv4.addresses = [ {
address = netConfig.hosts4.${config.networking.hostName};
prefixLength = netConfig.subnet4Len;
} ];
};
defaultGateway = netConfig.hosts4.serv-gw;
nameservers = [
netConfig.hosts4.dnscache "9.9.9.9"
];
2022-05-28 00:12:18 +02:00
};
users.users.oparl = {
2022-05-28 02:03:47 +02:00
isNormalUser = true;
2022-05-28 01:56:45 +02:00
createHome = true;
2022-05-28 00:12:18 +02:00
group = "oparl";
};
users.groups.oparl = {};
2022-05-28 01:25:54 +02:00
systemd.tmpfiles.rules = [
2022-05-28 02:29:48 +02:00
"C ${config.users.users.oparl.home}/.ssh/id_ed25519 0400 oparl oparl - ${config.sops.secrets."users/oparl/id_ed25519".path}"
"z ${config.users.users.oparl.home}/.ssh/id_ed25519 0400 oparl oparl - -"
2022-05-28 01:25:54 +02:00
];
2022-05-28 01:45:08 +02:00
sops.secrets."users/oparl/id_ed25519" = {};
2022-05-28 00:12:18 +02:00
systemd.services.oparl-scraper = {
wantedBy = [ "multi-user.target" ];
after = [ "systemd-tmpfiles-setup.service" "network-online.target" ];
2022-05-28 00:12:18 +02:00
startAt = "daily";
serviceConfig = {
User = "oparl";
Group = "oparl";
WorkingDirectory = "${config.users.users.oparl.home}";
};
path = with pkgs; [
git openssh poppler_utils ratsinfo-scraper
2022-05-28 00:12:18 +02:00
];
script = ''
if [ -d data ]; then
pushd data
git pull
popd
else
git clone git@github.com:offenesdresden/dresden-ratsinfo.git data
fi
2022-05-28 03:24:17 +02:00
pushd data
git config user.name Astro
git config user.email astro@spaceboyz.net
popd
2022-05-28 00:12:18 +02:00
scrape
pushd data
find . -name \*.json -exec git add "{}" +
2022-05-29 02:44:09 +02:00
git commit -m update || true
2022-05-28 11:23:14 +02:00
popd
2022-05-28 00:12:18 +02:00
meetings2ics data/meetings/ > data/meetings.ics
pushd data
git add meetings.ics
2022-05-29 02:44:09 +02:00
git commit -m "update meetings.ics" || true
2022-05-28 00:12:18 +02:00
popd
files_extract
pushd data
find . -name \*.txt -exec git add {} +
2022-05-29 02:44:09 +02:00
git commit -m update\ text || true
2022-05-28 00:12:18 +02:00
git push origin master
'';
};
2022-05-28 00:30:04 +02:00
system.stateVersion = "22.05";
2022-05-28 00:12:18 +02:00
}