Initial clean commit
This commit is contained in:
commit
1862821f8f
15 changed files with 1240 additions and 0 deletions
160
modules/services/static-sites/default.nix
Normal file
160
modules/services/static-sites/default.nix
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
{ inputs, pkgs, ... }:
|
||||
let
|
||||
buildPelicanSite = { name, src, subdir ? "", pluginSources ? [ ] }:
|
||||
let
|
||||
workdir = if subdir == "" then "." else subdir;
|
||||
pythonEnv = pkgs.python3.withPackages (ps: [
|
||||
ps.pelican
|
||||
ps.markdown
|
||||
ps.pygments
|
||||
]);
|
||||
copyPlugins = pkgs.lib.concatStringsSep "\n" (map (plugin: ''
|
||||
mkdir -p "${workdir}/${plugin.dest}"
|
||||
cp -a "${plugin.src}${if plugin ? subdir then "/${plugin.subdir}" else ""}/." "${workdir}/${plugin.dest}/"
|
||||
'') pluginSources);
|
||||
in
|
||||
pkgs.stdenvNoCC.mkDerivation {
|
||||
pname = name;
|
||||
version = "git";
|
||||
src = src;
|
||||
nativeBuildInputs = [ pythonEnv ];
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
cd ${workdir}
|
||||
${copyPlugins}
|
||||
${pythonEnv}/bin/pelican content -o "$out"
|
||||
runHook postBuild
|
||||
'';
|
||||
installPhase = "true";
|
||||
};
|
||||
|
||||
buildJekyllSite = { name, src, gemset }:
|
||||
let
|
||||
bundlerEnv = pkgs.bundlerEnv {
|
||||
name = "${name}-bundler-env";
|
||||
gemdir = src;
|
||||
gemset = gemset;
|
||||
};
|
||||
in
|
||||
pkgs.stdenvNoCC.mkDerivation {
|
||||
pname = name;
|
||||
version = "git";
|
||||
src = src;
|
||||
nativeBuildInputs = [ bundlerEnv ];
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
JEKYLL_ENV=production bundle exec jekyll build -s . -d "$out"
|
||||
runHook postBuild
|
||||
'';
|
||||
installPhase = "true";
|
||||
};
|
||||
|
||||
buildStaticSite = { name, src, subdir ? "" }:
|
||||
let
|
||||
srcPath = if subdir == "" then src else "${src}/${subdir}";
|
||||
in
|
||||
pkgs.stdenvNoCC.mkDerivation {
|
||||
pname = name;
|
||||
version = "git";
|
||||
src = src;
|
||||
dontUnpack = true;
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p "$out"
|
||||
cp -a ${srcPath}/. "$out/"
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
mkDeployService = { name, src, dest }:
|
||||
{
|
||||
description = "Deploy ${name} site";
|
||||
path = [ pkgs.coreutils pkgs.rsync ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
};
|
||||
script = ''
|
||||
install -d -m 755 ${dest}
|
||||
rsync -a --delete ${src}/ ${dest}/
|
||||
'';
|
||||
};
|
||||
|
||||
sublunarSite = buildPelicanSite {
|
||||
name = "sublunar";
|
||||
src = inputs.sublunar;
|
||||
};
|
||||
|
||||
tobiasRaayoniLastSite = buildPelicanSite {
|
||||
name = "tobias-raayoni-last";
|
||||
src = inputs.flux_vision;
|
||||
subdir = "web";
|
||||
};
|
||||
|
||||
nmnsSite = buildPelicanSite {
|
||||
name = "nmns";
|
||||
src = inputs.nfc_web;
|
||||
subdir = "web";
|
||||
};
|
||||
|
||||
scopesessionsSite = buildJekyllSite {
|
||||
name = "scopesessions";
|
||||
src = inputs.scopesessions;
|
||||
gemset = ./scopesessions-gemset.nix;
|
||||
};
|
||||
|
||||
almanacSite = buildStaticSite {
|
||||
name = "sublunar-almanac";
|
||||
src = inputs.sublunar_almanac;
|
||||
};
|
||||
|
||||
praxisSite = buildStaticSite {
|
||||
name = "praxis";
|
||||
src = inputs.praxis;
|
||||
};
|
||||
|
||||
isNixBuild = builtins.getEnv "IN_NIX_BUILD" == "1";
|
||||
in
|
||||
{
|
||||
sops.secrets.codeberg_id_ed25519 = {
|
||||
owner = "root";
|
||||
group = "root";
|
||||
mode = "0400";
|
||||
path = "/etc/ssh/codeberg_id_ed25519";
|
||||
};
|
||||
|
||||
systemd.services."deploy-sublunar" = mkDeployService {
|
||||
name = "sublunar";
|
||||
src = sublunarSite;
|
||||
dest = "/var/www/sublunar.space/public";
|
||||
};
|
||||
|
||||
systemd.services."deploy-tobias-raayoni-last" = mkDeployService {
|
||||
name = "tobias-raayoni-last";
|
||||
src = tobiasRaayoniLastSite;
|
||||
dest = "/var/www/raayoni-last.com/tobias/public";
|
||||
};
|
||||
|
||||
systemd.services."deploy-nmns" = mkDeployService {
|
||||
name = "nmns";
|
||||
src = nmnsSite;
|
||||
dest = "/var/www/nmns.place/public";
|
||||
};
|
||||
|
||||
systemd.services."deploy-scopesessions" = mkDeployService {
|
||||
name = "scopesessions";
|
||||
src = scopesessionsSite;
|
||||
dest = "/var/www/scopesessions.org/public";
|
||||
};
|
||||
|
||||
systemd.services."deploy-almanac" = mkDeployService {
|
||||
name = "almanac";
|
||||
src = almanacSite;
|
||||
dest = "/var/www/sublunar.space/almanac/public";
|
||||
};
|
||||
|
||||
systemd.services."deploy-privatpraxis" = mkDeployService {
|
||||
name = "privatpraxis";
|
||||
src = praxisSite;
|
||||
dest = "/var/www/privatpraxis-last-heidelberg.de/public";
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue