134 lines
3.5 KiB
Nix
134 lines
3.5 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
|
utils.url = "github:numtide/flake-utils";
|
|
confgen.url = "git+https://git.mzte.de/LordMZTE/confgen.git";
|
|
};
|
|
|
|
outputs =
|
|
{ self
|
|
, nixpkgs
|
|
, utils
|
|
, confgen
|
|
,
|
|
}: utils.lib.eachDefaultSystem
|
|
(system:
|
|
let
|
|
pkgs = import nixpkgs { inherit system; };
|
|
in
|
|
rec {
|
|
packages.cmark-lua = pkgs.luajitPackages.callPackage
|
|
(
|
|
{ buildLuarocksPackage
|
|
, fetchurl
|
|
, fetchFromGitHub
|
|
, ...
|
|
}: buildLuarocksPackage rec {
|
|
pname = "cmark-lua";
|
|
version = "0.31.1";
|
|
|
|
knownRockspec = (fetchurl {
|
|
url = "mirror://luarocks/cmark-0.31.1-1.rockspec";
|
|
hash = "sha256-lX+YKIV93Jhx7//9YoVILB9k1N2zKNEQcAfWN/pejQM=";
|
|
}).outPath;
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "jgm";
|
|
repo = pname;
|
|
rev = version;
|
|
hash = "sha256-elI+BYPTlFezkoWLjJyPBsAt2Pq2DRe/+YPmtG27ABY=";
|
|
};
|
|
}
|
|
)
|
|
{ };
|
|
|
|
packages.haxelib-deps = pkgs.stdenvNoCC.mkDerivation {
|
|
name = "haxelib-deps";
|
|
src = ./hx/common.hxml;
|
|
dontUnpack = true;
|
|
|
|
nativeBuildInputs = with pkgs; [ haxe curl git ];
|
|
|
|
buildPhase = ''
|
|
export HOME="$(pwd)"
|
|
echo "$out" > .haxelib
|
|
mkdir "$out"
|
|
{ yes || true; } | haxelib install "$src"
|
|
'';
|
|
|
|
fixupPhase = ''
|
|
# Delete non-deterministic .git directories
|
|
cd "$out"
|
|
find -type d -name .git | xargs rm -rf
|
|
'';
|
|
|
|
GIT_SSL_CAINFO = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
|
|
|
|
outputHashMode = "recursive";
|
|
outputHash = "sha256-FkMEF43ClO2wWg1+P/qD6PX+4zK3+okfsgse9SJ1idk=";
|
|
|
|
};
|
|
|
|
packages.default = pkgs.stdenvNoCC.mkDerivation {
|
|
name = "homepage";
|
|
src = ./.;
|
|
dontFixup = true;
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
confgen.packages.${system}.default
|
|
packages.cmark-lua
|
|
luajitPackages.luafilesystem
|
|
nodePackages.uglify-js
|
|
gnumake
|
|
haxe
|
|
aha
|
|
bat
|
|
];
|
|
|
|
configurePhase = ''
|
|
# Haxelib setup
|
|
export HOME=$TMPDIR
|
|
echo '${packages.haxelib-deps}' > ~/.haxelib
|
|
'';
|
|
|
|
buildPhase = ''
|
|
export XDG_CONFIG_HOME=$src/.config
|
|
export XDG_CACHE_HOME=$TMPDIR
|
|
bat cache --build
|
|
|
|
make -j$(nproc)
|
|
'';
|
|
|
|
installPhase = ''
|
|
chmod -R u+rw build
|
|
mv build $out
|
|
'';
|
|
};
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
buildInputs = with pkgs; [
|
|
luajit
|
|
confgen.packages.${system}.default
|
|
haxe
|
|
nodePackages.uglify-js
|
|
gnumake
|
|
luajitPackages.luafilesystem
|
|
packages.cmark-lua
|
|
aha
|
|
bat
|
|
httplz
|
|
|
|
(pkgs.writeShellScriptBin "serve" ''
|
|
# Mount the site via confgenfs and start an HTTP server.
|
|
# Requires a working FUSE3 installation
|
|
mkdir -p build/cgfs
|
|
|
|
confgenfs confgen.lua build/cgfs &
|
|
httplz build/cgfs
|
|
|
|
fusermount -u build/cgfs
|
|
'')
|
|
];
|
|
};
|
|
});
|
|
}
|