refactor: mkServeFromSite
This commit is contained in:
parent
947b755595
commit
39f6eb39be
@ -16,5 +16,7 @@ let
|
|||||||
(link "./index.html" "go back")
|
(link "./index.html" "go back")
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
|
|
||||||
|
site = { "index.html" = index; "ex.html" = ex; };
|
||||||
in
|
in
|
||||||
mkServePathScript (mkSitePath { "index.html" = index; "ex.html" = ex; })
|
mkServeFromSite site
|
||||||
|
10
pkgs-lib.nix
10
pkgs-lib.nix
@ -1,6 +1,7 @@
|
|||||||
{ utils, pkgs }:
|
{ utils, pkgs }:
|
||||||
let pkgBin = name: "${pkgs.${name}}/bin/${name}"; in
|
let
|
||||||
{
|
pkgBin = name: "${pkgs.${name}}/bin/${name}";
|
||||||
|
|
||||||
mkServePathScript = path: pkgs.writeScriptBin "serve" ''
|
mkServePathScript = path: pkgs.writeScriptBin "serve" ''
|
||||||
#!${pkgs.stdenv.shell}
|
#!${pkgs.stdenv.shell}
|
||||||
${pkgBin "miniserve"} --index index.html ${path}
|
${pkgBin "miniserve"} --index index.html ${path}
|
||||||
@ -20,4 +21,9 @@ let pkgBin = name: "${pkgs.${name}}/bin/${name}"; in
|
|||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
${concatStringsSep "\n" createFileCmds}
|
${concatStringsSep "\n" createFileCmds}
|
||||||
'';
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit mkServePathScript mkSitePath;
|
||||||
|
|
||||||
|
mkServeFromSite = site: mkServePathScript (mkSitePath site);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user