Skip to content

Commit

Permalink
Set up devenv to use nix
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilger committed Oct 8, 2024
1 parent c8eeec0 commit 29b1a06
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ open_ai_client-*.tar

# Temporary files, for example, from tests.
/tmp/
.nix-hex
.nix-mix
32 changes: 32 additions & 0 deletions .zellij.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
layout {
default_tab_template split_direction="horizontal" {
children
pane size=1 borderless=true {
plugin location="compact-bar"
}
}

tab name="1 code" focus=true {
pane split_direction="vertical" {
pane name="editor" size="80%" focus=true command="nvim" borderless=true
pane name="tests" size="20%" command="mix" {
args "test.interactive" "--stale"
}
}
}

// tab name="2 servers" {
// pane split_direction="vertical" {
// pane name="docker" command="docker" {
// args "compose" "up"
// }
// pane name="web" command="iex" start_suspended=true {
// args "-S" "mix" "phx.server"
// }
// }
// }

tab name="2 git" {
pane name="git" command="lazygit" borderless=true
}
}
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
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 = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
with pkgs; {
devShells.default = mkShell {
buildInputs = [
beam.interpreters.erlang_27
beam.packages.erlang_27.elixir_1_16
nodePackages.nodejs
flyctl
]
++ 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
mkdir -p .nix-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/.erlang-history\"'"
'';
};
}
);
}

0 comments on commit 29b1a06

Please sign in to comment.