From fdf81d0382208f2494b155bd42c021e989523868 Mon Sep 17 00:00:00 2001 From: Julien Moutinho Date: Sun, 20 Apr 2025 16:44:32 +0200 Subject: [PATCH 1/1] init --- .envrc | 1 + flake.lock | 25 +++++++++++++++++++ flake.nix | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ce2d446 --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1738843498, + "narHash": "sha256-7x+Q4xgFj9UxZZO9aUDCR8h4vyYut4zPUvfj3i+jBHE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f5a32fa27df91dfc4b762671a0e0a859a8a0058f", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..83dca41 --- /dev/null +++ b/flake.nix @@ -0,0 +1,73 @@ +{ + description = "Nix Flake to use LibreOffice Base with an SQLite database"; + inputs = { + nixpkgs.url = "flake:nixpkgs"; + }; + outputs = inputs: + let + lib = inputs.nixpkgs.lib; + forAllSystems = f: lib.genAttrs lib.systems.flakeExposed (system: f rec { + inherit system; + pkgs = inputs.nixpkgs.legacyPackages.${system}; + }); + in + { + devShells = forAllSystems ({ pkgs, system, ... }: { + default = + let driverSqlite = "${pkgs.lib.getLib pkgs.unixODBCDrivers.sqlite}/lib/libsqlite3odbc.so"; in + pkgs.mkShell { + JAVA_HOME = pkgs.libreoffice.unwrapped.jdk; + ODBCSYSINI = pkgs.writeTextDir "odbcinst.ini" '' + [ODBC Drivers] + SQLite3Driver=Installed + + [SQLite3Driver] + Description = SQLite ODBC Driver + Driver = ${driverSqlite} + Setup = ${driverSqlite} + Threading = 2 + UsageCount=1 + FileUsage= 1 + CPTimeout= + CPReuse= + FKSupport=Yes + SyncPragma= + + # Sadly does not work: https://github.com/sqitchers/docker-sqitch/pull/16/. + [Default] + Driver=SQLite3Driver + ''; + ODBCINI = pkgs.writeText "odbc.ini" '' + [testDSN] + Description=Test DB + Driver=SQLite3Driver + Database=/home/julm/work/julminfo/sibert/test.sqlite + TraceFile=/home/julm/work/julminfo/sibert/test.log + NoCreat=No + LongNames=Yes + # DescriptionNote: optional lock timeout in milliseconds; default 100000 + #Timeout=2000 + ''; + buildInputs = [ + pkgs.sqlite + pkgs.sqlitebrowser + pkgs.libreoffice + pkgs.bat + pkgs.unixODBC + ]; + shellHook = '' + bat $ODBCSYSINI/odbcinst.ini + bat $ODBCINI + export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [pkgs.unixODBC]}:$LD_LIBRARY_PATH + set -x + odbcinst -j + odbcinst -q -d -n SQLite3Driver + odbcinst -q -s -h + odbcinst -q -s -n testDSN + set +x + '' # + checks.${system}.git-hooks-check.shellHook + ; + }; + }); + }; +} -- 2.47.2