proper deno dep management
This commit is contained in:
parent
f937a3454d
commit
6abdf04412
11 changed files with 74 additions and 184 deletions
57
flake.lock
generated
57
flake.lock
generated
|
|
@ -1,5 +1,26 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"deno-with-packages": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1754403929,
|
||||||
|
"narHash": "sha256-2+VxvvvOQOmidNGEbJibuYyyFufEvnr37evnZxcf7ao=",
|
||||||
|
"owner": "voleum-org",
|
||||||
|
"repo": "deno-with-packages",
|
||||||
|
"rev": "47ad6f8ad05062db9a2b3dc421f8a0ea5484ce41",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "voleum-org",
|
||||||
|
"repo": "deno-with-packages",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
|
|
@ -18,6 +39,24 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-utils_2": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1753939845,
|
"lastModified": 1753939845,
|
||||||
|
|
@ -36,7 +75,8 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"deno-with-packages": "deno-with-packages",
|
||||||
|
"flake-utils": "flake-utils_2",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -54,6 +94,21 @@
|
||||||
"repo": "default",
|
"repo": "default",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"systems_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,15 @@
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
deno-with-packages.url = "github:voleum-org/deno-with-packages";
|
||||||
|
deno-with-packages.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils }:
|
outputs = { self, nixpkgs, flake-utils, deno-with-packages }:
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
lib = import ./nix;
|
lib = import ./nix // deno-with-packages.lib.${system};
|
||||||
shelf = import ./shelf {
|
shelf = import ./shelf {
|
||||||
inherit pkgs system lib;
|
inherit pkgs system lib;
|
||||||
};
|
};
|
||||||
|
|
@ -22,7 +24,7 @@
|
||||||
buildInputs = [ pkgs.deno ];
|
buildInputs = [ pkgs.deno ];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
export DENO_DIR=$PWD/.deno_cache
|
export DENO_DIR=$PWD/.deno_cache
|
||||||
${shelf.setupScript}
|
${shelf.setupScript}/bin/install-deno-cache
|
||||||
|
|
||||||
echo "Availabe scrolls:"
|
echo "Availabe scrolls:"
|
||||||
echo ${pkgs.lib.escapeShellArg (builtins.toJSON shelf.scrolls)} | jq .
|
echo ${pkgs.lib.escapeShellArg (builtins.toJSON shelf.scrolls)} | jq .
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
let
|
let
|
||||||
lib = {
|
lib = {
|
||||||
buildDenoCache = import ./deno/buildCache.nix { self = lib; };
|
|
||||||
readDenoScroll = import ./deno/readScroll.nix { self = lib; };
|
|
||||||
buildSharedDenoCache = import ./deno/buildSharedCache.nix { self = lib; };
|
|
||||||
makeDenoShelfSetup = import ./deno/makeShelfSetup.nix { self = lib; };
|
|
||||||
discoverScrolls = import ./discoverScrolls.nix { self = lib; };
|
discoverScrolls = import ./discoverScrolls.nix { self = lib; };
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
|
||||||
|
|
@ -1,78 +0,0 @@
|
||||||
{ self }:
|
|
||||||
{ pkgs, system, scrollsDir, subDir, baseCache ? null }:
|
|
||||||
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}";
|
|
||||||
|
|
||||||
scroll = import "${scrollsDir}/${subDir}/scroll.nix";
|
|
||||||
|
|
||||||
hashFilesCat = builtins.concatStringsSep ""
|
|
||||||
(builtins.map builtins.readFile scroll.build.hashFiles);
|
|
||||||
sourceContentHash_ = builtins.convertHash {
|
|
||||||
hash = "sha1:${builtins.hashString "sha1" hashFilesCat}";
|
|
||||||
toHashFormat = "base64";
|
|
||||||
};
|
|
||||||
sourceContentHash = "sha1-${sourceContentHash_}";
|
|
||||||
outputHash =
|
|
||||||
scroll.build.knownHashes.${sourceContentHash}
|
|
||||||
or pkgs.lib.fakeSha256;
|
|
||||||
|
|
||||||
in
|
|
||||||
pkgs.stdenv.mkDerivation {
|
|
||||||
name = if baseCache == null
|
|
||||||
then "${scroll.name}-scroll-env"
|
|
||||||
else "${scroll.name}-incremental-cache";
|
|
||||||
src = scrollsDir;
|
|
||||||
|
|
||||||
passAsFile = [ "knownHashesJson" ];
|
|
||||||
knownHashesJson = builtins.toJSON scroll.build.knownHashes;
|
|
||||||
nativeBuildInputs = [ pkgs.deno pkgs.jq ];
|
|
||||||
dontPatchShebangs = true;
|
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
export DENO_DIR=$out
|
|
||||||
mkdir -p $DENO_DIR
|
|
||||||
|
|
||||||
# Start with base cache if provided
|
|
||||||
${if baseCache != null then ''
|
|
||||||
if [ -d "${baseCache}" ]; then
|
|
||||||
cp -r "${baseCache}"/* "$out/" 2>/dev/null || true
|
|
||||||
find "$out" -type f -exec chmod u+w {} \;
|
|
||||||
find "$out" -type d -exec chmod u+w {} \;
|
|
||||||
fi
|
|
||||||
'' else ""}
|
|
||||||
|
|
||||||
cd ${subDir}
|
|
||||||
echo "Building cache for ${scroll.name}..."
|
|
||||||
${scroll.build.cacheCommand}
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
echo 'sourceContentHash: ${sourceContentHash}'
|
|
||||||
echo ""
|
|
||||||
echo "add me to knownHashes if you see a fake sha256 error ^"
|
|
||||||
echo "DON'T USE JSR DEPS UNLESS YOU MAKE THEM REPRODUCIBLE SOMEHOW"
|
|
||||||
echo ""
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = "true";
|
|
||||||
|
|
||||||
outputHashMode = "recursive";
|
|
||||||
outputHashAlgo = "sha256";
|
|
||||||
inherit outputHash;
|
|
||||||
}
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
{ self }:
|
|
||||||
{ pkgs, system, scrollsDir, subDirs }:
|
|
||||||
let
|
|
||||||
emptyDenoCache = pkgs.runCommand "empty-deno-cache" {} ''
|
|
||||||
mkdir -p $out
|
|
||||||
'';
|
|
||||||
|
|
||||||
in
|
|
||||||
builtins.foldl' (accCache: subDir:
|
|
||||||
self.buildDenoCache {
|
|
||||||
inherit pkgs system scrollsDir subDir;
|
|
||||||
baseCache = accCache;
|
|
||||||
}
|
|
||||||
) emptyDenoCache subDirs
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
{ self }:
|
|
||||||
{ pkgs, sharedCache }:
|
|
||||||
pkgs.writeShellScript "deno-shelf-setup" ''
|
|
||||||
# DENO_DIR should be set by the caller
|
|
||||||
if [ -z "$DENO_DIR" ]; then
|
|
||||||
echo "Error: DENO_DIR environment variable must be set"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "$DENO_DIR" ] || [ "${sharedCache}" -nt "$DENO_DIR/.cache_timestamp" ]; then
|
|
||||||
echo "Setting up shared Deno cache in $DENO_DIR..."
|
|
||||||
|
|
||||||
rm -rf "$DENO_DIR"
|
|
||||||
cp -r "${sharedCache}" "$DENO_DIR"
|
|
||||||
chmod -R u+w "$DENO_DIR"
|
|
||||||
|
|
||||||
touch "$DENO_DIR/.cache_timestamp"
|
|
||||||
echo "Shared Deno cache initialized"
|
|
||||||
else
|
|
||||||
echo "Deno cache is up to date"
|
|
||||||
fi
|
|
||||||
''
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
{ self }:
|
|
||||||
{ pkgs, system, scrollsDir, subDir }:
|
|
||||||
let
|
|
||||||
scroll = import "${scrollsDir}/${subDir}/scroll.nix";
|
|
||||||
in
|
|
||||||
{
|
|
||||||
env = self.buildDenoCache {
|
|
||||||
inherit pkgs system scrollsDir subDir;
|
|
||||||
};
|
|
||||||
meta = builtins.removeAttrs scroll [ "build" ];
|
|
||||||
}
|
|
||||||
|
|
@ -6,23 +6,22 @@ let
|
||||||
scrollsDir = denoScrollsDir;
|
scrollsDir = denoScrollsDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
mkScroll = subDir: lib.readDenoScroll {
|
mkScroll = subDir: import "${denoScrollsDir}/${subDir}/scroll.nix";
|
||||||
inherit pkgs system subDir;
|
|
||||||
scrollsDir = denoScrollsDir;
|
|
||||||
};
|
|
||||||
|
|
||||||
scrolls = builtins.map mkScroll scrollDirs;
|
scrolls = builtins.map mkScroll scrollDirs;
|
||||||
|
|
||||||
sharedCache = lib.buildSharedDenoCache {
|
lockfiles = builtins.map (s: s.build.lockFile) scrolls;
|
||||||
inherit pkgs system;
|
|
||||||
scrollsDir = denoScrollsDir;
|
denoSharedCache = lib.denoSharedCache {
|
||||||
subDirs = scrollDirs;
|
inherit pkgs lockfiles;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
setupScript = lib.makeDenoShelfSetup {
|
setupScript = lib.installDenoCache {
|
||||||
inherit pkgs sharedCache;
|
inherit pkgs;
|
||||||
|
cache = denoSharedCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
scrolls = builtins.map (s: s.meta) scrolls;
|
scrolls =
|
||||||
|
builtins.map (s: builtins.removeAttrs s [ "build" ]) scrolls;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
{
|
|
||||||
name = "hjq";
|
|
||||||
|
|
||||||
description = "Drop-in jq replacement for HJSON that tries to preserve comments";
|
|
||||||
|
|
||||||
inputs = {
|
|
||||||
stdin = {
|
|
||||||
format = "HJSON";
|
|
||||||
react = "push";
|
|
||||||
};
|
|
||||||
jqFilter = {
|
|
||||||
format = "string";
|
|
||||||
react = "push";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs = {
|
|
||||||
stdout = {
|
|
||||||
format = "HJSON";
|
|
||||||
react = "push";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
build = {
|
|
||||||
hashFiles = [ ./deno.json ./deno.lock ];
|
|
||||||
cacheCommand = "deno cache --frozen main.ts";
|
|
||||||
knownHashes = {
|
|
||||||
"sha1-gSeoE0sSj+dFQ7SUoyaQV0X/KJE=" =
|
|
||||||
"sha256-0ZfdWVfShbhgAoSse9vEpFPRh5XTTVjgxGMmezwon1I=";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"start": "deno run --cached-only main.ts"
|
"start": "deno run --cached-only main.ts"
|
||||||
},
|
},
|
||||||
"patch": [
|
"links": [
|
||||||
"../hjq"
|
"../hjq"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,6 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
build = {
|
build = {
|
||||||
hashFiles = [ ./deno.json ./deno.lock ];
|
lockFile = ./deno.lock;
|
||||||
cacheCommand = "deno cache --frozen main.ts";
|
|
||||||
knownHashes = {
|
|
||||||
"sha1-uO43Rt1F6+Ud1wk2p9LQhfP180M=" =
|
|
||||||
"sha256-x/Fvn/l3J7C0D7AftlbRk7iuc6o9qPakdnHb72TSxec=";
|
|
||||||
} ;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue