add d2plugin-tala
This commit is contained in:
parent
f53eabdbf6
commit
95f061b96b
4 changed files with 162 additions and 26 deletions
78
README.md
78
README.md
|
@ -1,2 +1,80 @@
|
|||
# tools
|
||||
|
||||
This repository contains latest version of useful utilities with patches that
|
||||
not included in official repositories.
|
||||
|
||||
# Usage
|
||||
|
||||
## As package
|
||||
|
||||
```sh
|
||||
nix build git+https://git.pleshevski.ru/mynix/tools#<name>
|
||||
```
|
||||
|
||||
## As one-time executable application
|
||||
|
||||
```sh
|
||||
nix run git+https://git.pleshevski.ru/mynix/tools#<name>
|
||||
```
|
||||
|
||||
## Using nix-profile
|
||||
|
||||
```sh
|
||||
nix profile install git+https://git.pleshevski.ru/mynix/tools#<name>
|
||||
```
|
||||
|
||||
## As overlay for your flake
|
||||
|
||||
```
|
||||
{
|
||||
inputs.tools.url = "git+https://git.pleshevski.ru/mynix/tools";
|
||||
|
||||
outputs = { nixpkgs, tools }:
|
||||
let
|
||||
system = builtins.currentSystem;
|
||||
overlays = [ tools.overlays.all ];
|
||||
pkgs = import nixpkgs { inherit system overlays; };
|
||||
in
|
||||
{
|
||||
devShells = {
|
||||
default = pkgs.mkShell {
|
||||
# now you can use any tools
|
||||
packages = with pkgs; [ d2 ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
> **Note**: For short this url (`git+https://git.pleshevski.ru/mynix/tools`)
|
||||
will be truncated to `.` in the document.
|
||||
|
||||
|
||||
# d2
|
||||
|
||||
_D2 is a modern diagram scripting language that turns text to diagrams._
|
||||
|
||||
References:
|
||||
- [https://d2lang.com](https://d2lang.com)
|
||||
- [https://github.com/terrastruct/d2](https://github.com/terrastruct/d2)
|
||||
|
||||
**d2**: Base d2 cli tool
|
||||
|
||||
```
|
||||
nix run .#d2 -- --help
|
||||
```
|
||||
|
||||
**[UNFREE]** **d2full**: Full d2 cli tool with d2plugin-tala
|
||||
|
||||
```
|
||||
NIXPKGS_ALLOW_UNFREE=1 nix run --impure .#d2full -- --help
|
||||
```
|
||||
|
||||
**[UNFREE]** **d2plugin-tala**: A diagram layout engine designed specifically for software
|
||||
architecture diagrams
|
||||
|
||||
```
|
||||
NIXPKGS_ALLOW_UNFREE=1 nix run --impure .#d2full -- --help
|
||||
```
|
||||
|
||||
|
||||
|
|
13
flake.nix
13
flake.nix
|
@ -7,13 +7,17 @@
|
|||
let
|
||||
inherit (builtins) listToAttrs mapAttrs;
|
||||
|
||||
mkPackage = pkgs: name: pkgs.callPackage ./pkgs/${name}.nix { };
|
||||
mkPackage = pkgs': name:
|
||||
pkgs'.callPackage ./pkgs/${name}.nix (
|
||||
if name == "d2" then { d2plugin-tala = mkPackage pkgs' "d2plugin-tala"; }
|
||||
else { }
|
||||
);
|
||||
mkApp = drv: flake-utils.lib.mkApp { inherit drv; };
|
||||
mkOverlay = name:
|
||||
final: prev:
|
||||
final.setAttrByPath [ name ] (mkPackage name prev);
|
||||
|
||||
allPackageNames = [ "d2" ];
|
||||
allPackageNames = [ "d2" "d2plugin-tala" ];
|
||||
mkAllPackages = pkgs':
|
||||
listToAttrs
|
||||
(map
|
||||
|
@ -33,7 +37,10 @@
|
|||
// flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
packages = mkAllPackages pkgs;
|
||||
basePackages = mkAllPackages pkgs;
|
||||
packages = with basePackages; {
|
||||
d2full = d2.override { withTala = true; };
|
||||
} // basePackages;
|
||||
in
|
||||
{
|
||||
check = packages;
|
||||
|
|
21
pkgs/d2.nix
21
pkgs/d2.nix
|
@ -1,12 +1,17 @@
|
|||
{ lib
|
||||
, buildGoModule
|
||||
, makeWrapper
|
||||
, symlinkJoin
|
||||
, fetchFromGitHub
|
||||
, installShellFiles
|
||||
, d2plugin-tala
|
||||
, withTala ? false
|
||||
}:
|
||||
|
||||
let version = "2022-12-12"; in
|
||||
|
||||
buildGoModule {
|
||||
let
|
||||
version = "2022-12-12";
|
||||
d2 = buildGoModule
|
||||
{
|
||||
pname = "d2";
|
||||
inherit version;
|
||||
|
||||
|
@ -34,4 +39,14 @@ buildGoModule {
|
|||
postInstall = "installManPage ci/release/template/man/d2.1";
|
||||
|
||||
subPackages = [ "." ];
|
||||
};
|
||||
in
|
||||
symlinkJoin {
|
||||
name = "d2";
|
||||
paths = [ d2 ] ++ lib.optional withTala [ d2plugin-tala ];
|
||||
buildInputs = [ makeWrapper ];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/d2 \
|
||||
--prefix PATH : "$out/bin"
|
||||
'';
|
||||
}
|
||||
|
|
36
pkgs/d2plugin-tala.nix
Normal file
36
pkgs/d2plugin-tala.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ system, stdenv, lib, fetchurl, installShellFiles }:
|
||||
|
||||
let
|
||||
platform = if stdenv.isLinux then "linux" else "darwin";
|
||||
arch = if lib.hasPrefix "x86_" system then "amd64" else "arm64";
|
||||
version = "0.2.7";
|
||||
fileName = "tala-v${version}-${platform}-${arch}.tar.gz";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "d2plugin-tala";
|
||||
inherit version;
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/terrastruct/TALA/releases/download/v${version}/${fileName}";
|
||||
sha256 = "sha256-p6nXOcveZ28Q1ODpbV9dVrGTtoXgxkFdsiXY61BK0dA=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ installShellFiles ];
|
||||
|
||||
phases = [ "unpackPhase" "installPhase" ];
|
||||
|
||||
unpackPhase = "tar --strip-component=1 -xf $src";
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp bin/d2plugin-tala $out/bin
|
||||
installManPage man/d2plugin-tala.1
|
||||
installManPage man/tala.1
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "A diagram layout engine designed specifically for software architecture diagrams";
|
||||
homepage = "https://terrastruct.com/tala";
|
||||
license = licenses.unfree;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue