67 lines
1.9 KiB
Nix
67 lines
1.9 KiB
Nix
{
|
|
description = "Prymn";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
inputs.flake-utils.follows = "flake-utils";
|
|
};
|
|
};
|
|
|
|
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
|
|
let
|
|
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
|
|
|
overlays = [
|
|
(final: prev: {
|
|
elixir = prev.beam.packages.erlang_26.elixir_1_15;
|
|
elixir-ls = prev.beam.packages.erlang_26.elixir-ls.override { elixir = final.elixir; };
|
|
protoc-gen-elixir = prev.callPackage ./protoc-gen-elixir.nix { elixir = final.elixir; };
|
|
})
|
|
|
|
(import rust-overlay)
|
|
];
|
|
in
|
|
flake-utils.lib.eachSystem supportedSystems (system:
|
|
let
|
|
pkgs = import nixpkgs { inherit system overlays; };
|
|
in
|
|
{
|
|
devShells.default = with pkgs; mkShell {
|
|
packages = [
|
|
elixir
|
|
elixir-ls
|
|
protobuf
|
|
protoc-gen-elixir
|
|
rust-bin.stable.latest.default
|
|
postgresql
|
|
] ++ lib.optionals stdenv.isLinux [ inotify-tools ];
|
|
|
|
inputsFrom = [
|
|
protoc-gen-elixir
|
|
];
|
|
|
|
shellHook = ''
|
|
export PGDATA=$PWD/.db
|
|
export PGHOST=/tmp
|
|
export DB_LOG=$PWD/.db/log
|
|
|
|
if [ ! -d $PGDATA ]; then
|
|
initdb $PGDATA --auth=trust
|
|
fi
|
|
|
|
if ! pg_ctl status >/dev/null; then
|
|
pg_ctl start -l $DB_LOG -o "-c unix_socket_directories=$PGHOST"
|
|
fi
|
|
|
|
user_exists=$(psql --csv -t -d postgres -c "SELECT count(*) FROM pg_user WHERE usename='postgres'")
|
|
if [ $user_exists != "1" ]; then
|
|
createuser -s -h $PGHOST postgres
|
|
fi
|
|
'';
|
|
};
|
|
});
|
|
}
|