This commit is contained in:
Daniel Flanagan 2024-06-07 14:58:13 -05:00
parent e0a750e896
commit 624ebe7090
3 changed files with 64 additions and 5 deletions

View file

@ -1,6 +1,40 @@
{
"nodes": {
"deno2nix": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1717790032,
"narHash": "sha256-C5M/AxzDyz82YUZG5XDHOtR5cXhp8y4klp2u9v0tNl0=",
"owner": "lytedev",
"repo": "deno2nix",
"rev": "48201f514efeb113b0505824c5f5cfda786094de",
"type": "github"
},
"original": {
"owner": "lytedev",
"repo": "deno2nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1717602782,
"narHash": "sha256-pL9jeus5QpX5R+9rsp3hhZ+uplVHscNJh8n8VpqscM0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e8057b67ebf307f01bdcc8fba94d94f75039d1f6",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1717602782,
"narHash": "sha256-pL9jeus5QpX5R+9rsp3hhZ+uplVHscNJh8n8VpqscM0=",
@ -18,7 +52,8 @@
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
"deno2nix": "deno2nix",
"nixpkgs": "nixpkgs_2"
}
}
},

View file

@ -1,9 +1,11 @@
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.deno2nix.url = "github:lytedev/deno2nix";
outputs = {
self,
nixpkgs,
deno2nix,
}: let
inherit (self) outputs;
supportedSystems = [
@ -15,6 +17,30 @@
];
forEachSupportedSystem = nixpkgs.lib.genAttrs supportedSystems;
in {
packages = forEachSupportedSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [deno2nix.overlays.default];
};
in {
diagrammer = pkgs.deno2nix.mkExecutable {
pname = "diagrammer";
version = "1.0.0";
src = ./.;
bin = "diagrammer";
entrypoint = "./mod.ts";
lockfile = "./deno.lock";
config = "./deno.json";
allow = {
all = true;
};
};
default = outputs.packages.${system}.diagrammer;
});
devShells = forEachSupportedSystem (system: let
pkgs = import nixpkgs {inherit system;};
in {

6
mod.ts
View file

@ -1,12 +1,10 @@
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-net --allow-env --ext=ts
import { Command } from 'https://deno.land/x/cliffy@v1.0.0-rc.4/command/mod.ts'
import { z } from 'https://deno.land/x/zod@v3.23.8/mod.ts'
const sockets: Set<WebSocket> = new Set([])
const Args = z.object({
input: z.string().default('./src'),
input: z.string().default('./'),
open: z.boolean().default(false),
server: z.boolean().default(true),
host: z.string().default('localhost'),
@ -27,7 +25,7 @@ const command = new Command()
'-i, --input <input_directory:path>',
'The directory containing .mmd files to compile.',
{
default: './src',
default: './',
},
)
.option('--open', 'Include this flag to open your browser automatically.', {