dev: devenv.nix, nosdump pkg

This commit is contained in:
2026-04-09 10:44:46 +02:00
parent a07942b644
commit 4b7fe1b9ed
7 changed files with 395 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
export DIRENV_WARN_TIMEOUT=20s
eval "$(devenv direnvrc)"
# `use devenv` supports the same options as the `devenv shell` command.
#
# To silence all output, use `--quiet`.
#
# Example usage: use devenv --quiet --impure --option services.postgres.enable:bool true
use devenv
+15
View File
@@ -25,3 +25,18 @@ Thumbs.db
# Env files
.env
.env.local
# To do list
/TODO.md
# Devenv
.devenv*
.env
.null-ls_*.nix
devenv.local.nix
# direnv
.direnv
# pre-commit
.pre-commit-config.yaml
+139
View File
@@ -0,0 +1,139 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1774475276,
"owner": "cachix",
"repo": "devenv",
"rev": "f8ca2c061ec2feceee1cf1c5e52c92f58b6aec9c",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1767039857,
"owner": "NixOS",
"repo": "flake-compat",
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "flake-compat",
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1774104215,
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "f799ae951fde0627157f40aec28dec27b22076d0",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1762808025,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "cb5e3fdca1de58ccbc3ef53de65bd372b48f567c",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"inputs": {
"nixpkgs-src": "nixpkgs-src"
},
"locked": {
"lastModified": 1774287239,
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "fa7125ea7f1ae5430010a6e071f68375a39bd24c",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"nixpkgs-src": {
"flake": false,
"locked": {
"lastModified": 1769922788,
"narHash": "sha256-H3AfG4ObMDTkTJYkd8cz1/RbY9LatN5Mk4UF48VuSXc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "207d15f1a6603226e1e223dc79ac29c7846da32e",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1774386573,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "46db2e09e1d3f113a13c0d7b81e2f221c63b8ce9",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"git-hooks": "git-hooks",
"nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable",
"pre-commit-hooks": [
"git-hooks"
]
}
}
},
"root": "root",
"version": 7
}
+90
View File
@@ -0,0 +1,90 @@
{
pkgs,
lib,
inputs,
...
}: let
system = pkgs.stdenv.system;
pkgs-unstable = inputs.nixpkgs-unstable.legacyPackages.${system};
in {
# https://devenv.sh/basics/
env = {
# Parallel deps compilation
MIX_OS_DEPS_COMPILE_PARTITION_COUNT = 8;
# Enable JS/LV debugging (required?)
NODE_ENV = "development";
};
# https://devenv.sh/packages/
packages = with pkgs;
[
git
# linter and formatter for JavaScript, TypeScript, JSX, CSS and GraphQL
prettier
# Nix code formatter
alejandra
# Nostr tooling
pkgs-unstable.nak
pkgs-unstable.algia
(pkgs-unstable.callPackage ./nix/nosdump.nix {})
]
++
# Linux only
lib.optionals pkgs.stdenv.isLinux [
# for ExUnit notifier
libnotify
# for package - file_system
inotify-tools
];
# https://devenv.sh/tests/
# enterTest = ''
# echo "Running tests"
# git --version | grep "2.42.0"
# '';
# https://devenv.sh/languages/
languages = {
elixir = {
enable = true;
package = pkgs.elixir_1_19;
};
javascript = {
enable = true;
package = pkgs.nodejs_24;
npm.enable = true;
};
};
# dotenv.enable = true;
devenv.warnOnNewVersion = false;
# https://devenv.sh/pre-commit-hooks/
git-hooks.hooks = {
alejandra.enable = true;
prettier.enable = true;
prettier.files = "\\.(js|ts|tsx|css)$";
check-added-large-files = {
enable = true;
args = ["--maxkb=131072"];
};
mix-format.enable = true;
mix-format.files = "\\.(ex|exs|heex)$";
};
# https://devenv.sh/scripts/
enterShell = ''
echo
elixir --version
echo -n "Node.js "
node --version
echo
'';
# scripts = {
# };
# See full reference at https://devenv.sh/reference/options/
}
+17
View File
@@ -0,0 +1,17 @@
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
nixpkgs-unstable:
url: github:NixOS/nixpkgs/nixos-unstable
# If you're using non-OSS software, you can set allowUnfree to true.
# allowUnfree: true
# If you're willing to use a package that's vulnerable
# permittedInsecurePackages:
# - "openssl-1.1.1w"
# If you have more than one devenv you can merge them
#imports:
# - ./backend
+30
View File
@@ -0,0 +1,30 @@
--- a/command.ts
+++ b/command.ts
@@ -3,8 +3,6 @@ import { toText as streamToText } from "@std/streams";
import type { ArgumentValue } from "@cliffy/command";
import { Command, ValidationError } from "@cliffy/command";
import { CompletionsCommand } from "@cliffy/command/completions";
-import { UpgradeCommand } from "@cliffy/command/upgrade";
-import { JsrProvider } from "@cliffy/command/upgrade/provider/jsr";
import type { AllEventsIterOptions, FetchFilter, FetchTimeRangeFilter } from "nostr-fetch";
import * as nip19 from "nostr-tools/nip19";
@@ -29,18 +27,6 @@ export const nosdumpCommand = new Command()
.description("A tool to dump events stored in Nostr relays")
.usage("[options...] <relays...>")
.command("completions", new CompletionsCommand())
- .command(
- "upgrade",
- new UpgradeCommand({
- provider: [
- new JsrProvider({
- scope: "jiftechnify",
- package: "@jiftechnify/nosdump",
- }),
- ],
- args: ["--allow-all"], // grant all permissions while upgrading
- }),
- )
.command("relay-alias", relayAliasCommand).alias("alias")
.command("relay-set", relaySetCommand).alias("rset")
.reset()
+92
View File
@@ -0,0 +1,92 @@
{
lib,
stdenv,
fetchFromGitHub,
deno,
}: let
pname = "nosdump";
version = "0.7.1";
src = fetchFromGitHub {
owner = "jiftechnify";
repo = "nosdump";
rev = version;
hash = "sha256-sn6KUZWA2Y65Y/f1J718pT/a2BvX1Vr1LMe5RL4KtrM=";
};
# Fixed-output derivation: materialise DENO_DIR with all remote deps
# (jsr: + npm:) so the main build runs fully offline.
#
# To obtain the real hash after changing version or deps:
# nix build --impure --expr '(import <nixpkgs> {}).callPackage ./nix/nosdump.nix {}'
# The error output will contain the correct sha256 to substitute below.
denoCache = stdenv.mkDerivation {
name = "${pname}-${version}-deno-cache";
inherit src;
nativeBuildInputs = [deno];
outputHash = "sha256-v9hQQvYrnYVTlGud+i67rCZiw7nYq0MvXT8Lb7sSm30=";
outputHashMode = "recursive";
outputHashAlgo = "sha256";
buildPhase = ''
export HOME="$TMPDIR/home"
export DENO_DIR="$out"
mkdir -p "$HOME" "$DENO_DIR"
deno cache --frozen mod.ts
'';
dontInstall = true;
};
in
stdenv.mkDerivation {
inherit pname version src;
nativeBuildInputs = [deno];
patches = [./nosdump-no-upgrade.patch];
dontConfigure = true;
buildPhase = ''
runHook preBuild
export HOME="$TMPDIR/home"
export DENO_DIR="$TMPDIR/deno-dir"
mkdir -p "$HOME" "$DENO_DIR"
# DENO_DIR in the Nix store is read-only; Deno needs to write SQLite
# check/v8 caches at runtime, so we copy the pre-fetched cache here.
cp -r ${denoCache}/. "$DENO_DIR/"
chmod -R u+w "$DENO_DIR"
deno compile \
--cached-only \
--frozen \
--no-check \
--allow-env \
--allow-net \
--allow-read \
--allow-write \
--allow-sys \
--output nosdump \
mod.ts
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -Dm755 nosdump "$out/bin/nosdump"
runHook postInstall
'';
meta = with lib; {
description = "Dump events from Nostr relays";
homepage = "https://github.com/jiftechnify/nosdump";
license = licenses.mit;
mainProgram = "nosdump";
platforms = platforms.linux ++ platforms.darwin;
};
}