refactor(users/grfn/gws.fyi): implement isDirectory in pure nix

Another day, another import from derivation avoided by
builtins.unsafeDiscardStringContext!

Change-Id: I67274b1ba13ba980bb3346b22f2955c702aa3151
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3372
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
sterni 2021-08-18 11:38:59 +02:00
parent eb6c7fd3bf
commit 32de4cbd93
2 changed files with 67 additions and 10 deletions

View file

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ pkgs, depot, ... }:
with pkgs;
with lib;
@ -22,21 +22,13 @@ let
bn = builtins.baseNameOf src;
filename = elemAt (splitString "." bn) 0;
isDirectory = import (runCommand "isDirectory" {} ''
if [ -d ${src} ]; then
echo "true" > $out
else
echo "false" > $out
fi
'');
outName =
if isNull headline
then
let bn = builtins.baseNameOf src;
filename = elemAt (splitString "." bn) 0;
in
if isDirectory
if depot.nix.utils.isDirectory src
then filename
else filename + ".html"
else "${filename}-${replaceStrings [" "] ["-"] filename}.html";