improve shelf hiearchy

This commit is contained in:
EatThePooh 2025-08-02 10:24:01 +07:00
parent 928c1067b3
commit 9c18a0c924
5 changed files with 46 additions and 18 deletions

View file

@ -1,5 +1,5 @@
{
description = "Deno development environment";
description = "Grimu-R base";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
@ -10,23 +10,16 @@
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
denoWorkspace = import ./shelf/deno-workspace.nix {
shelf = import ./shelf {
inherit pkgs system;
# collective hash of all deno sources - resulting shared deno cache hash
knownDenoHashes = {
"UnKGEQo7oF1X5JeWyx7w0oCwqPQ=" =
"sha256-7csbrTbGd6J4a0Gkj9ndKhNxv90KeOHjr7DDNal3L4Q=";
};
};
in
{
packages.shelf = shelf;
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"
${shelf.setupScript}
'';
};
});

24
shelf/default.nix Normal file
View file

@ -0,0 +1,24 @@
{ pkgs, system }:
let
denoShelf = import ./deno {
inherit pkgs system;
# collective hash of all (relevant) deno sources
# mapped to resulting shared deno cache hash
knownDenoHashes = {
"2JQI9Ie/fkl5Ltr22BGJynF9tFc=" =
"sha256-7csbrTbGd6J4a0Gkj9ndKhNxv90KeOHjr7DDNal3L4Q=";
};
};
shelfSetup = pkgs.writeShellScript "setup-shelf" ''
export DENO_DIR=$PWD/.deno_cache
rm -rf $DENO_DIR
cp -r ${denoShelf.cache} $DENO_DIR
chmod -R u+w "$DENO_DIR"
# TODO: add other interpreters
'';
in
{
setupScript = shelfSetup;
}

View file

@ -15,9 +15,9 @@ let
hash = "sha256-ukIk8K2CE+N+3eFs++RPiGZlhhRRVk1gjhdt77/s+4o=";
};
scrollsDir = ./deno;
scrollsDir = ./.;
lib = pkgs.lib;
packageDirs = builtins.attrNames (builtins.readDir scrollsDir);
packageDirs = [ "./hjq" "./uses-hjq" ];
# hash only dependency-relevant files (lock files and configs)
hashDependencyFiles = dir:
@ -98,4 +98,6 @@ let
};
in
unifiedCache
{
cache = unifiedCache;
}

View file

@ -4,12 +4,21 @@
description = "Drop-in jq replacement for HJSON that tries to preserve comments";
inputs = {
stdin = "HJSON";
jq_filter = "string";
stdin = {
format = "HJSON";
react = "push";
};
jq_filter = {
format = "string";
react = "push";
};
};
outputs = {
stdout = "HJSON";
stdout = {
format = "HJSON";
react = "push";
};
};
cache-command = "deno cache --reload main.ts";

View file

@ -2,7 +2,7 @@
"tasks": {
"start": "deno run --cached-only main.ts"
},
"links": [
"patch": [
"../hjq"
]
}