This repository has been archived on 2022-09-16. You can view files and clone it, but cannot push or open issues or pull requests.
tlaternet-templates/flake.nix

73 lines
2 KiB
Nix

{
description = "tlater.net web server contents";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }@inputs:
flake-utils.lib.simpleFlake {
inherit self nixpkgs;
name = "tlaternet-templates";
overlay = final: prev: {
tlaternet-templates = rec {
packages = rec {
nodeEnv = prev.callPackage ./nix/override.nix { pkgs = prev; };
templates = prev.callPackage ({ stdenv, nodejs, rename, ... }:
let nodeDeps = nodeEnv.shell.nodeDependencies;
in stdenv.mkDerivation {
name = "tlaternet-templates";
src = ./.;
buildInputs = [ nodejs rename ];
buildPhase = ''
ln -s ${nodeDeps}/lib/node_modules ./node_modules
export PATH="${nodeDeps}/bin:$PATH"
npm run build
'';
installPhase = ''
cp -r dist $out/
'';
postFixup = ''
rename 's/.html$/.html.hbs/' $out/browser/*.html
'';
}) { };
};
defaultPackage = packages.templates;
devShell = prev.mkShell {
buildInputs = with prev;
with nodePackages;
[
nodejs
node2nix
# Handy dev tools
prettier
typescript
typescript-language-server
] ++ packages.nodeEnv.shell.buildInputs;
};
# TODO: This would be the ideal. Sadly, parcel isn't smart
# enough to pull its plugins from $NODE_PATH.
#
#
# devShell = packages.nodeEnv.shell.override {
# buildInputs = with prev; with nodePackages; [
# node2nix
# prettier
# typescript-language-server
# ];
# };
};
};
};
}