mirror of
https://git.sr.ht/~magic_rb/website
synced 2024-11-23 08:37:39 +01:00
242 lines
5.6 KiB
Nix
242 lines
5.6 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
|
|
|
|
org-thtml = {
|
|
url = "github:MagicRB/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
|
|
fix
|
|
getExe
|
|
;
|
|
|
|
supportedSystems = ["x86_64-linux" "i686-linux" "aarch64-linux"];
|
|
forAllSystems = f: genAttrs supportedSystems (system: f system);
|
|
packages = [
|
|
"modus-themes"
|
|
"org-thtml"
|
|
"emacs-htmlize"
|
|
"magit"
|
|
"web-mode"
|
|
"hcl-mode"
|
|
"yaml-mode"
|
|
"nix-mode"
|
|
"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)
|
|
+ "\n"
|
|
+ (concatMapStringsSep "\n" (x: ''
|
|
(when (string-match-p "^.*-mode$" "${x}")
|
|
(require '${x}))
|
|
'')
|
|
packages));
|
|
site = pkgs: which:
|
|
pkgs.stdenv.mkDerivation {
|
|
name = which;
|
|
version = "0.1";
|
|
src = ./.;
|
|
nativeBuildInputs = [pkgs.utillinux pkgs.emacs];
|
|
|
|
# xvfb-run -s '-screen 0 800x600x24' make test
|
|
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 {
|
|
apps = forAllSystems (
|
|
system: let
|
|
pkgs = import nixpkgs {inherit system;};
|
|
in {
|
|
live-server = {
|
|
type = "app";
|
|
program = toString (pkgs.writeShellScript "live-server.sh" ''
|
|
nix build .#
|
|
${getExe pkgs.nodePackages.live-server} result/redalder "$@"
|
|
'');
|
|
};
|
|
|
|
generateCSS = let
|
|
script =
|
|
pkgs.writeText "init.el"
|
|
''
|
|
(load-file "${loadPackages pkgs}")
|
|
|
|
(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 {
|
|
type = "app";
|
|
program = toString (
|
|
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
|
|
''
|
|
);
|
|
};
|
|
}
|
|
);
|
|
|
|
packages = forAllSystems (
|
|
system: let
|
|
pkgs = import nixpkgs {inherit system;};
|
|
in
|
|
fix (this: {
|
|
redalder = site pkgs "redalder.org";
|
|
nixng = site pkgs "nixng.org";
|
|
|
|
website =
|
|
pkgs.runCommandNoCC "website" {}
|
|
''
|
|
mkdir -p $out/
|
|
ln -s ${this.redalder} $out/redalder
|
|
ln -s ${this.nixng} $out/nixng
|
|
'';
|
|
|
|
default = this.website;
|
|
})
|
|
);
|
|
|
|
devShells = forAllSystems (
|
|
system: let
|
|
pkgs = import nixpkgs {inherit system;};
|
|
in {
|
|
default = pkgs.mkShell {
|
|
nativeBuildInputs = with pkgs; [
|
|
httplz
|
|
alejandra
|
|
];
|
|
};
|
|
}
|
|
);
|
|
};
|
|
}
|