proper scrolls
This commit is contained in:
parent
d92bc3b437
commit
9df3f362fe
11 changed files with 146 additions and 36 deletions
46
flake.nix
46
flake.nix
|
|
@ -10,39 +10,19 @@
|
|||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
toDenoTarget = system:
|
||||
let
|
||||
arch = builtins.head (builtins.split "-" system);
|
||||
os = builtins.elemAt (builtins.split "-" system) 1;
|
||||
vendor = if os == "darwin" then "apple" else "unknown";
|
||||
sys = if os == "darwin" then "darwin" else "linux-gnu";
|
||||
in "${arch}-${vendor}-${sys}";
|
||||
|
||||
target = toDenoTarget system;
|
||||
hjq = import ./shelf/hjq/package.nix {
|
||||
inherit pkgs;
|
||||
inherit target;
|
||||
denoWorkspace = import ./shelf/deno-workspace.nix {
|
||||
inherit pkgs system;
|
||||
};
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
deno
|
||||
hjq
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
echo "🦕 Deno development environment loaded!"
|
||||
echo "Deno version: $(deno --version | head -n1)"
|
||||
'';
|
||||
|
||||
DENO_DIR = "./.deno_cache";
|
||||
};
|
||||
|
||||
# unfortunately this derivation is impure because
|
||||
# managing deno's deps is HARD, so
|
||||
# nix build --option sanbox relaxed
|
||||
packages.default = hjq;
|
||||
|
||||
});
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [ ];
|
||||
shellHook = ''
|
||||
export DENO_DIR=$PWD/.deno_cache
|
||||
rm -rf $DENO_DIR
|
||||
cp -r ${denoWorkspace} $DENO_DIR
|
||||
chmod -R u+w "$DENO_DIR"
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
|||
63
shelf/deno-workspace.nix
Normal file
63
shelf/deno-workspace.nix
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
{ pkgs, system }:
|
||||
|
||||
let
|
||||
target =
|
||||
let
|
||||
arch = builtins.head (builtins.split "-" system);
|
||||
os = builtins.elemAt (builtins.split "-" system) 1;
|
||||
vendor = if os == "darwin" then "apple" else "unknown";
|
||||
sys = if os == "darwin" then "darwin" else "linux-gnu";
|
||||
in "${arch}-${vendor}-${sys}";
|
||||
|
||||
# currently unused, needed for deno compile
|
||||
denort = pkgs.fetchzip {
|
||||
url = "https://dl.deno.land/release/v${pkgs.deno.version}/denort-${target}.zip";
|
||||
hash = "sha256-ukIk8K2CE+N+3eFs++RPiGZlhhRRVk1gjhdt77/s+4o=";
|
||||
};
|
||||
|
||||
scrollsDir = ./deno;
|
||||
lib = pkgs.lib;
|
||||
packageDirs = builtins.attrNames (builtins.readDir scrollsDir);
|
||||
|
||||
# Separate FOD for cache only
|
||||
unifiedCache = pkgs.stdenv.mkDerivation {
|
||||
name = "deno-scrolls-cache";
|
||||
src = scrollsDir;
|
||||
|
||||
nativeBuildInputs = [ pkgs.deno pkgs.jq ];
|
||||
dontPatchShebangs = true;
|
||||
|
||||
buildPhase = ''
|
||||
export DENO_DIR=$out
|
||||
|
||||
${lib.concatStringsSep "\n" (map (pkg:
|
||||
let config = import (scrollsDir + "/${pkg}/scroll.nix");
|
||||
in ''
|
||||
echo "Caching ${pkg}..."
|
||||
cd ${pkg}
|
||||
${config.cache-command}
|
||||
cd ..
|
||||
''
|
||||
) packageDirs)}
|
||||
|
||||
echo 'Go fuck yourself, SQLite!'
|
||||
find $out -name "*-wal" -delete
|
||||
find $out -name "*-shm" -delete
|
||||
|
||||
echo 'Go fuck yourself, JSON!'
|
||||
find $out/npm -name "*.json" -type f 2>/dev/null | while read -r file; do
|
||||
if ${pkgs.jq}/bin/jq empty "$file" 2>/dev/null; then
|
||||
${pkgs.jq}/bin/jq -S . "$file" > "$file.tmp" && mv "$file.tmp" "$file"
|
||||
fi
|
||||
done
|
||||
'';
|
||||
|
||||
installPhase = "true";
|
||||
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHash = "sha256-maP/JMY6n95A9FQx72YFwRtnprGXc97v1ZdPgt2GB8s=";
|
||||
};
|
||||
|
||||
in
|
||||
unifiedCache
|
||||
10
shelf/deno/hjq/deno.json
Normal file
10
shelf/deno/hjq/deno.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "hjq",
|
||||
"exports": {
|
||||
".": "./main.ts"
|
||||
},
|
||||
"imports": {
|
||||
"hjson": "npm:hjson@^3.2.2",
|
||||
"jq-web": "npm:jq-web@^0.6.2"
|
||||
}
|
||||
}
|
||||
21
shelf/deno/hjq/deno.lock
generated
Normal file
21
shelf/deno/hjq/deno.lock
generated
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"version": "4",
|
||||
"specifiers": {
|
||||
"npm:hjson@^3.2.2": "3.2.2",
|
||||
"npm:jq-web@~0.6.2": "0.6.2"
|
||||
},
|
||||
"npm": {
|
||||
"hjson@3.2.2": {
|
||||
"integrity": "sha512-MkUeB0cTIlppeSsndgESkfFD21T2nXPRaBStLtf3cAYA2bVEFdXlodZB0TukwZiobPD1Ksax5DK4RTZeaXCI3Q=="
|
||||
},
|
||||
"jq-web@0.6.2": {
|
||||
"integrity": "sha512-+7XvjBYwTx4vP5PYkf6Q6orubO/v+UgMU6By1GritrmShr9QpT3UKa4ANzXWQfhdqtBnQYXsm7ZNbdIHT6tYpQ=="
|
||||
}
|
||||
},
|
||||
"workspace": {
|
||||
"dependencies": [
|
||||
"npm:hjson@^3.2.2",
|
||||
"npm:jq-web@~0.6.2"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
// a basic drop-in replacement for jq to handle HJSON
|
||||
// tries to preserve comments but doesn't do a very good job :(
|
||||
|
||||
import Hjson from "npm:hjson";
|
||||
import jqModule from "npm:jq-web";
|
||||
import Hjson from "hjson";
|
||||
import jqModule from "jq-web";
|
||||
import fs from "node:fs";
|
||||
|
||||
export const n = 42;
|
||||
|
||||
const jq = await jqModule;
|
||||
|
||||
var filter = process.argv[2];
|
||||
|
|
@ -22,6 +22,8 @@ pkgs.stdenv.mkDerivation rec {
|
|||
unzip ${denort}
|
||||
chmod +x denort
|
||||
popd
|
||||
|
||||
deno cache --reload main.ts
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
|
|
@ -29,7 +31,7 @@ pkgs.stdenv.mkDerivation rec {
|
|||
|
||||
export DENORT_BIN="$TMPDIR/denort/denort"
|
||||
|
||||
deno compile --target=${target} --output app main.ts
|
||||
deno compile --target=${target} --cached-only --output app main.ts
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
3
shelf/deno/hjq/scroll.nix
Normal file
3
shelf/deno/hjq/scroll.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
cache-command = "deno cache --reload main.ts";
|
||||
}
|
||||
8
shelf/deno/uses-hjq/deno.json
Normal file
8
shelf/deno/uses-hjq/deno.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"tasks": {
|
||||
"start": "deno run --cached-only main.ts"
|
||||
},
|
||||
"patch": [
|
||||
"../hjq"
|
||||
]
|
||||
}
|
||||
15
shelf/deno/uses-hjq/deno.lock
generated
Normal file
15
shelf/deno/uses-hjq/deno.lock
generated
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"version": "4",
|
||||
"specifiers": {
|
||||
"npm:hjson@^3.2.2": "3.2.2",
|
||||
"npm:jq-web@~0.6.2": "0.6.2"
|
||||
},
|
||||
"npm": {
|
||||
"hjson@3.2.2": {
|
||||
"integrity": "sha512-MkUeB0cTIlppeSsndgESkfFD21T2nXPRaBStLtf3cAYA2bVEFdXlodZB0TukwZiobPD1Ksax5DK4RTZeaXCI3Q=="
|
||||
},
|
||||
"jq-web@0.6.2": {
|
||||
"integrity": "sha512-+7XvjBYwTx4vP5PYkf6Q6orubO/v+UgMU6By1GritrmShr9QpT3UKa4ANzXWQfhdqtBnQYXsm7ZNbdIHT6tYpQ=="
|
||||
}
|
||||
}
|
||||
}
|
||||
3
shelf/deno/uses-hjq/main.ts
Normal file
3
shelf/deno/uses-hjq/main.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import {n} from 'hjq';
|
||||
|
||||
console.log("I use hjq:", n);
|
||||
3
shelf/deno/uses-hjq/scroll.nix
Normal file
3
shelf/deno/uses-hjq/scroll.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
cache-command = "deno cache -I --reload main.ts";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue