mirror of
https://git.sr.ht/~magic_rb/website
synced 2024-11-22 08:04:21 +01:00
f34d6fa4fa
Signed-off-by: Magic_RB <magic_rb@redalder.org>
125 lines
3.8 KiB
Nix
125 lines
3.8 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "nixpkgs";
|
|
|
|
org-thtml = { url = "github:juanjosegarciaripoll/org-thtml"; flake = false; };
|
|
emacs-htmlize = { url = "github:hniksic/emacs-htmlize"; flake = false; };
|
|
modus-themes = { url = "github:protesilaos/modus-themes"; flake = false; };
|
|
web-mode = { url = "github:fxbois/web-mode"; flake = false; };
|
|
hcl-mode = { url = "github:purcell/emacs-hcl-mode"; flake = false; };
|
|
};
|
|
|
|
outputs = { self
|
|
, nixpkgs
|
|
, nixng
|
|
, org-thtml
|
|
, emacs-htmlize
|
|
, modus-themes
|
|
, web-mode
|
|
, hcl-mode
|
|
, ...
|
|
}@inputs:
|
|
let
|
|
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
|
|
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
|
|
site = pkgs: which:
|
|
pkgs.stdenv.mkDerivation {
|
|
name = which;
|
|
version = "0.1";
|
|
src = ./.;
|
|
nativeBuildInputs = [ pkgs.utillinux pkgs.emacs ];
|
|
|
|
buildPhase = ''
|
|
export TMPDIR="$(mktemp -d)" HOME=$(pwd)/tmp
|
|
emacs -nw --fg-daemon &
|
|
|
|
timeout 10 bash -c 'until [ -e $TMPDIR/emacs$(id -u) ] ; do sleep 0.1 ; done'
|
|
|
|
emacsclient -e $'(add-to-list \'load-path "${org-thtml}")'
|
|
emacsclient -e $'(add-to-list \'load-path "${modus-themes}")'
|
|
emacsclient -e $'(add-to-list \'load-path "${emacs-htmlize}")'
|
|
emacsclient -e $'(add-to-list \'load-path "${web-mode}")'
|
|
emacsclient -e $'(add-to-list \'load-path "${hcl-mode}")'
|
|
|
|
emacsclient -e '(load-file "./make.el")'
|
|
emacsclient -e '(magic_rb/publish-website "${which}")'
|
|
emacsclient -e '(kill-emacs)'
|
|
|
|
find public_html -name 'sitemap.*' -exec rm {} \;
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir -p $out
|
|
cp -r public_html/* $out
|
|
'';
|
|
};
|
|
in
|
|
{
|
|
redalder = forAllSystems (system:
|
|
let
|
|
pkgs = import nixpkgs { inherit system; };
|
|
in
|
|
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
|
|
''
|
|
);
|
|
|
|
generateCss = forAllSystems (system:
|
|
let
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
script = pkgs.writeText "init.el"
|
|
''
|
|
(add-to-list 'load-path "${modus-themes}")
|
|
(add-to-list 'load-path "${emacs-htmlize}")
|
|
|
|
(require 'org)
|
|
(require 'ox)
|
|
(require 'ox-html)
|
|
(require 'modus-themes)
|
|
|
|
(load-theme 'modus-operandi t nil)
|
|
|
|
(org-html-htmlize-generate-css)
|
|
(with-current-buffer "*html*"
|
|
(write-file (getenv "OUTFILE")))
|
|
|
|
(kill-emacs)
|
|
'';
|
|
in
|
|
pkgs.writeShellScript "generate-css"
|
|
''
|
|
export PATH=$PATH:${pkgs.emacs}/bin
|
|
|
|
export OUTFILE="$(mktemp)" TMPDIR="$(mktemp -d)" HOME=$TMPDIR
|
|
emacs -l ${script}
|
|
|
|
mv $OUTFILE ./assets/css/org.css
|
|
|
|
rm -r $TMPDIR
|
|
''
|
|
);
|
|
|
|
defaultPackage = forAllSystems (system:
|
|
self.website.${system}
|
|
);
|
|
};
|
|
}
|