9 llvm_18, # does not build with 19+ due to API changes
30 src = fetchFromGitHub {
34 hash = "sha256-C2EOd85idiSKKnWYcfoUFMuCQHB36d3CkrYVNNYmotw=";
35 fetchSubmodules = true;
39 homepage = "https://faust.grame.fr/";
40 downloadPage = "https://github.com/grame-cncm/faust/";
41 license = licenses.gpl2;
42 platforms = platforms.unix;
43 maintainers = with maintainers; [
51 ncurses_static = ncurses.override { enableStatic = true; };
80 passthru = { inherit wrap wrapWithBuildEnv faust2ApplBase; };
83 # include llvm-config in path
84 export PATH="${lib.getDev llvm_18}/bin:$PATH"
86 substituteInPlace Make.llvm.static \
87 --replace 'mkdir -p $@ && cd $@ && ar -x ../../$<' 'mkdir -p $@ && cd $@ && ar -x ../source/build/lib/libfaust.a && cd ../source/build/'
88 substituteInPlace Make.llvm.static \
89 --replace 'rm -rf $(TMP)' ' ' \
90 --replace-fail "ar" "${stdenv.cc.targetPrefix}ar"
91 sed -i 's@LIBNCURSES_PATH ?= .*@LIBNCURSES_PATH ?= ${ncurses_static}/lib/libncurses.a@' Make.llvm.static
94 for f in **/Makefile **/Makefile.library **/CMakeLists.txt build/Make.llvm.static embedded/faustjava/faust2engine architecture/autodiff/autodiff.sh source/tools/faust2appls/* **/llvm.cmake tools/benchmark/faust2object; do
95 echo $f "llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}"
96 substituteInPlace $f \
97 --replace-quiet "llvm-config" "llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}"
104 "-C../backends/all.cmake"
105 "-C../targets/all.cmake"
109 # syntax error when eval'd directly
110 pattern="faust2!(*@(atomsnippets|graph|graphviewer|md|plot|sig|sigviewer|svg))"
111 (shopt -s extglob; rm "$out"/bin/$pattern)
115 # The 'faustoptflags' is 'source'd into other faust scripts and
116 # not used as an executable, so patch 'uname' usage directly
117 # rather than use makeWrapper.
118 substituteInPlace "$out"/bin/faustoptflags \
119 --replace uname "${coreutils}/bin/uname"
121 # wrapper for scripts that don't need faust.wrap*
122 for script in "$out"/bin/faust2*; do
123 wrapProgram "$script" \
124 --prefix PATH : "$out"/bin
129 description = "A functional programming language for realtime audio signal processing";
131 FAUST (Functional Audio Stream) is a functional programming
132 language specifically designed for real-time signal processing
133 and synthesis. FAUST targets high-performance signal processing
134 applications and audio plug-ins for a variety of platforms and
136 The Faust compiler translates DSP specifications into very
137 efficient C++ code. Thanks to the notion of architecture,
138 FAUST programs can be easily deployed on a large variety of
139 audio platforms and plugin formats (jack, alsa, ladspa, maxmsp,
140 puredata, csound, supercollider, pure, vst, coreaudio) without
141 any change to the FAUST code.
143 This package has just the compiler, libraries, and headers.
144 Install faust2* for specific faust2appl scripts.
150 # Default values for faust2appl.
154 dir ? "tools/faust2appls",
155 scripts ? [ baseName ],
161 name = "${baseName}-${version}";
171 for script in ${concatStringsSep " " scripts}; do
172 cp "${dir}/$script" "$out/bin/"
179 # For the faust2appl script, change 'faustpath' and
180 # 'faustoptflags' to absolute paths.
181 for script in "$out"/bin/*; do
182 substituteInPlace "$script" \
183 --replace " error " "echo"
188 description = "The ${baseName} script, part of faust functional programming language for realtime audio signal processing";
192 # Some 'faust2appl' scripts, such as faust2alsa, run faust to
193 # generate cpp code, then invoke the c++ compiler to build the code.
194 # This builder wraps these scripts in parts of the stdenv such that
195 # when the scripts are called outside any nix build, they behave as
196 # if they were running inside a nix build in terms of compilers and
197 # paths being configured (e.g. rpath is set so that compiled
198 # binaries link to the libs inside the nix store)
200 # The function takes two main args: the appl name (e.g.
201 # 'faust2alsa') and an optional list of propagatedBuildInputs. It
202 # returns a derivation that contains only the bin/${appl} script,
203 # wrapped up so that it will run as if it was inside a nix build
204 # with those build inputs.
206 # The build input 'faust' is automatically added to the
207 # propagatedBuildInputs.
211 propagatedBuildInputs ? [ ],
215 stdenv.mkDerivation (
216 (faust2ApplBase args)
219 nativeBuildInputs = [
224 propagatedBuildInputs = [ faust ] ++ propagatedBuildInputs;
226 libPath = lib.makeLibraryPath propagatedBuildInputs;
230 # export parts of the build environment
231 for script in "$out"/bin/*; do
232 # e.g. NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu
233 nix_cc_wrapper_target_host="$(printenv | grep ^NIX_CC_WRAPPER_TARGET_HOST | sed 's/=.*//')"
235 # e.g. NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu
236 nix_bintools_wrapper_target_host="$(printenv | grep ^NIX_BINTOOLS_WRAPPER_TARGET_HOST | sed 's/=.*//')"
238 wrapProgram "$script" \
239 --set FAUSTLDDIR "${faust}/lib" \
240 --set FAUSTLIB "${faust}/share/faust" \
241 --set FAUSTINC "${faust}/include/faust" \
242 --set FAUSTARCH "${faust}/share/faust" \
243 --prefix PATH : "$PATH" \
244 --prefix PKG_CONFIG_PATH : "$PKG_CONFIG_PATH" \
245 --set NIX_CFLAGS_COMPILE "$NIX_CFLAGS_COMPILE" \
246 --set NIX_LDFLAGS "$NIX_LDFLAGS -lpthread" \
247 --set "$nix_cc_wrapper_target_host" "''${!nix_cc_wrapper_target_host}" \
248 --set "$nix_bintools_wrapper_target_host" "''${!nix_bintools_wrapper_target_host}" \
249 --prefix LIBRARY_PATH "$libPath"
255 # Builder for 'faust2appl' scripts, such as faust2firefox that
256 # simply need to be wrapped with some dependencies on PATH.
258 # The build input 'faust' is automatically added to the PATH.
268 runtimePath = concatStringsSep ":" (map (p: "${p}/bin") ([ faust ] ++ runtimeInputs));
271 stdenv.mkDerivation (
272 (faust2ApplBase args)
275 nativeBuildInputs = [ makeWrapper ];
278 for script in "$out"/bin/*; do
279 wrapProgram "$script" --prefix PATH : "${runtimePath}"