-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
109 lines (97 loc) · 3.34 KB
/
Copy pathflake.nix
File metadata and controls
109 lines (97 loc) · 3.34 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
{
description = "Use Pollen Racket to generate static site";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
dream2nix = {
url = "github:nix-community/dream2nix?ref=legacy";
inputs.nixpkgs.follows = "nixpkgs";
};
};
nixConfig = {
extra-substituters = [
"https://garage.cachix.org"
];
extra-trusted-public-keys = [
"garage.cachix.org-1:AH27ths8QR/GZlbFoCQk+Ju3R4U2XepsdQKU3LN0JDA="
];
};
outputs = { self, nixpkgs, dream2nix }:
let
forAllSystems = f: nixpkgs.lib.genAttrs [ "x86_64-linux" ] (system:
f nixpkgs.legacyPackages.${system});
project-outputs = dream2nix.lib.makeFlakeOutputs {
systems = [ "x86_64-linux" ];
config.projectRoot = ./.;
source = ./.;
projects = {
site = {
name = "site";
subsystem = "racket";
translator = "racket-impure";
};
};
};
in
{
apps = forAllSystems (pkgs:
{
thumbnails = {
type = "app";
program = "${pkgs.writeShellScriptBin "manageThumbnails.sh" ''
find ./images/portfolio -regex '.*\.\(jpg\|jxl\)' -printf '%f\n' | sort >./portfolio_files.txt
if [ -f ./portfolio_datetimes.txt ]; then
rm ./portfolio_datetimes.txt
fi
while read pic; do
if [ -f ./images/thumbnails/$pic ]; then
echo " Found thumbnail for $pic"
else
echo " Generating thumbnail for $pic"
${pkgs.imagemagick}/bin/magick ./images/portfolio/$pic -resize 250000@ ./images/thumbnails/$pic
fi
timestamp=$(${pkgs.exif}/bin/exif -t DateTimeOriginal ./images/portfolio/$pic | grep Value | sed 's/[a-zA-Z: ]*//g')
if [ -z $timestamp ]; then
timestamp="0"
fi
echo $timestamp >>./portfolio_datetimes.txt
done <./portfolio_files.txt
for thumbnail in $(ls ./images/thumbnails); do
if [ ! -f ./images/portfolio/$thumbnail ]; then
echo " Removing thumbnail for $thumbnail"
rm ./images/thumbnails/$thumbnail
fi
done
''}/bin/manageThumbnails.sh";
};
});
packages = forAllSystems (pkgs:
let fs = nixpkgs.lib.fileset; in {
default = pkgs.stdenv.mkDerivation {
pname = "site";
version = "0.1.0";
src = fs.toSource {
root = ./.;
fileset = fs.unions (map
(ext: fs.fileFilter (file: file.hasExt ext) ./.)
[ "p" "pp" "pm" "txt" "rkt" "css" "js" ]
);
};
buildInputs = [ project-outputs.packages.${pkgs.system}.site ];
buildPhase = ''
raco pollen render -psf .
'';
installPhase = ''
rm *.txt
raco pollen publish . $out
'';
};
resolveImpure = project-outputs.packages.${pkgs.system}.site.resolve;
});
devShells = forAllSystems (pkgs:
{
default = pkgs.mkShell {
packages = [ project-outputs.packages.${pkgs.system}.site pkgs.exif ];
};
});
};
}