58 lines
1.3 KiB
Nix
58 lines
1.3 KiB
Nix
{
|
|
|
|
pkgsArg ? import (fetchTarball {
|
|
name = "nixpkgs-21-05";
|
|
url = "https://github.com/NixOS/nixpkgs/archive/7e9b0dff974c89e070da1ad85713ff3c20b0ca97.tar.gz";
|
|
sha256 = "1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36";
|
|
}) {},
|
|
|
|
config ? import ./config.nix,
|
|
|
|
}: rec {
|
|
|
|
pkgs = pkgsArg;
|
|
|
|
srv = pkgs.callPackage (import ./srv) {
|
|
inherit config;
|
|
};
|
|
|
|
|
|
entrypoint = pkgs.writeScript "mediocre-blog-entrypoint" ''
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
mkdir -p ${config.runDir}
|
|
mkdir -p ${config.dataDir}
|
|
|
|
exec ${srv.bin}
|
|
'';
|
|
|
|
service = pkgs.writeText "mediocre-blog" ''
|
|
[Unit]
|
|
Description=mediocregopher mediocre blog
|
|
Requires=network.target
|
|
After=network.target
|
|
|
|
[Service]
|
|
Restart=always
|
|
RestartSec=1s
|
|
User=mediocregopher
|
|
Group=mediocregopher
|
|
RuntimeDirectory=mediocre-blog
|
|
ExecStart=${entrypoint}
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
'';
|
|
|
|
install = pkgs.writeScript "mediocre-blog" ''
|
|
set -e -x
|
|
|
|
sudo cp ${service} /etc/systemd/system/mediocregopher-mediocre-blog.service
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable mediocregopher-mediocre-blog.service
|
|
sudo systemctl restart mediocregopher-mediocre-blog.service
|
|
'';
|
|
}
|