87 lines
2.1 KiB
Nix
87 lines
2.1 KiB
Nix
{
|
|
inputs= {
|
|
utils.url = "github:numtide/flake-utils";
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
};
|
|
outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
self-pkgs = self.packages.${system};
|
|
|
|
eleventy-shortcut = { name, args ? [] }: pkgs.writeShellApplication {
|
|
inherit name;
|
|
|
|
text = ''
|
|
npx @11ty/eleventy \
|
|
${pkgs.lib.escapeShellArgs args} \
|
|
"$@"
|
|
'';
|
|
|
|
runtimeInputs = [
|
|
pkgs.nodejs_25
|
|
];
|
|
};
|
|
|
|
deploy = pkgs.writeShellApplication {
|
|
name = "deploy";
|
|
|
|
text = ''
|
|
build
|
|
rsyncy --archive _site/* root@pyrope.net:/var/www/static/twopn
|
|
'';
|
|
|
|
runtimeInputs = [
|
|
self-pkgs.build
|
|
pkgs.rsyncy
|
|
];
|
|
};
|
|
|
|
new-post = pkgs.writeShellApplication {
|
|
name = "new-post";
|
|
|
|
text = ''
|
|
if [ $# -lt 1 ]; then
|
|
echo "usage: $0 <slug> [<title> [<description>]]"
|
|
exit 1
|
|
fi
|
|
|
|
filename="$1.mdx"
|
|
title=''${2:-"CHANGEME"}
|
|
description=''${3:-"CHANGEME"}
|
|
|
|
if [ -e "site-src/$filename" ]; then
|
|
echo "$filename already exists!"
|
|
exit 2
|
|
fi
|
|
|
|
# TODO: don't hardcode timezone (%z doesn't quite work)
|
|
cat > "site-src/$filename" <<EOF
|
|
---
|
|
title: $title
|
|
description: $description
|
|
tags: post,short
|
|
date: $(date +'%Y-%m-%d %H:%M:%S -5')
|
|
---
|
|
bla bla bla
|
|
EOF
|
|
'';
|
|
};
|
|
in
|
|
{
|
|
devShell = pkgs.mkShell {
|
|
buildInputs = with pkgs; [
|
|
nodejs_25
|
|
];
|
|
};
|
|
|
|
packages = {
|
|
default = eleventy-shortcut { name = "eleventy"; };
|
|
build = eleventy-shortcut { name = "build"; };
|
|
serve = eleventy-shortcut { name = "serve"; args = ["--serve"]; };
|
|
watch = eleventy-shortcut { name = "watch"; args = ["--watch"]; };
|
|
inherit deploy new-post;
|
|
};
|
|
}
|
|
);
|
|
}
|