-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
92 lines (83 loc) · 2.71 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{
description = "Grace Bobber's Website";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-utils.inputs.nixpkgs.follows = "nixpkgs";
gitignore.url = "github:hercules-ci/gitignore.nix";
gitignore.inputs.nixpkgs.follows = "nixpkgs";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
nixpkgs,
flake-utils,
gitignore,
rust-overlay,
}:
flake-utils.lib.eachDefaultSystem (system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {
inherit system overlays;
};
revision = "${self.lastModifiedDate}-${self.shortRev or "dirty"}";
inherit (gitignore.lib) gitignoreSource;
htmlSource = pkgs.stdenv.mkDerivation {
name = "gracebobberdotcom";
src = gitignoreSource ./.;
preferLocalBuild = true;
buildInputs = [pkgs.exiftool];
buildPhase = ''
exiftool -Title="Grace Bobber Resume" -q -P -overwrite_original_in_place ./images/Grace-Bobber-Resume.pdf
'';
installPhase = ''
mkdir $out
cp -r ./* $out/
'';
};
images_folder = "images";
dist_images_folder = "dist/images";
thumbnails_folder = "thumbnails";
optimizejpg = pkgs.writeShellScriptBin "optimizejpg" ''
for img in $(${pkgs.fd}/bin/fd -e jpg -e jpeg . ${images_folder});
do
${pkgs.jpegoptim}/bin/jpegoptim --dest="${dist_images_folder}" \
--overwrite \
--all-progressive \
--strip-all \
--max=90 \
--force \
$img
${pkgs.jpegoptim}/bin/jpegoptim --dest=${thumbnails_folder} \
--overwrite \
--all-progressive \
--strip-all \
--size=10% \
--force \
$img
done
'';
optimizepng = pkgs.writeShellScriptBin "optimizepng" ''
for img in $( ${pkgs.fd}/bin/fd -e png . ${images_folder} );
do
${pkgs.optipng}/bin/optipng $img -dir ${dist_images_folder} -clobber
${pkgs.optipng}/bin/optipng $img -dir ${thumbnails_folder} -o 7 -clobber
done
'';
in rec {
devShell = pkgs.mkShell {
buildInputs = with pkgs;
with nodePackages; [
nodejs
fd
exiftool
nodePackages.prettier
netlify-cli
ffmpeg
optimizepng
optimizejpg
];
};
});
}