Files
spotifast/flake.nix
T
millia ampora 37d62e7977 Offer a Nix development shell
nix develop brings up the toolchain and the Linux GUI and audio libraries in
one step, so a contributor on NixOS or with Nix on macOS does not hand-install
the list in the README, and .envrc enters it on cd for direnv users.

The compiler comes from rust-toolchain.toml through rust-overlay rather than
from whatever nixpkgs currently ships, so the shell agrees with CI on the
compiler, clippy and rustfmt. nixpkgs is at 1.97.1 today, which would quietly
disagree with the 1.98.0 pin.

On Linux the shell also exports LD_LIBRARY_PATH for the Wayland, X11 and GL
libraries the GUI dlopens at run time, which are not found from a Nix shell
otherwise.
2026-08-28 13:13:55 +02:00

84 lines
2.0 KiB
Nix

{
description = "Spotify, native and fast";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# rust-toolchain.toml pins the compiler so local builds and CI agree.
# This reads that file rather than restating the version here.
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
nixpkgs,
rust-overlay,
...
}:
let
systems = [
"aarch64-darwin"
"x86_64-darwin"
"aarch64-linux"
"x86_64-linux"
];
forAllSystems =
f:
nixpkgs.lib.genAttrs systems (
system:
f (
import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
}
)
);
in
{
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages =
with pkgs;
[
(rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
rust-analyzer
pkg-config
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
apple-sdk
]
++ lib.optionals stdenv.hostPlatform.isLinux [
alsa-lib
libpulseaudio
libxkbcommon
wayland
libGL
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
];
# The GUI dlopens its Wayland, X11 and GL libraries at run time.
LD_LIBRARY_PATH = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux (
pkgs.lib.makeLibraryPath (
with pkgs;
[
libxkbcommon
wayland
libGL
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
]
)
);
};
});
formatter = forAllSystems (pkgs: pkgs.nixfmt-tree);
};
}