-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
109 lines (97 loc) · 3.2 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = {
self,
nixpkgs,
flake-utils,
...
}:
{
overlay = final: prev: {
videoconverter = self.packages.${prev.system}.default;
};
}
// flake-utils.lib.eachDefaultSystem (system:
# Instantiating a nixpkgs here as it needs to have `config.allowUnfree = true;`.
# Using https://github.com/numtide/nixpkgs-unfree caused opencv to build from source.
let
pkgs = import "${nixpkgs}" {
config.allowUnfree = true;
inherit system;
};
inherit (pkgs) lib rustPlatform;
nnedi_weights = pkgs.fetchurl {
url = "https://github.com/dubhater/vapoursynth-nnedi3/raw/cc6f6065e09c9241553cb51f10002a7314d66bfa/src/nnedi3_weights.bin";
sha256 = "0hhx4n19qaj3g68f5kqjk23cj063g4y2zidivq9pdfrm0i1q5wr7";
};
videoconverter = {
rustPlatform,
lib,
pkg-config,
ffmpeg,
}:
rustPlatform.buildRustPackage {
name = "videoconverter";
src = lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
# Point to a nixpkgs ffmpeg rather than using the one on $PATH
prePatch = ''
substituteInPlace src/command.rs \
--replace 'const FFMPEG_BIN_PATH: &str = "ffmpeg";'\
'const FFMPEG_BIN_PATH: &str = "${ffmpeg}/bin/ffmpeg";'
substituteInPlace src/interface.rs \
--replace '"~/.ffmpeg/nnedi3_weights"'\
'"${nnedi_weights}"'
'';
nativeBuildInputs = [
pkg-config
rustPlatform.bindgenHook
];
buildInputs = with pkgs; (
[
ffmpeg
]
++ lib.optionals (stdenv.isDarwin) [
libiconv
]
);
inherit ffmpeg;
meta = with lib; {
license = licenses.mpl20;
homepage = "https://github.com/Sciencentistguy/videoconverter";
platforms = ffmpeg.meta.platforms;
};
};
in {
packages.videoconverter = pkgs.callPackage videoconverter {
ffmpeg = pkgs.ffmpeg_7.override {
ffmpegVariant = "full";
withFullDeps = true;
withUnfree = true;
};
};
# Assume that ffmpeg works and I don't need to build it in CI
packages.videoconverter-ci = pkgs.callPackage videoconverter {
ffmpeg = pkgs.ffmpeg_7;
};
packages.nnedi_weights = nnedi_weights;
packages.default = self.packages.${system}.videoconverter;
devShells.default = self.packages.${system}.default.overrideAttrs (super: {
nativeBuildInputs = with pkgs;
super.nativeBuildInputs
++ [
clippy
rustfmt
cargo-edit
];
RUST_SRC_PATH = "${rustPlatform.rustLibSrc}";
});
});
}