2024-05-07 16:49:30 +05:00
|
|
|
{
|
|
|
|
description = "Materia is a file server";
|
|
|
|
|
|
|
|
nixConfig = {
|
|
|
|
extra-substituters = [ "https://bonfire.cachix.org" ];
|
|
|
|
extra-trusted-public-keys = [ "bonfire.cachix.org-1:mzAGBy/Crdf8NhKail5ciK7ZrGRbPJJobW6TwFb7WYM=" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
|
|
poetry2nix = {
|
|
|
|
url = "github:nix-community/poetry2nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, poetry2nix, ... }:
|
|
|
|
let
|
|
|
|
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" ];
|
|
|
|
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
|
|
|
in
|
|
|
|
{
|
2024-05-08 23:13:23 +05:00
|
|
|
packages = forAllSystems (system: let
|
2024-05-07 16:49:30 +05:00
|
|
|
pkgs = nixpkgsFor.${system};
|
2024-05-16 11:05:11 +05:00
|
|
|
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
|
2024-05-08 23:13:23 +05:00
|
|
|
in {
|
2024-05-16 11:05:11 +05:00
|
|
|
materia = mkPoetryApplication {
|
|
|
|
projectDir = ./.;
|
|
|
|
};
|
2024-05-08 23:13:23 +05:00
|
|
|
|
2024-05-16 11:05:11 +05:00
|
|
|
default = self.packages.${system}.materia;
|
2024-05-08 23:13:23 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
apps = forAllSystems (system: {
|
2024-05-16 11:05:11 +05:00
|
|
|
materia = {
|
2024-05-07 16:49:30 +05:00
|
|
|
type = "app";
|
2024-05-16 11:05:11 +05:00
|
|
|
program = "${self.packages.${system}.materia}/bin/materia";
|
2024-05-07 16:49:30 +05:00
|
|
|
};
|
|
|
|
|
2024-05-16 11:05:11 +05:00
|
|
|
default = self.apps.${system}.materia;
|
2024-05-07 16:49:30 +05:00
|
|
|
});
|
|
|
|
|
2024-05-16 11:05:11 +05:00
|
|
|
devShells = forAllSystems (system: let
|
2024-05-08 23:13:23 +05:00
|
|
|
pkgs = nixpkgsFor.${system};
|
|
|
|
db_name = "materia";
|
|
|
|
db_user = "materia";
|
2024-05-16 11:05:11 +05:00
|
|
|
db_path = "temp/materia-db";
|
2024-05-07 16:49:30 +05:00
|
|
|
in {
|
|
|
|
default = pkgs.mkShell {
|
2024-05-08 23:13:23 +05:00
|
|
|
buildInputs = with pkgs; [
|
|
|
|
nil
|
|
|
|
nodejs
|
|
|
|
ripgrep
|
|
|
|
|
|
|
|
postgresql
|
|
|
|
|
|
|
|
poetry
|
2024-05-07 16:49:30 +05:00
|
|
|
];
|
2024-05-08 23:13:23 +05:00
|
|
|
|
|
|
|
LD_LIBRARY_PATH = nixpkgs.lib.makeLibraryPath [ pkgs.stdenv.cc.cc ];
|
|
|
|
|
|
|
|
shellHook = ''
|
|
|
|
trap "pg_ctl -D ${db_path} stop" EXIT
|
|
|
|
|
|
|
|
[ ! -d $(pwd)/${db_path} ] && initdb -D $(pwd)/${db_path} -U ${db_user}
|
|
|
|
pg_ctl -D $(pwd)/${db_path} -l $(pwd)/${db_path}/db.log -o "--unix_socket_directories=$(pwd)/${db_path}" start
|
|
|
|
[ ! "$(psql -h $(pwd)/${db_path} -U ${db_user} -l | rg '^ ${db_name}')" ] && createdb -h $(pwd)/${db_path} -U ${db_user} ${db_name}
|
|
|
|
'';
|
2024-05-07 16:49:30 +05:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|