-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
134 lines (119 loc) · 4.4 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
description = "A flake for my photography stuff";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
};
outputs = inputs@{ self, nixpkgs, ... }:let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
t = lib.trivial;
hl = pkgs.haskell.lib;
extraLibraries = with pkgs; [
self.packages.${system}.focus-stack # main aligning and focus stacking
hugin # provides align_image_stack, for alternative aligning
glew # for parallel processing
enblend-enfuse # provides enfuse, for alternative focus stacking
imagemagick # for composing colages and more
exiftool # for extracting metadata
ffmpeg-headless # for extracting imgs from video
libraw # for converting raw files like ARW to tiff, provides dcraw_emu
libheif # for converting heif files
];
project = devTools:
let addBuildTools = (t.flip hl.addBuildTools) devTools;
addExtraLibraries = (t.flip hl.addExtraLibraries) extraLibraries;
in pkgs.haskellPackages.developPackage {
root = ./.;
name = "myphoto-unwrapped";
returnShellEnv = !(devTools == [ ]);
modifier = (t.flip t.pipe) [
addBuildTools
addExtraLibraries
hl.dontHaddock
hl.enableStaticLibraries
hl.justStaticExecutables
hl.disableLibraryProfiling
hl.disableExecutableProfiling
((t.flip hl.appendBuildFlags) ["--ghc-options=\" -threaded -rtsopts -with-rtsopts=-N\"" "+RTS"])
];
};
in {
packages.${system} = {
focus-stack = pkgs.focus-stack.overrideDerivation (oldAttrs: {
version = "master";
src = ./PetteriAimonen-focus-stack;
});
myphoto-unwrapped = project [];
myphoto-stack-from-github = pkgs.writeShellScriptBin "myphoto-gh-stack" ''
exec nix run --refresh "github:maxhbr/myphoto"#myphoto-stack -- "$@"
'';
myphoto-watch-from-github = pkgs.writeShellScriptBin "myphoto-gh-watch" ''
exec nix run --refresh "github:maxhbr/myphoto"#myphoto-watch -- "$@"
'';
myphoto = pkgs.buildEnv {
name = "myphoto";
paths = [ self.packages.${system}.myphoto-stack-from-github self.packages.${system}.myphoto-watch-from-github ];
pathsToLink = [ "/bin" "/share" ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
mkdir -p $out/bin
makeWrapper ${self.packages.${system}.myphoto-unwrapped}/bin/myphoto-stack $out/bin/myphoto-stack \
--set PATH ${pkgs.lib.makeBinPath extraLibraries}
makeWrapper ${self.packages.${system}.myphoto-unwrapped}/bin/myphoto-stack $out/bin/myphoto-stack-inplace \
--set PATH ${pkgs.lib.makeBinPath extraLibraries} \
--add-flags "--inplace"
makeWrapper ${self.packages.${system}.myphoto-unwrapped}/bin/myphoto-stack $out/bin/myphoto-stack-replace \
--set PATH ${pkgs.lib.makeBinPath extraLibraries} \
--add-flags "--replace"
makeWrapper ${self.packages.${system}.myphoto-unwrapped}/bin/myphoto-stack $out/bin/myphoto-stack-dirs \
--set PATH ${pkgs.lib.makeBinPath extraLibraries} \
--add-flags "--dirs"
makeWrapper ${self.packages.${system}.myphoto-unwrapped}/bin/myphoto-watch $out/bin/myphoto-watch \
--set PATH ${pkgs.lib.makeBinPath extraLibraries}
'';
};
default = self.packages.${system}.myphoto;
};
apps.${system} = {
myphoto-stack = {
type = "app";
program = "${self.packages.${system}.myphoto}/bin/myphoto-stack";
};
myphoto-watch = {
type = "app";
program = "${self.packages.${system}.myphoto}/bin/myphoto-watch";
};
};
devShell.${system} = project (with pkgs.haskellPackages; [
cabal-fmt
cabal-install
haskell-language-server
hlint
ghcid
]);
homeManagerModules.myphoto = (
{
config,
lib,
pkgs,
...
}: let
inherit (pkgs.stdenv.hostPlatform) system;
in {
config = {
home.packages = (with pkgs; [
gphoto2
gphoto2fs
gimp # -with-plugins
darktable
geeqie
]) ++ (with self.packages.${system}; [
focus-stack
myphoto
]);
};
}
);
};
}