fix: Fix using unable character for drv name (#5)
This commit is contained in:
parent
e8765a69c3
commit
638631c842
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"tasks": {
|
||||
"run": "deno run ./mod.ts"
|
||||
"run": "deno run --import-map=./import_map.json ./mod.ts",
|
||||
"cache": "deno cache --import-map=./import_map.json --lock lock.json --lock-write ./mod.ts"
|
||||
},
|
||||
"fmt": {
|
||||
"options": {
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
[devshell]
|
||||
packages = [
|
||||
"alejandra", # Formatter for nix
|
||||
"deno",
|
||||
"taplo-cli",
|
||||
]
|
||||
|
||||
[[commands]]
|
||||
package = "treefmt"
|
||||
category = "formatter"
|
||||
|
||||
[[commands]]
|
||||
name = "update_lockfile"
|
||||
command = "deno cache --import-map=./import_map.json --lock lock.json --lock-write ./mod.ts"
|
45
flake.nix
45
flake.nix
|
@ -1,23 +1,27 @@
|
|||
{
|
||||
# main
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
devshell.url = "github:numtide/devshell";
|
||||
};
|
||||
|
||||
# dev
|
||||
inputs = {
|
||||
devshell.url = "github:numtide/devshell";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
flake-compat = {
|
||||
url = "github:edolstra/flake-compat";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
devshell,
|
||||
...
|
||||
} @ inputs:
|
||||
{
|
||||
overlays.default = import ./overlay.nix;
|
||||
overlays.default = import ./nix/overlay.nix;
|
||||
overlay = self.overlays.default;
|
||||
}
|
||||
// flake-utils.lib.eachSystem [
|
||||
|
@ -25,34 +29,36 @@
|
|||
]
|
||||
(
|
||||
system: let
|
||||
inherit (pkgs) deno2nix;
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
devshell.overlay
|
||||
overlays = with inputs; [
|
||||
self.overlays.default
|
||||
devshell.overlay
|
||||
];
|
||||
};
|
||||
in {
|
||||
packages.bundled = pkgs.deno2nix.mkBundled {
|
||||
packages.depslink = deno2nix.internal.mkDepsLink ./lock.json;
|
||||
packages.bundled = deno2nix.mkBundled {
|
||||
name = "example";
|
||||
version = "0.1.0";
|
||||
src = self;
|
||||
src = ./.;
|
||||
lockfile = ./lock.json;
|
||||
importMap = ./import_map.json;
|
||||
entrypoint = ./mod.ts;
|
||||
};
|
||||
packages.wrapper = pkgs.deno2nix.mkBundledWrapper {
|
||||
packages.wrapper = deno2nix.mkBundledWrapper {
|
||||
name = "example";
|
||||
version = "0.1.0";
|
||||
src = self;
|
||||
src = ./.;
|
||||
lockfile = ./lock.json;
|
||||
importMap = ./import_map.json;
|
||||
entrypoint = ./mod.ts;
|
||||
};
|
||||
packages.executable = pkgs.deno2nix.mkExecutable {
|
||||
packages.executable = deno2nix.mkExecutable {
|
||||
name = "example";
|
||||
version = "0.1.0";
|
||||
src = self;
|
||||
src = ./.;
|
||||
lockfile = ./lock.json;
|
||||
importMap = ./import_map.json;
|
||||
entrypoint = ./mod.ts;
|
||||
|
@ -66,9 +72,18 @@
|
|||
|
||||
checks = self.packages.${system};
|
||||
|
||||
devShell = pkgs.devshell.mkShell {
|
||||
imports = [
|
||||
(pkgs.devshell.importTOML ./devshell.toml)
|
||||
devShells.default = pkgs.devshell.mkShell {
|
||||
packages = with pkgs; [
|
||||
alejandra
|
||||
deno
|
||||
treefmt
|
||||
taplo-cli
|
||||
];
|
||||
commands = [
|
||||
{
|
||||
package = "treefmt";
|
||||
category = "formatters";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
49
nix/internal.nix
Normal file
49
nix/internal.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
linkFarm,
|
||||
writeText,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) split elemAt fetchurl toJSON hashString baseNameOf;
|
||||
inherit (lib) flatten mapAttrsToList importJSON;
|
||||
inherit (lib.strings) sanitizeDerivationName;
|
||||
|
||||
# https://deno.land/std@0.118.0/fmt/colors.ts
|
||||
#
|
||||
# 0. "https"
|
||||
# 1. "deno.land"
|
||||
# 2. "/std@0.118.0/fmt/colors.ts"
|
||||
urlPart = url: elemAt (flatten (split "://([a-z0-9\.]*)" url));
|
||||
|
||||
# https://deno.land/std@0.118.0/fmt/colors.ts
|
||||
#
|
||||
# https/deno.land/<sha256 "/std@0.118.0/fmt/colors.ts">
|
||||
artifactPath = url: let up = urlPart url; in "${up 0}/${up 1}/${hashString "sha256" (up 2)}";
|
||||
in {
|
||||
mkDepsLink = lockfile: (
|
||||
linkFarm "deps" (flatten (
|
||||
mapAttrsToList
|
||||
(
|
||||
url: sha256: let
|
||||
in [
|
||||
{
|
||||
name = artifactPath url;
|
||||
path = fetchurl {
|
||||
inherit url sha256;
|
||||
name = sanitizeDerivationName (baseNameOf url);
|
||||
};
|
||||
}
|
||||
{
|
||||
name = artifactPath url + ".metadata.json";
|
||||
path = writeText "metadata.json" (toJSON {
|
||||
inherit url;
|
||||
headers = {};
|
||||
});
|
||||
}
|
||||
]
|
||||
)
|
||||
(importJSON lockfile)
|
||||
))
|
||||
);
|
||||
}
|
|
@ -1,6 +1,12 @@
|
|||
{pkgs, ...}: {name, ...} @ args: let
|
||||
bundled = (pkgs.callPackage ./make-bundled.nix {}) args;
|
||||
{
|
||||
pkgs,
|
||||
deno,
|
||||
deno2nix,
|
||||
writeShellScriptBin,
|
||||
...
|
||||
}: {name, ...} @ args: let
|
||||
bundled = deno2nix.mkBundled args;
|
||||
in
|
||||
pkgs.writeShellScriptBin
|
||||
writeShellScriptBin
|
||||
"${name}"
|
||||
"${pkgs.deno}/bin/deno run ${bundled}/dist/bundled.js"
|
||||
"${deno}/bin/deno run ${bundled}/dist/bundled.js"
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{
|
||||
pkgs,
|
||||
lib ? pkgs.lib,
|
||||
stdenv,
|
||||
deno2nix,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
name,
|
||||
|
@ -11,9 +13,9 @@
|
|||
importMap ? null,
|
||||
denoFlags ? [],
|
||||
}: let
|
||||
inherit (pkgs.callPackage ./utils.nix {}) mkDepsLink;
|
||||
inherit (deno2nix.internal) mkDepsLink;
|
||||
in
|
||||
pkgs.stdenv.mkDerivation {
|
||||
stdenv.mkDerivation {
|
||||
inherit name version entrypoint;
|
||||
denoFlags =
|
||||
denoFlags
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
{pkgs, ...}: {
|
||||
{
|
||||
pkgs,
|
||||
stdenv,
|
||||
deno2nix,
|
||||
...
|
||||
}: {
|
||||
name,
|
||||
version,
|
||||
src,
|
||||
|
@ -7,9 +12,9 @@
|
|||
importMap ? null,
|
||||
denoFlags ? [],
|
||||
}: let
|
||||
inherit (pkgs.callPackage ./utils.nix {}) mkDepsLink;
|
||||
inherit (deno2nix.internal) mkDepsLink;
|
||||
in
|
||||
pkgs.stdenv.mkDerivation {
|
||||
stdenv.mkDerivation {
|
||||
inherit src name entrypoint;
|
||||
denoFlags =
|
||||
denoFlags
|
||||
|
@ -21,10 +26,7 @@ in
|
|||
then ["--import-map" importMap]
|
||||
else []
|
||||
);
|
||||
buildInputs = with pkgs; [
|
||||
deno
|
||||
jq
|
||||
];
|
||||
buildInputs = with pkgs; [deno jq];
|
||||
fixupPhase = ":";
|
||||
|
||||
buildPhase = ''
|
||||
|
|
9
nix/overlay.nix
Normal file
9
nix/overlay.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
final: prev: {
|
||||
deno2nix = {
|
||||
mkBundled = final.callPackage ./make-bundled.nix {};
|
||||
mkBundledWrapper = final.callPackage ./make-bundled-wrapper.nix {};
|
||||
mkExecutable = final.callPackage ./make-executable.nix {};
|
||||
|
||||
internal = final.callPackage ./internal.nix {};
|
||||
};
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
{
|
||||
pkgs,
|
||||
lib ? pkgs.lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) hashString split elemAt fetchurl toJSON;
|
||||
inherit (pkgs) linkFarm writeText;
|
||||
inherit (lib) flatten mapAttrsToList importJSON;
|
||||
in rec {
|
||||
urlPart = url: elemAt (flatten (split "://([a-z0-9\.]*)" url));
|
||||
artifactPath = url: "${urlPart url 0}/${urlPart url 1}/${hashString "sha256" (urlPart url 2)}";
|
||||
mkDepsLink = lockfile: (
|
||||
linkFarm "deps" (lib.flatten (
|
||||
mapAttrsToList
|
||||
(
|
||||
url: sha256: [
|
||||
{
|
||||
name = artifactPath url;
|
||||
path = fetchurl {inherit url sha256;};
|
||||
}
|
||||
{
|
||||
name = (artifactPath url) + ".metadata.json";
|
||||
path = writeText "metadata.json" (toJSON {
|
||||
inherit url;
|
||||
headers = {};
|
||||
});
|
||||
}
|
||||
]
|
||||
)
|
||||
(importJSON lockfile)
|
||||
))
|
||||
);
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
final: prev: {
|
||||
deno2nix = {
|
||||
mkBundled = final.callPackage ./nix/make-bundled.nix {};
|
||||
mkBundledWrapper = final.callPackage ./nix/make-bundled-wrapper.nix {};
|
||||
mkExecutable = final.callPackage ./nix/make-executable.nix {};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue