mirror of
https://git.sr.ht/~magic_rb/website
synced 2024-11-22 00:04:20 +01:00
Multisite start
Signed-off-by: Magic_RB <magic_rb@redalder.org>
This commit is contained in:
parent
e2249619a8
commit
2edfef83b3
42
flake.nix
42
flake.nix
|
@ -15,13 +15,9 @@
|
||||||
let
|
let
|
||||||
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
|
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
|
||||||
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
|
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
|
||||||
|
site = pkgs: which:
|
||||||
in
|
pkgs.stdenv.mkDerivation {
|
||||||
{
|
name = which;
|
||||||
|
|
||||||
website = pkgs:
|
|
||||||
pkgs.stdenv.mkDerivation {
|
|
||||||
name = "magic_rb-website";
|
|
||||||
version = "0.1";
|
version = "0.1";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
nativeBuildInputs = [ pkgs.emacs ];
|
nativeBuildInputs = [ pkgs.emacs ];
|
||||||
|
@ -30,7 +26,7 @@
|
||||||
cp ${org-thtml}/ox-thtml.el ./ox-thtml.el
|
cp ${org-thtml}/ox-thtml.el ./ox-thtml.el
|
||||||
cp ${emacs-htmlize}/htmlize.el ./htmlize.el
|
cp ${emacs-htmlize}/htmlize.el ./htmlize.el
|
||||||
mkdir tmp && export HOME=$(pwd)/tmp
|
mkdir tmp && export HOME=$(pwd)/tmp
|
||||||
emacs --script ./make.el
|
emacs --script ./make.el -- ${which}
|
||||||
|
|
||||||
find public_html -name 'sitemap.*' -exec rm {} \;
|
find public_html -name 'sitemap.*' -exec rm {} \;
|
||||||
'';
|
'';
|
||||||
|
@ -40,12 +36,36 @@
|
||||||
cp -r public_html/* $out
|
cp -r public_html/* $out
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
in
|
||||||
defaultPackage = forAllSystems (system:
|
{
|
||||||
|
redalder = forAllSystems (system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { inherit system; };
|
||||||
in
|
in
|
||||||
self.website pkgs
|
site pkgs "redalder.org"
|
||||||
|
);
|
||||||
|
|
||||||
|
nixng = forAllSystems (system:
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs { inherit system; };
|
||||||
|
in
|
||||||
|
site pkgs "nixng.org"
|
||||||
|
);
|
||||||
|
|
||||||
|
website = forAllSystems (system:
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs { inherit system; };
|
||||||
|
in
|
||||||
|
pkgs.runCommandNoCC "website" {}
|
||||||
|
''
|
||||||
|
mkdir -p $out/
|
||||||
|
ln -s ${self.redalder.${system}} $out/redalder
|
||||||
|
ln -s ${self.nixng.${system}} $out/nixng
|
||||||
|
''
|
||||||
|
);
|
||||||
|
|
||||||
|
defaultPackage = forAllSystems (system:
|
||||||
|
self.website.${system}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
81
make.el
81
make.el
|
@ -30,11 +30,39 @@
|
||||||
;; org-html-htmlize-output-type 'inline-css
|
;; org-html-htmlize-output-type 'inline-css
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(defvar magic_rb/asset-include
|
||||||
|
"\\(ttf\\|svg\\|jpg\\|gif\\|png\\|css\\|js\\|el\\|nb\\|ipynb\\|pdf\\|xml\\)")
|
||||||
|
|
||||||
|
(defun magic_rb/source-with-name (name symbol property)
|
||||||
|
""
|
||||||
|
(string-trim
|
||||||
|
(org-element-property
|
||||||
|
property
|
||||||
|
(car (let ((path buffer-file-name))
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert-file-contents path)
|
||||||
|
(org-element-map (org-element-parse-buffer) symbol
|
||||||
|
(lambda (object)
|
||||||
|
(let ((block-name (org-element-property :name object)))
|
||||||
|
(if (string-equal block-name name)
|
||||||
|
object
|
||||||
|
nil))))))))))
|
||||||
|
|
||||||
|
;; (org-element-map (org-element-parse-buffer) 'paragraph
|
||||||
|
;; (lambda (paragraph)
|
||||||
|
;; (let ((parent (org-element-property :parent paragraph)))
|
||||||
|
;; (and (eq (org-element-type parent) 'section)
|
||||||
|
;; (let ((first-child (car (org-element-contents parent))))
|
||||||
|
;; (eq first-child paragraph))
|
||||||
|
;; ;; Return value.
|
||||||
|
;; paragraph))))
|
||||||
|
|
||||||
|
|
||||||
(defvar org-publish-project-alist)
|
(defvar org-publish-project-alist)
|
||||||
(setq org-publish-project-alist
|
(setq org-publish-project-alist
|
||||||
`(
|
`(
|
||||||
;; Blog
|
;; Blog
|
||||||
("blog-content"
|
("redalder-blog-content"
|
||||||
:base-directory ,(expand-file-name "./blog/")
|
:base-directory ,(expand-file-name "./blog/")
|
||||||
:base-extension "org"
|
:base-extension "org"
|
||||||
:publishing-directory ,(expand-file-name "./public_html/blog")
|
:publishing-directory ,(expand-file-name "./public_html/blog")
|
||||||
|
@ -53,7 +81,7 @@
|
||||||
:sitemap-title "Magic_RB's blog"
|
:sitemap-title "Magic_RB's blog"
|
||||||
:sitemap-filename "sitemap.inc"
|
:sitemap-filename "sitemap.inc"
|
||||||
:sitemap-sort-files anti-chronologically)
|
:sitemap-sort-files anti-chronologically)
|
||||||
("blog-index"
|
("redalder-blog-index"
|
||||||
:base-directory ,(expand-file-name "./blog/")
|
:base-directory ,(expand-file-name "./blog/")
|
||||||
:root-directory ,(expand-file-name "./blog/")
|
:root-directory ,(expand-file-name "./blog/")
|
||||||
:recursive t
|
:recursive t
|
||||||
|
@ -66,12 +94,12 @@
|
||||||
:with-date nil
|
:with-date nil
|
||||||
:html-template ,(templated-html-load-template "./templates/blog-index.html")
|
:html-template ,(templated-html-load-template "./templates/blog-index.html")
|
||||||
:publishing-function org-html-publish-to-templated-html)
|
:publishing-function org-html-publish-to-templated-html)
|
||||||
("blog"
|
("redalder-blog"
|
||||||
:components ("blog-content" "blog-index"))
|
:components ("redalder-blog-content" "redalder-blog-index"))
|
||||||
|
|
||||||
|
|
||||||
;; Homepage
|
;; Homepage
|
||||||
("homepage"
|
("redalder-homepage"
|
||||||
:base-directory ,(expand-file-name "./home")
|
:base-directory ,(expand-file-name "./home")
|
||||||
:recursive nil
|
:recursive nil
|
||||||
:base-extension "org"
|
:base-extension "org"
|
||||||
|
@ -84,7 +112,7 @@
|
||||||
|
|
||||||
|
|
||||||
;; Contact
|
;; Contact
|
||||||
("contact"
|
("redalder-contact"
|
||||||
:base-directory ,(expand-file-name "./home")
|
:base-directory ,(expand-file-name "./home")
|
||||||
:recursive nil
|
:recursive nil
|
||||||
:base-extension "org"
|
:base-extension "org"
|
||||||
|
@ -96,7 +124,7 @@
|
||||||
:publishing-function org-html-publish-to-templated-html)
|
:publishing-function org-html-publish-to-templated-html)
|
||||||
|
|
||||||
;; Links
|
;; Links
|
||||||
("links"
|
("redalder-links"
|
||||||
:base-directory ,(expand-file-name "./home")
|
:base-directory ,(expand-file-name "./home")
|
||||||
:recursive nil
|
:recursive nil
|
||||||
:base-extension "org"
|
:base-extension "org"
|
||||||
|
@ -107,19 +135,46 @@
|
||||||
:html-template ,(templated-html-load-template "./templates/empty.html")
|
:html-template ,(templated-html-load-template "./templates/empty.html")
|
||||||
:publishing-function org-html-publish-to-templated-html)
|
:publishing-function org-html-publish-to-templated-html)
|
||||||
|
|
||||||
;; Static images and css and js
|
;; Static images and css and js for redalder.org
|
||||||
("assets"
|
("redalder-assets"
|
||||||
:base-directory ,(expand-file-name "./assets/")
|
:base-directory ,(expand-file-name "./assets/")
|
||||||
:publishing-directory ,(expand-file-name "./public_html/")
|
:publishing-directory ,(expand-file-name "./public_html/")
|
||||||
:recursive t
|
:recursive t
|
||||||
:base-extension "\\(ttf\\|svg\\|jpg\\|gif\\|png\\|css\\|js\\|el\\|nb\\|ipynb\\|pdf\\|xml\\)"
|
:base-extension ,magic_rb/asset-include
|
||||||
|
:publishing-function org-publish-attachment)
|
||||||
|
|
||||||
|
|
||||||
|
("nixng-examples"
|
||||||
|
:base-directory ,(expand-file-name "./nixng/examples/")
|
||||||
|
:base-extension "org"
|
||||||
|
:publishing-directory ,(expand-file-name "./public_html/")
|
||||||
|
:html-template ,(templated-html-load-template "./templates/example.html")
|
||||||
|
:publishing-function org-html-publish-to-templated-html)
|
||||||
|
|
||||||
|
;; Static images and css and js for nixng.org
|
||||||
|
("nixng-assets"
|
||||||
|
:base-directory ,(expand-file-name "./assets/")
|
||||||
|
:publishing-directory ,(expand-file-name "./public_html/")
|
||||||
|
:recursive t
|
||||||
|
:base-extension ,magic_rb/asset-include
|
||||||
:publishing-function org-publish-attachment)
|
:publishing-function org-publish-attachment)
|
||||||
|
|
||||||
;; top-level trigger
|
;; top-level trigger
|
||||||
("publish"
|
("redalder-publish"
|
||||||
:components ("blog" "assets" "homepage" "contact" "links"))))
|
:components ("redalder-blog"
|
||||||
|
"redalder-assets"
|
||||||
|
"redalder-homepage"
|
||||||
|
"redalder-contact"
|
||||||
|
"redalder-links"))
|
||||||
|
|
||||||
(org-publish "publish" t)
|
("nixng-publish"
|
||||||
|
:components ("nixng-assets"
|
||||||
|
"nixng-examples"))))
|
||||||
|
|
||||||
|
(cond ((member "redalder.org" command-line-args-left)
|
||||||
|
(org-publish "redalder-publish" t))
|
||||||
|
((member "nixng.org" command-line-args-left)
|
||||||
|
(org-publish "nixng-publish")))
|
||||||
|
|
||||||
(provide 'make)
|
(provide 'make)
|
||||||
;;; make.el ends here
|
;;; make.el ends here
|
||||||
|
|
102
nixng/examples/apache.org
Normal file
102
nixng/examples/apache.org
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
#+NAME: example
|
||||||
|
#+BEGIN_SRC nix :exports none
|
||||||
|
nglib:
|
||||||
|
(nglib "x86_64-linux").makeSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
name = "nixng-apache";
|
||||||
|
config = ({ pkgs, config, ... }:
|
||||||
|
let
|
||||||
|
ids = config.ids;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
dumb-init = {
|
||||||
|
enable = true;
|
||||||
|
type.services = {};
|
||||||
|
};
|
||||||
|
init.services.apache2 = {
|
||||||
|
shutdownOnExit = true;
|
||||||
|
ensureSomething.link."documentRoot" = {
|
||||||
|
src = "${pkgs.apacheHttpd}/htdocs";
|
||||||
|
dst = "/var/www";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
services.apache2 = {
|
||||||
|
enable = true;
|
||||||
|
envsubst = true;
|
||||||
|
configuration = [
|
||||||
|
{
|
||||||
|
LoadModule = [
|
||||||
|
[ "mpm_event_module" "modules/mod_mpm_event.so" ]
|
||||||
|
[ "log_config_module" "modules/mod_log_config.so" ]
|
||||||
|
[ "unixd_module" "modules/mod_unixd.so" ]
|
||||||
|
[ "authz_core_module" "modules/mod_authz_core.so" ]
|
||||||
|
[ "dir_module" "modules/mod_dir.so" ]
|
||||||
|
[ "mime_module" "modules/mod_mime.so" ]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Listen = "0.0.0.0:80";
|
||||||
|
|
||||||
|
ServerRoot = "/var/www";
|
||||||
|
ServerName = "blowhole";
|
||||||
|
PidFile = "/httpd.pid";
|
||||||
|
|
||||||
|
DocumentRoot = "/var/www";
|
||||||
|
|
||||||
|
User = "www-data";
|
||||||
|
Group = "www-data";
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ErrorLog = "/dev/stderr";
|
||||||
|
TransferLog = "/dev/stdout";
|
||||||
|
|
||||||
|
LogLevel = "info";
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
AddType = [
|
||||||
|
[ "image/svg+xml" "svg" "svgz" ]
|
||||||
|
];
|
||||||
|
AddEncoding = [ "gzip" "svgz" ];
|
||||||
|
|
||||||
|
TypesConfig = "${pkgs.apacheHttpd}/conf/mime.types";
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Directory = {
|
||||||
|
"/" = {
|
||||||
|
Require = [ "all" "denied" ];
|
||||||
|
Options = "SymlinksIfOwnerMatch";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
VirtualHost = {
|
||||||
|
"*:80" = {
|
||||||
|
Directory = {
|
||||||
|
"/var/www" = {
|
||||||
|
Require = [ "all" "granted" ];
|
||||||
|
Options = [ "-Indexes" "+FollowSymlinks" ];
|
||||||
|
DirectoryIndex = "\${DIRECTORY_INDEX:-index.html}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
#+NAME: command-docker
|
||||||
|
#+BEGIN_SRC fundamental
|
||||||
|
nix run git+https://gitea.redalder.org/Magic_RB/NixNG?rev=d5146db73cfd31712950608560a387ad71243cee#nginxSystem.config.system.build.ociImage.stream && ./result | docker load
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
#+NAME: command-podman
|
||||||
|
#+BEGIN_SRC fundamental
|
||||||
|
nix run git+https://gitea.redalder.org/Magic_RB/NixNG?rev=d5146db73cfd31712950608560a387ad71243cee#nginxSystem.config.system.build.ociImage.stream && ./result | podman load
|
||||||
|
#+END_SRC
|
26
templates/example.html
Normal file
26
templates/example.html
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
{{:include "head.html"}}
|
||||||
|
<body>
|
||||||
|
{{:include "navbar.html"}}
|
||||||
|
<div id="organizer">
|
||||||
|
<div class="sidebar">{{org-html-toc 2 info}}</div>
|
||||||
|
<div id="content" class="textual">
|
||||||
|
{{:if with-title}}<h1>{{title}}</h1>{{:endif}}
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
{{magic_rb/source-with-name "example" 'src-block :value}}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
{{magic_rb/source-with-name "command-docker" 'src-block :value}}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
{{magic_rb/source-with-name "command-podman" 'src-block :value}}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
<div class="sidebar"></div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in a new issue