feat: add elixir phoenix template
This commit is contained in:
parent
08060f117f
commit
0752d7175e
2 changed files with 107 additions and 0 deletions
|
|
@ -68,6 +68,10 @@
|
|||
description = "Crane + Fenix flake with mold for faster local builds.";
|
||||
path = ./templates/rust;
|
||||
};
|
||||
templates.elixir-phoenix = {
|
||||
description = "A flake for building development environment of Phoenix project.";
|
||||
path = ./templates/elixir-phoenix;
|
||||
};
|
||||
};
|
||||
|
||||
# Define your clan
|
||||
|
|
|
|||
103
templates/elixir-phoenix/flake.nix
Normal file
103
templates/elixir-phoenix/flake.nix
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
{
|
||||
description = "A flake for building development environment of Phoenix project.";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/master";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
erl = pkgs.beam.interpreters.erlang_27;
|
||||
erlangPackages = pkgs.beam.packagesWith erl;
|
||||
elixir = erlangPackages.elixir;
|
||||
in {
|
||||
packages = let
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
mixFodDeps = erlangPackages.fetchMixDeps {
|
||||
inherit version src;
|
||||
pname = "example";
|
||||
sha256 = "";
|
||||
};
|
||||
translatedPlatform =
|
||||
pkgs.lib.getAttr
|
||||
system
|
||||
{
|
||||
aarch64-darwin = "macos-arm64";
|
||||
aarch64-linux = "linux-arm64";
|
||||
armv7l-linux = "linux-armv7";
|
||||
x86_64-darwin = "macos-x64";
|
||||
x86_64-linux = "linux-x64";
|
||||
};
|
||||
in rec {
|
||||
default = erlangPackages.mixRelease {
|
||||
inherit version src mixFodDeps;
|
||||
pname = "example";
|
||||
|
||||
preInstall = ''
|
||||
ln -s ${pkgs.tailwindcss}/bin/tailwindcss _build/tailwind-${translatedPlatform}
|
||||
ln -s ${pkgs.esbuild}/bin/esbuild _build/esbuild-${translatedPlatform}
|
||||
|
||||
${elixir}/bin/mix assets.deploy
|
||||
${elixir}/bin/mix phx.gen.release
|
||||
'';
|
||||
};
|
||||
dockerImage = pkgs.dockerTools.buildImage {
|
||||
name = "example";
|
||||
config = {
|
||||
Entrypoint = "${default}/bin/example";
|
||||
Cmd = "start";
|
||||
};
|
||||
};
|
||||
};
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs;
|
||||
[
|
||||
erl
|
||||
elixir
|
||||
lexical
|
||||
erlangPackages.elixir-ls
|
||||
next-ls
|
||||
]
|
||||
++ lib.optionals stdenv.isLinux [
|
||||
# For ExUnit Notifier on Linux.
|
||||
libnotify
|
||||
|
||||
# For file_system on Linux.
|
||||
inotify-tools
|
||||
]
|
||||
++ lib.optionals stdenv.isDarwin [
|
||||
# For ExUnit Notifier on macOS.
|
||||
terminal-notifier
|
||||
|
||||
# For file_system on macOS.
|
||||
darwin.apple_sdk.frameworks.CoreFoundation
|
||||
darwin.apple_sdk.frameworks.CoreServices
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
# allows mix to work on the local directory
|
||||
mkdir -p .nix/{mix,hex}
|
||||
export MIX_HOME=$PWD/.nix/mix
|
||||
export HEX_HOME=$PWD/.nix/hex
|
||||
export ERL_LIBS=$HEX_HOME/lib/erlang/lib
|
||||
|
||||
# concats PATH
|
||||
export PATH=$MIX_HOME/bin:$PATH
|
||||
export PATH=$MIX_HOME/escripts:$PATH
|
||||
export PATH=$HEX_HOME/bin:$PATH
|
||||
|
||||
# enables history for IEx
|
||||
export ERL_AFLAGS="-kernel shell_history enabled -kernel shell_history_path '\"$PWD/.nix/erlang-history\"'"
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue