diff --git a/.gitignore b/.gitignore index 599be4e..7ef61a4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.ez /build erl_crash.dump +.envrc diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..42b5046 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1783279667, + "narHash": "sha256-/NAkDSsve+GNM0Bt6tleJdCGfsTlK89nPjkVOzZMo0s=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f205b5574fd0cb7da5b702a2da51507b7f4fdd1b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1780220602, + "narHash": "sha256-eynAfOmbmxJnkp7YewvCEbShNnnYJ9gLLqkzsYtBPeM=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "db947814a175b7ca6ded66e21383d938df01c227", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b91698d --- /dev/null +++ b/flake.nix @@ -0,0 +1,41 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { + self, + nixpkgs, + treefmt-nix, + ... + }: let + lib = nixpkgs.lib; + supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; + forEachSupportedSystem = f: + lib.genAttrs supportedSystems (system: + f { + pkgs = import nixpkgs {inherit system;}; + }); + treefmtEval = forEachSupportedSystem ({pkgs}: treefmt-nix.lib.evalModule pkgs ./treefmt.nix); + in { + devShells = forEachSupportedSystem ({pkgs}: { + default = pkgs.mkShell { + packages = with pkgs; [ + gleam + beamMinimal29Packages.erlang + beamMinimal29Packages.rebar3 + ]; + }; + }); + + formatter = forEachSupportedSystem ({pkgs}: treefmtEval.${pkgs.stdenv.hostPlatform.system}.config.build.wrapper); + checks = forEachSupportedSystem ({pkgs}: { + formatting = + treefmtEval.${pkgs.stdenv.hostPlatform.system}.config.build.check self; + }); + }; +} diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..15a8d59 --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,5 @@ +{pkgs, ...}: { + projectRootFile = "flake.nix"; + programs.gleam.enable = true; + programs.alejandra.enable = true; +}