mirror of
https://git.sr.ht/~magic_rb/website
synced 2024-11-25 09:36:14 +01:00
a0fe578168
Signed-off-by: Magic_RB <magic_rb@redalder.org>
189 lines
5.6 KiB
Nix
189 lines
5.6 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
|
|
|
|
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; };
|
|
yaml-mode = { url = "github:yoshiki/yaml-mode"; flake = false; };
|
|
nix-mode = { url = "github:NixOS/nix-mode"; flake = false; };
|
|
magit = { url = "github:magit/magit"; flake = false; };
|
|
compat = { url = "github:emacs-straight/compat"; flake = false; };
|
|
dash = { url = "github:magnars/dash.el"; flake = false; };
|
|
s-el = { url = "github:magnars/s.el"; flake = false; };
|
|
dockerfile-mode = { url = "github:spotify/dockerfile-mode"; flake = false; };
|
|
org-special-block-extras = { url = "github:alhassy/org-special-block-extras"; flake = false; };
|
|
lf = { url = "github:alhassy/lf"; flake = false; };
|
|
};
|
|
|
|
outputs = { self
|
|
, nixpkgs
|
|
, nixng
|
|
, org-thtml
|
|
, emacs-htmlize
|
|
, modus-themes
|
|
, web-mode
|
|
, hcl-mode
|
|
, yaml-mode
|
|
, nix-mode
|
|
, magit
|
|
, compat
|
|
, dash
|
|
, s-el
|
|
, dockerfile-mode
|
|
, org-special-block-extras
|
|
, lf
|
|
, ...
|
|
}@inputs:
|
|
let
|
|
inherit (nixpkgs.lib)
|
|
genAttrs
|
|
concatMapStringsSep;
|
|
|
|
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
|
|
forAllSystems = f: genAttrs supportedSystems (system: f system);
|
|
packages = [
|
|
"modus-themes"
|
|
"org-thtml"
|
|
"emacs-htmlize"
|
|
"web-mode"
|
|
"hcl-mode"
|
|
"modus-themes"
|
|
"yaml-mode"
|
|
"nix-mode"
|
|
"magit"
|
|
"compat"
|
|
"dash"
|
|
"s-el"
|
|
"dockerfile-mode"
|
|
"org-special-block-extras"
|
|
"lf"
|
|
];
|
|
loadPackages = pkgs:
|
|
pkgs.writeText "packages.el"
|
|
(concatMapStringsSep "\n" (x: ''
|
|
(if (file-exists-p "${inputs.${x}}/lisp")
|
|
(add-to-list 'load-path "${inputs.${x}}/lisp")
|
|
(add-to-list 'load-path "${inputs.${x}}"))
|
|
'') packages);
|
|
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 --debug-init &
|
|
|
|
timeout 10 bash -c 'until [ -e $TMPDIR/emacs$(id -u) ] ; do sleep 0.1 ; done'
|
|
|
|
emacsclient -e $'(load-file "${loadPackages pkgs}")'
|
|
|
|
emacsclient -e $'(add-to-list \'load-path "'"$(pwd)"'/lisp")'
|
|
|
|
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"
|
|
''
|
|
(load-file "${loadPackages pkgs}")
|
|
|
|
(require 'nix-mode)
|
|
(require 'web-mode)
|
|
(require 'hcl-mode)
|
|
(require 'yaml-mode)
|
|
|
|
(require 'org)
|
|
(require 'ox)
|
|
(require 'ox-html)
|
|
(require 'modus-themes)
|
|
|
|
(defface modus-themes-cyan-subtle
|
|
'((t :inherit modus-themes-subtle-cyan))
|
|
"")
|
|
|
|
(load-theme 'modus-vivendi 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 ${builtins.trace "modus: ${modus-themes}" script} --debug-init
|
|
|
|
mv $OUTFILE ./assets/css/org.css
|
|
|
|
rm -r $TMPDIR
|
|
''
|
|
);
|
|
|
|
defaultPackage = forAllSystems (system:
|
|
self.website.${system}
|
|
);
|
|
|
|
devShells = forAllSystems (system:
|
|
let pkgs = import nixpkgs { inherit system; };
|
|
in
|
|
{
|
|
default = pkgs.mkShell {
|
|
nativeBuildInputs = with pkgs; [
|
|
httplz
|
|
];
|
|
};
|
|
}
|
|
);
|
|
};
|
|
}
|