-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from brianmcgee/feat/db
Packages for reading sqlite databases
- Loading branch information
Showing
38 changed files
with
1,818 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
watch_file devshell.nix | ||
|
||
if nix flake metadata &>/dev/null; then | ||
use flake | ||
else | ||
use nix | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
fixtures: | ||
name: fixtures-up-to-date | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: cachix/install-nix-action@v22 | ||
with: | ||
install_url: https://releases.nixos.org/nix/nix-2.12.1/install | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
- name: Build fixtures | ||
run: bash -c 'cd test/testdata && ./build-fixtures.go' | ||
- name: Diff fixtures | ||
run: git diff --exit-code test/testdata | ||
fixtures: | ||
name: fixtures-up-to-date | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: cachix/install-nix-action@v22 | ||
with: | ||
install_url: https://releases.nixos.org/nix/nix-2.12.1/install | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.21" | ||
- name: Build fixtures | ||
run: bash -c 'cd test/testdata && ./build-fixtures.go' | ||
- name: Diff fixtures | ||
run: git diff --exit-code test/testdata | ||
|
||
build: | ||
strategy: | ||
matrix: | ||
os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] | ||
go: [ '1.20', '1.21' ] | ||
runs-on: ${{ matrix.os }} | ||
build: | ||
strategy: | ||
matrix: | ||
os: ["ubuntu-latest", "macos-latest", "windows-latest"] | ||
go: ["1.20", "1.21"] | ||
runs-on: ${{ matrix.os }} | ||
|
||
name: Build (Go ${{ matrix.go }}, OS ${{ matrix.os }}) | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
- name: go test -race -bench='.+' -v ./... | ||
run: go test -race -bench='.+' -v ./... | ||
name: Build (Go ${{ matrix.go }}, OS ${{ matrix.os }}) | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
- name: go test -race -bench='.+' -v ./... | ||
run: go test -race -bench='.+' -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
name: golangci-lint | ||
on: | ||
push: | ||
tags: | ||
- v* | ||
branches: | ||
- main | ||
pull_request: | ||
push: | ||
tags: | ||
- v* | ||
branches: | ||
- main | ||
pull_request: | ||
permissions: | ||
contents: read | ||
# Optional: allow read access to pull request. Use with `only-new-issues` option. | ||
# pull-requests: read | ||
contents: read | ||
# Optional: allow read access to pull request. Use with `only-new-issues` option. | ||
# pull-requests: read | ||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version | ||
version: v1.61.0 | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version | ||
version: v1.61.0 | ||
|
||
# Optional: working directory, useful for monorepos | ||
# working-directory: somedir | ||
# Optional: working directory, useful for monorepos | ||
# working-directory: somedir | ||
|
||
# Optional: golangci-lint command line arguments. | ||
args: --timeout=10m | ||
# Optional: golangci-lint command line arguments. | ||
args: --timeout=10m | ||
|
||
# Optional: show only new issues if it's a pull request. The default value is `false`. | ||
# only-new-issues: true | ||
# Optional: show only new issues if it's a pull request. The default value is `false`. | ||
# only-new-issues: true | ||
|
||
# Optional: if set to true then the action will use pre-installed Go. | ||
# skip-go-installation: true | ||
# Optional: if set to true then the action will use pre-installed Go. | ||
# skip-go-installation: true | ||
|
||
# Optional: if set to true then the action don't cache or restore ~/go/pkg. | ||
# skip-pkg-cache: true | ||
# Optional: if set to true then the action don't cache or restore ~/go/pkg. | ||
# skip-pkg-cache: true | ||
|
||
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build. | ||
# skip-build-cache: true | ||
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build. | ||
# skip-build-cache: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
linters: | ||
enable: | ||
- errname | ||
- exhaustive | ||
- gci | ||
- gochecknoglobals | ||
- gochecknoinits | ||
- goconst | ||
- godot | ||
- gofumpt | ||
- goheader | ||
- goimports | ||
- gosec | ||
- importas | ||
- ireturn | ||
- lll | ||
- makezero | ||
- misspell | ||
- nakedret | ||
- nestif | ||
- nilerr | ||
- nilnil | ||
- nlreturn | ||
- noctx | ||
- nolintlint | ||
- prealloc | ||
- predeclared | ||
- revive | ||
- rowserrcheck | ||
- stylecheck | ||
- tagliatelle | ||
- tenv | ||
- testpackage | ||
- unconvert | ||
- unparam | ||
- wastedassign | ||
- whitespace | ||
- wsl | ||
enable: | ||
- errname | ||
- exhaustive | ||
- gci | ||
- gochecknoglobals | ||
- gochecknoinits | ||
- goconst | ||
- godot | ||
- gofumpt | ||
- goheader | ||
- goimports | ||
- gosec | ||
- importas | ||
- ireturn | ||
- lll | ||
- makezero | ||
- misspell | ||
- nakedret | ||
- nestif | ||
- nilerr | ||
- nilnil | ||
- nlreturn | ||
- noctx | ||
- nolintlint | ||
- prealloc | ||
- predeclared | ||
- revive | ||
- rowserrcheck | ||
- stylecheck | ||
- tagliatelle | ||
- tenv | ||
- testpackage | ||
- unconvert | ||
- unparam | ||
- wastedassign | ||
- whitespace | ||
- wsl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,80 @@ | ||
# go-nix - Nix experiments written in go | ||
|
||
*STATUS*: experimental | ||
_STATUS_: experimental | ||
|
||
This repository holds a bunch of experiments written in Go. | ||
|
||
## `cmd/gonix` | ||
|
||
A command line entrypoint called `gonix`, currently implementing the nar | ||
{cat,dump-path,ls} commands. | ||
|
||
They're not meant to be 100% compatible, but are documented in the `--help` | ||
output. | ||
|
||
## `pkg/derivation` | ||
|
||
A parser for Nix `.drv` files. | ||
Functions to calculate derivation paths and output hashes. | ||
|
||
## `pkg/derivation/store` | ||
|
||
A Structure to hold derivation graphs. | ||
|
||
## `pkg/hash` | ||
|
||
Methods to serialize and deserialize some of the hashes used in nix code and | ||
`.narinfo` files. | ||
|
||
## `pkg/nar` | ||
|
||
A Nix ARchive (NAR) file Reader and Writer, with an interface similar to | ||
`archive/tar` from the stdlib, as well as a `DumpPath` method, which | ||
will assemble a NAR representation of a local file system path. | ||
|
||
## `pkg/nar/ls` | ||
|
||
A parser for .ls files (providing an index for .nar files) | ||
|
||
## `pkg/nar/narinfo` | ||
|
||
A parser and generator for `.narinfo` files. | ||
|
||
## `pkg/nixbase32` | ||
|
||
An implementation of the slightly odd "base32" encoding that's used in Nix, | ||
providing some of the functions in `encoding/base32.Encoding`. | ||
|
||
## `pkg/storepath` | ||
|
||
A parser and regexes for Nix Store Paths. | ||
|
||
## `pkg/storepath/references` | ||
|
||
A Nix Store path reference scanner. | ||
|
||
## `pkg/sqlite` | ||
|
||
A collection of interfaces and utilities for writing to and querying various `sqlite` databases that Nix uses. | ||
|
||
[sqlc]: https://github.com/sqlc-dev/sqlc | ||
|
||
## `pkg/sqlite/binary_cache_v6` | ||
|
||
[SQLC] generated code for querying the Nar Info Disk Cache, typically located at `$XDG_CACHE_HOME/nix/binary-cache-v6.sqlite`. | ||
|
||
## `pkg/sqlite/eval_cache_v5` | ||
|
||
[SQLC] generated code for querying an instance of the Eval Cache, typically located at `$XDG_CACHE_HOME/nix/eval-cache-v5/*.sqlite`. | ||
|
||
## `pkg/sqlite/fetcher_cache_v2` | ||
|
||
[SQLC] generated code for querying the fetcher cache, typically located in `$XDG_CACHE_HOME/nix/fetcher-cache-v2.sqlite`. | ||
|
||
## `pkg/sqlite/nix_v10` | ||
|
||
[SQLC] generated code for querying the main Nix database, typically located in `/nix/var/nix/db.sqlite`. | ||
|
||
## `pkg/wire` | ||
|
||
Methods to parse and produce fields used in the low-level Nix wire protocol. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This file provides backward compatibility to nix < 2.4 clients | ||
{ | ||
system ? builtins.currentSystem, | ||
}: | ||
let | ||
lock = builtins.fromJSON (builtins.readFile ./flake.lock); | ||
|
||
root = lock.nodes.${lock.root}; | ||
inherit (lock.nodes.${root.inputs.flake-compat}.locked) | ||
owner | ||
repo | ||
rev | ||
narHash | ||
; | ||
|
||
flake-compat = fetchTarball { | ||
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; | ||
sha256 = narHash; | ||
}; | ||
|
||
flake = import flake-compat { | ||
inherit system; | ||
src = ./.; | ||
}; | ||
in | ||
flake.defaultNix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
perSystem, | ||
pkgs, | ||
... | ||
}: | ||
pkgs.mkShell { | ||
env.GOROOT = "${pkgs.go}/share/go"; | ||
|
||
packages = | ||
(with pkgs; [ | ||
delve | ||
pprof | ||
go | ||
gotools | ||
golangci-lint | ||
lazysql | ||
sqlc | ||
]) | ||
++ (with perSystem; [ | ||
gomod2nix.default | ||
]); | ||
} |
Oops, something went wrong.