Exploring Scala Native + Nix Flakes + Nix Devshell + Direnv.
- https://scala-native.org/en/latest
- https://github.com/numtide/devshell
- https://nixos-and-flakes.thiscute.world/nixos-with-flakes/introduction-to-flakes
- https://direnv.net
- https://github.com/typelevel/typelevel-nix
The Nix sets up the development environment with:
clang: C/C++ LLVM compiler https://clang.llvm.orgsn-bindgen: Scala Native bindings generator https://sn-bindgen.indoorvivants.comimagemagick:magickwandAPICfor processing images https://imagemagick.orgsndfile:Clibrary for working with WAV audio files https://libsndfile.github.io/libsndfilejdk: GraalVM Community Edition: https://www.graalvm.orgmetals: Scala Metals LSP server: https://scalameta.org/metalssbt: Scala Built Tool: https://www.scala-sbt.org/index.htmlscala-cli: Scala command-line tool: https://scala-cli.virtuslab.orgscala-fix: Scala refactoring and linting tool for Scala: https://scalacenter.github.io/scalafix
The build.sbt points to clang and sn-bindgen binaries provided by the devshell,
and defines sn-bindgen bindings.
You can use this repo without nix if all of the above provided by your own environment.
As for nix users, cd into the repository directory and run nix develop to drop into the development environment.
Or, if you have direnv installed, simply cd into the repository directory and do direnv allow.
Now, whenever you cd into the repository directory the development environment will be activated automatically,
and erased when you cd out of the repository directory.
$ sbt sndfile/nativeLink
$ ./modules/sndfile/target/scala-3.5.0-RC2/sndfile ./file.wav
Channels: 2
Format: 65538
Frames: 7623627
Sample rate: 48000
Sections: 1
Seekable: 1
Album: null
Artist: RavioliCode
Comment: https://soundcloud.com/raviolicode/babangida
Copyright: null
Date: 20170223
Genre: Hip-hop & Rap
License: null
Software: Lavf58.76.100
Title: babangida - купол
Tracknumber: null
$ sbt magickwand/nativeLink
$ ./modules/magickwand/target/scala-3.5.0-RC2/magickwand
# will produce the `./logo-extend.png` image
This repo uses nix based GitHub actions for caching the development environment dependencies,
instead of the traditional approach with coursier/setup-action and coursier/cache-action: