refactor: mkServeFromSite

This commit is contained in:
dusk 2021-05-15 04:15:00 +03:00
parent 947b755595
commit 39f6eb39be
Signed by: dusk
GPG Key ID: 1D8F8FAF2294D6EA
2 changed files with 11 additions and 3 deletions

View File

@ -16,5 +16,7 @@ let
(link "./index.html" "go back")
])
];
site = { "index.html" = index; "ex.html" = ex; };
in
mkServePathScript (mkSitePath { "index.html" = index; "ex.html" = ex; })
mkServeFromSite site

View File

@ -1,6 +1,7 @@
{ utils, pkgs }:
let pkgBin = name: "${pkgs.${name}}/bin/${name}"; in
{
let
pkgBin = name: "${pkgs.${name}}/bin/${name}";
mkServePathScript = path: pkgs.writeScriptBin "serve" ''
#!${pkgs.stdenv.shell}
${pkgBin "miniserve"} --index index.html ${path}
@ -20,4 +21,9 @@ let pkgBin = name: "${pkgs.${name}}/bin/${name}"; in
mkdir -p $out
${concatStringsSep "\n" createFileCmds}
'';
in
{
inherit mkServePathScript mkSitePath;
mkServeFromSite = site: mkServePathScript (mkSitePath site);
}