-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
86 lines (81 loc) · 2.01 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
{
description = "Hoverbear.org";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
};
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
in
{
overlay = final: prev: {
image-optimize = final.writeShellApplication {
name = "image-optimize";
runtimeInputs = with final; [
bash
fd
jpegoptim
optipng
];
text = ''
fd \
--exclude static/processed_images \
--extension jpg \
--extension jpeg \
--threads "$(nproc)" \
--exec jpegoptim
fd \
--exclude static/processed_images \
--extension png \
--threads "$(nproc)" \
--exec optipng
'';
};
};
packages = forAllSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlay
];
};
in
{
inherit (pkgs) image-optimize;
});
checks = forAllSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlay
];
};
in
{
format = pkgs.runCommand "check-format"
{ } ''
${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.}
touch $out # it worked!
'';
});
devShell = forAllSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlay
];
};
in
pkgs.mkShell {
buildInputs = with pkgs; [
nixpkgs-fmt
zola
image-optimize
];
});
};
}