Skip to content

Commit fddf898

Browse files
committed
Add Nix flake support
1 parent eccdb30 commit fddf898

File tree

4 files changed

+181
-0
lines changed

4 files changed

+181
-0
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ jobs:
3434
run: |
3535
python -c "from sqlit.cli import main; print('CLI import OK')"
3636
37+
nix-flake:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Install Nix
43+
uses: cachix/install-nix-action@v26
44+
45+
- name: Build flake package
46+
run: nix build .#sqlit
47+
3748
test-unit:
3849
runs-on: ubuntu-latest
3950
strategy:

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ pip install sqlit-tui
112112

113113
# Arch Linux (AUR)
114114
yay -S sqlit
115+
116+
# Nix (flake)
117+
nix run github:Maxteabag/sqlit
115118
```
116119

117120
## Usage

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
description = "A terminal UI for SQL databases";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = nixpkgs.legacyPackages.${system};
13+
lib = pkgs.lib;
14+
pyPkgs = pkgs.python3.pkgs;
15+
16+
ref =
17+
if self ? sourceInfo && self.sourceInfo ? ref
18+
then self.sourceInfo.ref
19+
else "";
20+
tag =
21+
if lib.hasPrefix "refs/tags/v" ref
22+
then lib.removePrefix "refs/tags/v" ref
23+
else if lib.hasPrefix "refs/tags/" ref
24+
then lib.removePrefix "refs/tags/" ref
25+
else if lib.hasPrefix "v" ref
26+
then lib.removePrefix "v" ref
27+
else "";
28+
shortRev = if self ? shortRev then self.shortRev else "dirty";
29+
version = if tag != "" then tag else "0.0.0+${shortRev}";
30+
31+
sqlit = pyPkgs.buildPythonApplication {
32+
pname = "sqlit";
33+
inherit version;
34+
pyproject = true;
35+
36+
src = self;
37+
38+
build-system = [
39+
pyPkgs.hatchling
40+
pyPkgs."hatch-vcs"
41+
pyPkgs."setuptools-scm"
42+
];
43+
44+
nativeBuildInputs = [
45+
pyPkgs.pythonRelaxDepsHook
46+
];
47+
48+
pythonRelaxDeps = [
49+
"textual-fastdatatable"
50+
];
51+
52+
SETUPTOOLS_SCM_PRETEND_VERSION = version;
53+
54+
dependencies = [
55+
pyPkgs.docker
56+
pyPkgs.keyring
57+
pyPkgs.pyperclip
58+
pyPkgs.sqlparse
59+
pyPkgs.textual
60+
pyPkgs."textual-fastdatatable"
61+
];
62+
63+
pythonImportsCheck = [ "sqlit" ];
64+
65+
meta = with lib; {
66+
description = "A terminal UI for SQL databases";
67+
homepage = "https://github.com/Maxteabag/sqlit";
68+
license = licenses.mit;
69+
mainProgram = "sqlit";
70+
};
71+
};
72+
in {
73+
packages = {
74+
inherit sqlit;
75+
default = sqlit;
76+
};
77+
78+
apps.default = {
79+
type = "app";
80+
program = "${sqlit}/bin/sqlit";
81+
};
82+
83+
checks = {
84+
inherit sqlit;
85+
};
86+
87+
devShells.default = pkgs.mkShell {
88+
packages = [
89+
pkgs.python3
90+
pkgs.hatch
91+
pyPkgs.pytest
92+
pyPkgs.pytest-timeout
93+
pyPkgs.pytest-asyncio
94+
pyPkgs.pytest-cov
95+
pyPkgs.pytest-benchmark
96+
pkgs.ruff
97+
pyPkgs.mypy
98+
pkgs.pre-commit
99+
pyPkgs.build
100+
pyPkgs.faker
101+
pyPkgs.ipython
102+
];
103+
inputsFrom = [ sqlit ];
104+
};
105+
});
106+
}

0 commit comments

Comments
 (0)