diff --git a/elixir/flake.nix b/elixir/flake.nix new file mode 100644 index 0000000..373c2b9 --- /dev/null +++ b/elixir/flake.nix @@ -0,0 +1,56 @@ +{ + description = "minimal flake for elixir dev"; + + inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1"; + + outputs = {self, ...} @ inputs: let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + ]; + forEachSupportedSystem = f: + inputs.nixpkgs.lib.genAttrs supportedSystems ( + system: + f { + inherit system; + pkgs = import inputs.nixpkgs { + inherit system; + overlays = [inputs.self.overlays.default]; + }; + } + ); + in { + overlays.default = final: prev: rec { + erlang = final.beam.interpreters.erlang_27; + pkgs-beam = final.beam.packagesWith erlang; + elixir = pkgs-beam.elixir_1_17; + }; + + devShells = forEachSupportedSystem ( + { + pkgs, + system, + }: { + default = pkgs.mkShellNoCC { + packages = with pkgs; + [ + elixir + self.formatter.${system} + ] + ++ + # Linux only + pkgs.lib.optionals pkgs.stdenv.isLinux ( + with pkgs; [ + gigalixir + inotify-tools + libnotify + ] + ); + }; + } + ); + + formatter = forEachSupportedSystem ({pkgs, ...}: pkgs.nixfmt); + }; +} diff --git a/flake.nix b/flake.nix index 1464424..76b000c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,32 +1,34 @@ { description = "nix flakes"; - outputs = - { self }: - { - templates = { - c = { - path = ./c; - description = "c template"; - }; - go = { - path = ./go; - description = "go template"; - }; - zig = { - path = ./zig; - description = "zig template"; - }; - odin = { - path = ./odin; - description = "odin template"; - }; - crystal = { - path = ./crystal; - description = "crystal template"; - }; + outputs = {self}: { + templates = { + c = { + path = ./c; + description = "c template"; + }; + go = { + path = ./go; + description = "go template"; + }; + elixir = { + path = ./elixir; + description = "elixir template"; + }; + zig = { + path = ./zig; + description = "zig template"; + }; + odin = { + path = ./odin; + description = "odin template"; + }; + crystal = { + path = ./crystal; + description = "crystal template"; }; - - defaultTemplate = self.templates.go; }; + + defaultTemplate = self.templates.go; + }; }