WIP Gleam bindings to ALSA
1{
2 inputs = {
3 nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
4 gleam2nix.url = "git+https://git.isincredibly.gay/srxl/gleam2nix";
5 gleam2nix.inputs.nixpkgs.follows = "nixpkgs";
6 };
7
8 outputs = {
9 nixpkgs,
10 gleam2nix,
11 ...
12 }: let
13 lib = nixpkgs.lib;
14 supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
15 forEachSupportedSystem = f:
16 lib.genAttrs supportedSystems (system:
17 f {
18 pkgs = import nixpkgs {inherit system;};
19 g2n = gleam2nix.packages.${system}.gleam2nix;
20 buildGleamApplication = gleam2nix.lib.${system}.buildGleamApplication;
21 });
22 in {
23 devShells = forEachSupportedSystem ({
24 pkgs,
25 g2n,
26 ...
27 }: {
28 default = pkgs.mkShell {
29 packages = with pkgs; [
30 gleam
31 beamMinimal28Packages.erlang
32 beamMinimal28Packages.rebar3
33 g2n
34 ];
35 buildInputs = with pkgs; [
36 alsa-lib
37 ];
38 nativeBuildInputs = with pkgs; [
39 pkg-config
40 ];
41 };
42 });
43 apps = forEachSupportedSystem ({pkgs, ...}: let
44 runtimeInputs = with pkgs; [
45 gleam
46 beamMinimal28Packages.erlang
47 beamMinimal28Packages.rebar3
48 beamMinimal28Packages.elixir
49 beamMinimal28Packages.hex
50 ];
51 in {
52 default = {
53 type = "app";
54 program = "${(pkgs.writeShellApplication {
55 inherit runtimeInputs;
56 name = "app";
57 text = ''
58 ${pkgs.gleam}/bin/gleam run
59 '';
60 })}/bin/app";
61 };
62 });
63 packages = forEachSupportedSystem ({
64 pkgs,
65 buildGleamApplication,
66 ...
67 }: let
68 buildInputs = with pkgs; [
69 alsa-lib
70 ];
71 nativeBuildInputs = with pkgs; [
72 pkg-config
73 ];
74 in {
75 default = buildGleamApplication {
76 inherit buildInputs nativeBuildInputs;
77 pname = "fern";
78 version = "1.0.0";
79 target = "erlang";
80 erlang = pkgs.beamMinimal28Packages.erlang;
81 src = ./.;
82 gleamNix = import ./gleam.nix;
83 gleamNixOverrides = final: prev: {
84 alsa =
85 prev.alsa;
86 # .override {
87 # buildInputs = with pkgs; [
88 # alsa-lib.dev
89 # ];
90 # };
91 };
92 };
93 });
94 };
95}