]> Git — Sourcephile - tmp/julm/LesQuatreRoux.git/blob - flake.nix
add sql
[tmp/julm/LesQuatreRoux.git] / flake.nix
1 {
2 description = "Nix Flake to use LibreOffice Base with an SQLite database";
3 inputs = {
4 nixpkgs.url = "flake:nixpkgs";
5 git-hooks.url = "github:cachix/git-hooks.nix";
6 git-hooks.inputs.nixpkgs.follows = "nixpkgs";
7 };
8 outputs = inputs:
9 let
10 lib = inputs.nixpkgs.lib;
11 forAllSystems = f: lib.genAttrs lib.systems.flakeExposed (system: f rec {
12 inherit system;
13 pkgs = inputs.nixpkgs.legacyPackages.${system};
14 });
15 in
16 {
17 devShells = forAllSystems ({ pkgs, system, ... }: {
18 default =
19 let database = "LesQuatreRoux"; in
20 pkgs.mkShell {
21 JAVA_HOME = pkgs.libreoffice.unwrapped.jdk;
22 ODBCSYSINI =
23 let
24 odbcsysini = pkgs.writeTextDir "odbcinst.ini" ''
25 [ODBC Drivers]
26 SQLite3=Installed
27
28 [SQLite3]
29 Description = SQLite ODBC Driver
30 Driver = ${pkgs.lib.getLib pkgs.unixODBCDrivers.sqlite}/lib/libsqlite3odbc.so
31 Setup = ${pkgs.lib.getLib pkgs.unixODBCDrivers.sqlite}/lib/libsqlite3odbc.so
32 Threading = 2
33 UsageCount=1
34 FileUsage= 1
35 CPTimeout=
36 CPReuse=
37 FKSupport=Yes
38 SyncPragma=
39
40 # Sadly does not work: https://github.com/sqitchers/docker-sqitch/pull/16/.
41 [Default]
42 Driver=SQLite3
43 '';
44 odbcini = pkgs.writeTextDir "odbc.ini" ''
45 [${database}]
46 Description=${database} database
47 Driver=SQLite
48 NoCreat=No
49 LongNames=Yes
50 Database=${database}
51 TraceFile=/tmp/${database}.log
52 # DescriptionNote: optional lock timeout in milliseconds; default 100000
53 #Timeout=2000
54 '';
55 in
56 # ExplanationNote: somehow using ODBCINI= does not work, so keep everything in ODBCSYSINI=
57 pkgs.symlinkJoin {
58 name = "ODBCSYSINI";
59 paths = [
60 odbcsysini
61 odbcini
62 ];
63 };
64 buildInputs = [
65 #pkgs.bat
66 pkgs.dbeaver-bin
67 pkgs.hsqldb
68 pkgs.libreoffice
69 pkgs.sqlfluff
70 #pkgs.sqlite
71 #pkgs.sqlitebrowser
72 #pkgs.unixODBC
73 (pkgs.writeShellScriptBin "sql" ''
74 exec ${pkgs.hsqldb}/bin/sqltool --inlineRc='url=jdbc:hsqldb:hsql://localhost:9001/LesQuatreRoux' --autoCommit "$@"
75 '')
76 ];
77 shellHook = ''
78 #bat $ODBCSYSINI/odbcinst.ini
79 #bat $ODBCSYSINI/odbc.ini
80 export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [pkgs.unixODBC]}:$LD_LIBRARY_PATH
81 set -x
82 #odbcinst -j
83 #odbcinst -q -d -n SQLite3
84 #odbcinst -q -s -h
85 #odbcinst -q -s -n ${database}
86 set +x
87 echo "You may now launch runServer"
88 '' # + checks.${system}.git-hooks-check.shellHook
89 ;
90 };
91 });
92 # nix flake check
93 checks = forAllSystems (args: with args; {
94 git-hooks-check = inputs.git-hooks.lib.${system}.run {
95 src = ./.;
96 hooks = {
97 nixpkgs-fmt.enable = true;
98 sqlfluff.enable = true;
99 reuse = {
100 enable = true;
101 entry = "${pkgs.reuse}/bin/reuse lint";
102 pass_filenames = false;
103 };
104 };
105 };
106 });
107 };
108 }