Add Nix Shell Env
This commit is contained in:
parent
e24049b1fb
commit
36439c0837
4 changed files with 75 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -24,3 +24,4 @@ app/data/misc/*
|
|||
app/data/commander/*
|
||||
app/data/bset/*
|
||||
app/tools/json/*
|
||||
app/.pg
|
||||
|
|
70
app/shell.nix
Normal file
70
app/shell.nix
Normal file
|
@ -0,0 +1,70 @@
|
|||
let
|
||||
nixpkgs = import (builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/24.11-beta.tar.gz") {
|
||||
overlays = [];
|
||||
config = {};
|
||||
};
|
||||
|
||||
in
|
||||
with nixpkgs;
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "postgres-env";
|
||||
buildInputs = [];
|
||||
|
||||
nativeBuildInputs = [
|
||||
zsh
|
||||
vim
|
||||
geos
|
||||
gdal
|
||||
nixpkgs-fmt
|
||||
nodejs_22
|
||||
openssl
|
||||
prisma
|
||||
|
||||
# postgres-12 with postgis support
|
||||
(postgresql_12.withPackages (p: [ p.postgis ]))
|
||||
];
|
||||
|
||||
postgresConf =
|
||||
writeText "postgresql.conf"
|
||||
''
|
||||
# Add Custom Settings
|
||||
log_min_messages = warning
|
||||
log_min_error_statement = error
|
||||
log_min_duration_statement = 100 # ms
|
||||
log_connections = on
|
||||
log_disconnections = on
|
||||
log_duration = on
|
||||
#log_line_prefix = '[] '
|
||||
log_timezone = 'UTC'
|
||||
log_statement = 'all'
|
||||
log_directory = 'pg_log'
|
||||
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
|
||||
logging_collector = on
|
||||
log_min_error_statement = error
|
||||
'';
|
||||
|
||||
|
||||
# ENV Variables
|
||||
LD_LIBRARY_PATH = "${geos}/lib:${gdal}/lib";
|
||||
PGDATA = "${toString ./.}/.pg";
|
||||
|
||||
# Post Shell Hook
|
||||
shellHook = ''
|
||||
echo "Using ${postgresql_12.name}."
|
||||
|
||||
# Setup: other env variables
|
||||
export PGHOST="$PGDATA"
|
||||
export PRISMA_SCHEMA_ENGINE_BINARY="${pkgs.prisma-engines}/bin/schema-engine"
|
||||
export PRISMA_QUERY_ENGINE_BINARY="${pkgs.prisma-engines}/bin/query-engine"
|
||||
export PRISMA_QUERY_ENGINE_LIBRARY="${pkgs.prisma-engines}/lib/libquery_engine.node"
|
||||
export PRISMA_FMT_BINARY="${pkgs.prisma-engines}/bin/prisma-fmt"
|
||||
export PATH="$PWD/node_modules/.bin/:$PATH"
|
||||
|
||||
# Setup: DB
|
||||
[ ! -d $PGDATA ] && pg_ctl initdb -o "-U postgres" && cat "$postgresConf" >> $PGDATA/postgresql.conf
|
||||
pg_ctl -o "-p 5555 -k $PGDATA" start
|
||||
alias fin="pg_ctl stop && exit"
|
||||
alias pg="psql -p 5555 -U postgres"
|
||||
'';
|
||||
}
|
|
@ -2,9 +2,9 @@ import { readFileSync, readdirSync } from "fs"
|
|||
|
||||
const base_api_url = "http://localhost:3000"
|
||||
|
||||
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6Imp3dCJ9.eyJ1c2VybmFtZSI6Imdsb2J1em1hIiwiYWRtaW4iOnRydWUsImlkIjoiMDc4YWViYTYtNzZlNC00YzRkLTg3NjYtNjA0N2JhNjkxM2Y5IiwibWF4QWdlIjo2MDQ4MDB9.acd6b0fab88719f708fa0553f18a6b034b2c3a84659e3a63b32e87f22c611d3e"
|
||||
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6Imp3dCJ9.eyJ1c2VybmFtZSI6Inp1bWEiLCJhZG1pbiI6dHJ1ZSwiaWQiOiJjMmZlNDhhNi1iNmVmLTRhMDktOTZmNi0wM2YyNTNkZjExZGQiLCJtYXhBZ2UiOjYwNDgwMH0=.0eee4c6c4c2a13b4add8ca7b34e1f1cdec5e16b56d6cae77ede9974fccd8f2d6"
|
||||
|
||||
let bsets_sanitized_names = readdirSync(import.meta.dirname + "/data/bsets/")
|
||||
let bsets_sanitized_names = readdirSync(import.meta.dirname + "/data/decks_bsets/")
|
||||
|
||||
function get_line_data(line) {
|
||||
let data = line.split(" ")
|
||||
|
@ -14,7 +14,7 @@ function get_line_data(line) {
|
|||
}
|
||||
|
||||
for(const sanitized_name of bsets_sanitized_names) {
|
||||
let path = import.meta.dirname + "/data/bsets/" + sanitized_name + "/"
|
||||
let path = import.meta.dirname + "/data/decks_bsets/" + sanitized_name + "/"
|
||||
let deck_files = readdirSync(path)
|
||||
for( const deck_file of deck_files) {
|
||||
let api_object = {
|
||||
|
|
|
@ -10,7 +10,7 @@ console.log('Status Code:', scryfallSets.status);
|
|||
const sets = await scryfallSets.json();
|
||||
|
||||
// Read the data from the exported fr_cards.json extracted from Scryfall Bulk Data
|
||||
const fileBytes = fs.readFileSync(import.meta.dirname + '/data/default-cards-20241210100712.json')
|
||||
const fileBytes = fs.readFileSync(import.meta.dirname + '/data/scryfall_data.json')
|
||||
let scryfallData = JSON.parse(fileBytes)
|
||||
|
||||
// Connect to postgres database
|
||||
|
|
Loading…
Reference in a new issue