server/flake.nix

87 lines
2.6 KiB
Nix
Raw Normal View History

2023-11-28 17:50:13 +00:00
{
2023-12-01 18:00:43 +00:00
description = "The BoardWise backend/frontend.";
2023-11-28 17:50:13 +00:00
inputs = {
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs.beam.packages.erlang_25)
beamPackages
elixir
elixir-ls
hex
mixRelease;
nodeDependencies = (
pkgs.callPackage ./assets/default.nix {}
).nodeDependencies;
tailwindcss = pkgs.nodePackages.tailwindcss.overrideAttrs (oa: {
plugins = [
pkgs.nodePackages."@tailwindcss/forms"
2023-12-04 13:06:54 +00:00
pkgs.nodePackages.autoprefixer
];
});
2023-11-28 17:50:13 +00:00
in
{
packages = {
app = mixRelease {
2023-11-30 17:25:00 +00:00
pname = "boardwise";
2023-11-28 17:50:13 +00:00
src = ./.;
version = "0.1.0";
mixNixDeps = import ./deps.nix {
lib = pkgs.lib;
inherit beamPackages;
};
# Enable if using distributed Erlang.
# https://github.com/NixOS/nixpkgs/issues/166229
removeCookie = false;
# https://hexdocs.pm/esbuild/Esbuild.html
# https://hexdocs.pm/tailwind/Tailwind.html
postBuild = ''
ln -s ${nodeDependencies}/lib/node_modules assets/node_modules
export MIX_ESBUILD_PATH=${pkgs.esbuild}/bin/esbuild
export MIX_TAILWIND_PATH=${tailwindcss}/bin/tailwind
mix do deps.loadpaths --no-deps-check, assets.deploy
mix phx.gen.release
'';
2023-11-28 17:50:13 +00:00
};
default = self.packages.${system}.app;
};
devShells.default = pkgs.mkShell {
packages = [
elixir
elixir-ls
hex
] ++ (with pkgs; [
inotify-tools # For file watching in development.
mix2nix
node2nix
2023-12-02 01:48:47 +00:00
nodePackages.prettier
nodePackages.typescript-language-server
nodejs
2023-11-28 17:50:13 +00:00
postgresql_15
2023-12-02 01:48:47 +00:00
typescript
2023-11-28 17:50:13 +00:00
]);
shellHook = ''
# The server will try to use the data directory named by this
# environment variable whenever `-D` is not specified (for e.g.
# `postgres` and `pg_ctl`).
# https://www.postgresql.org/docs/15/server-start.html
2023-12-01 18:00:43 +00:00
export PGDATA="$PWD/db"
2023-11-28 17:50:13 +00:00
'';
};
});
}