Add lib/generators.nix

This commit is contained in:
Henrik Lissner 2020-10-17 23:37:47 -04:00
parent df1a899d6d
commit 93b1a4bfed
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

30
lib/generators.nix Normal file
View file

@ -0,0 +1,30 @@
{ lib, pkgs, ... }:
with builtins;
with lib;
{
toCSSFile = file:
let fileName = baseNameOf file;
compiledStyles =
pkgs.runCommand "compileScssFile"
{ buildInputs = [ sass ]; } ''
mkdir "$out"
scss --sourcekkmap=none \
--no-cache \
--style compressed \
--default-encoding utf-8 \
"${file}" \
>>"$out/${fileName}.css"
'';
in "${compiledStyles}/${fileName}";
toFilteredImage = imageFile: options:
let result = "result.png";
filteredImage =
pkgs.runCommand "filterWallpaper"
{ buildInputs = [ pkgs.imagemagick ]; } ''
mkdir "$out"
convert ${options} ${imageFile} $out/${result}
'';
in "${filteredImage}/${result}";
}