-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
119 lines (88 loc) · 2.84 KB
/
flake.nix
File metadata and controls
119 lines (88 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
{
description = "Ordis discord bot";
inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
new-migration = pkgs.writeShellScriptBin "new-migration" (''diesel migration generate $1 '');
redo-migration = pkgs.writeShellScriptBin "redo-migration" (''diesel migration redo'');
run-migration = pkgs.writeShellScriptBin "run-migration" (''diesel migration run'');
build-and-debug = pkgs.writeShellScriptBin "build-and-debug" (''cargo run'');
gen-up = pkgs.writeShellApplication {
name = "gen-up";
text = ''
chatgpt "
Please write an up.sql for SQLite based on the following schema.rs: $(cat src/db/schema.rs)
Assume it is already being run in a transaction (don't add begin and end transaction statements)
The up.sql should make the following changes:
$1
"
'';
};
gen-down = pkgs.writeShellApplication {
name = "gen-down";
text = ''
latest=$(find migrations -type d | sort -r | head -n 1)
up=$(cat "$latest"/up.sql)
chatgpt "
With the context of the current schema ($(cat src/db/schema.rs))
Please generate a sqlite down.sql for the following up.sql: $up"
'';
};
rustPkgs = import ./Cargo.nix { inherit pkgs; };
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
rustc
cargo
rustfmt
rust-analyzer
clippy
sqlite
sqlite-web
cachix
crate2nix
diesel-cli
pkg-config
openssl.dev
lldb
new-migration
redo-migration
run-migration
gen-up
gen-down
build-and-debug
cmake # For songbird build
libopus # For songbird runtime
yt-dlp # For songbird youtube interface
];
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
OUT_DIR = "./src/db";
RUST_BACKTRACE = "full";
};
packages.default = rustPkgs.workspaceMembers."ordis".build.overrideAttrs (old: rec {
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
OUT_DIR = "./src/db";
RUST_BACKTRACE = "full";
# preBuild = ''
# pkgs.crate2nix generate
# '';
buildInputs = old.buildInputs or [ ] ++ [
pkgs.sqlite
pkgs.openssl.dev
];
});
}
);
}