-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
85 lines (66 loc) · 2.06 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
{
description = "Documentation for FFmpeg filters.";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils.url =
"github:numtide/flake-utils/1ef2e671c3b0c19053962c07dbda38332dcebf26";
};
outputs = { self, nixpkgs, flake-utils, }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
bin-name = "ffmpeg-filters-docs";
ruby-env = pkgs.bundlerEnv {
name = "docs-builder";
ruby = pkgs.ruby_3_2;
gemset = ./.nix/gemset.nix;
gemdir = ./.;
};
deps = with pkgs; [
ruby-env
ruby-env.wrappedRuby
git
librsvg
optipng
saxonb_9_1
texinfo
zstd
];
shellDeps = let
# Make a wrapper script to set GEM_PATH with the gems from the bundle.
gemWrapper = gem:
pkgs.writeShellScriptBin gem ''
export GEM_PATH="$(
bundle exec ruby -e \
'print Gem.loaded_specs.values.map(&:full_gem_path)*?:'
)"
exec ruby ${pkgs.rubyPackages_3_2.${gem}}/bin/${gem} "$@"
'';
in [
pkgs.bundix
(gemWrapper "solargraph") # LSP
(gemWrapper "yard")
];
in {
formatter = pkgs.nixfmt-classic;
packages.default = pkgs.stdenv.mkDerivation {
name = bin-name;
src = ./.;
buildInputs = deps;
installPhase = ''
mkdir -p "$out"/{source,bin}
cp -a "${bin-name}" README.md lib "$out/source"
bin="$out/bin/${bin-name}"
{
echo '#!/bin/bash'
printf '\nPATH=%q\n\n' "$PATH"
printf 'exec %q %q "$@"\n' \
'${ruby-env.wrappedRuby}/bin/ruby' \
"$out/source/${bin-name}"
} > "$bin"
chmod +x "$bin"
'';
};
devShells.default = pkgs.mkShell { buildInputs = deps ++ shellDeps; };
});
}