|
3 | 3 |
|
4 | 4 | with lib;
|
5 | 5 |
|
6 |
| -let generatePalette = |
7 |
| - { image, polarity }: |
8 |
| - # TODO: make base16.nix able to load this file directly, rather than importing it here |
9 |
| - let palette = pkgs.runCommand "palette.json" { } '' |
10 |
| - ${palette-generator}/bin/palette-generator ${polarity} ${image} $out |
11 |
| - ''; |
12 |
| - in importJSON palette; |
| 6 | +let |
| 7 | + generatePalette = |
| 8 | + { image, polarity }: |
| 9 | + # TODO: make base16.nix able to load this file directly, rather than importing it here |
| 10 | + let palette = pkgs.runCommand "palette.json" { } '' |
| 11 | + ${palette-generator}/bin/palette-generator ${polarity} ${image} $out |
| 12 | + ''; |
| 13 | + in importJSON palette; |
| 14 | + |
| 15 | + extractFirstFrame = |
| 16 | + input: |
| 17 | + pkgs.runCommand "first-frame.png" { } '' |
| 18 | + ${pkgs.ffmpeg}/bin/ffmpeg -i ${input} -vf 'select=eq(n\,0)' -vframes 1 $out |
| 19 | + ''; |
13 | 20 |
|
14 | 21 | in {
|
15 | 22 | config.lib.stylix = {
|
|
30 | 37 |
|
31 | 38 | mkAnimation =
|
32 | 39 | { animation, polarity ? "either" }:
|
33 |
| - let image = pkgs.runCommand "image.png" { } '' |
34 |
| - ${pkgs.ffmpeg}/bin/ffmpeg -i ${animation} -vf "select=eq(n\,0)" -q:v 3 -f image2 $out |
35 |
| - ''; |
36 |
| - in { |
37 |
| - inherit image animation; |
| 40 | + rec { |
| 41 | + inherit animation; |
| 42 | + image = extractFirstFrame animation; |
38 | 43 | colors = generatePalette { inherit image polarity; };
|
39 | 44 | };
|
40 | 45 |
|
41 | 46 | mkVideo =
|
42 | 47 | { video, polarity ? "either" }:
|
43 |
| - let image = pkgs.runCommand "image.png" { } '' |
44 |
| - ${pkgs.ffmpeg}/bin/ffmpeg -i ${video} -vf "select=eq(n\,0)" -q:v 3 -f image2 $out |
45 |
| - ''; |
46 |
| - in { |
47 |
| - inherit image video; |
| 48 | + rec { |
| 49 | + inherit video; |
| 50 | + image = extractFirstFrame video; |
48 | 51 | colors = generatePalette { inherit image polarity; };
|
49 | 52 | };
|
50 | 53 |
|
51 | 54 | mkSlideshow =
|
52 | 55 | { images, delay ? 300, polarity ? "either" }:
|
53 |
| - let image = builtins.elemAt images 0; |
54 |
| - in { |
55 |
| - inherit image images delay; |
| 56 | + rec { |
| 57 | + inherit images delay; |
| 58 | + image = builtins.elemAt images 0; |
56 | 59 | colors = generatePalette { inherit image polarity; };
|
57 | 60 | };
|
58 | 61 | };
|
|
0 commit comments