refac structure
This commit is contained in:
parent
95f061b96b
commit
0469fc1fba
6 changed files with 69 additions and 69 deletions
33
flake.nix
33
flake.nix
|
@ -7,22 +7,24 @@
|
|||
let
|
||||
inherit (builtins) listToAttrs mapAttrs;
|
||||
|
||||
mkPackage = pkgs': name:
|
||||
pkgs'.callPackage ./pkgs/${name}.nix (
|
||||
if name == "d2" then { d2plugin-tala = mkPackage pkgs' "d2plugin-tala"; }
|
||||
else { }
|
||||
);
|
||||
allPackageNames = [ "d2" "d2plugin-tala" "d2full" ];
|
||||
mkAllPackages = pkgs':
|
||||
let
|
||||
d2-unwrapped = pkgs'.callPackage ./pkgs/d2/d2-unwrapped.nix { };
|
||||
d2plugin-tala = pkgs'.callPackage ./pkgs/d2/d2plugin-tala.nix { };
|
||||
d2 = pkgs'.callPackage ./pkgs/d2 {
|
||||
inherit d2-unwrapped d2plugin-tala;
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit d2 d2plugin-tala;
|
||||
d2full = d2.override { withTala = true; };
|
||||
};
|
||||
|
||||
mkApp = drv: flake-utils.lib.mkApp { inherit drv; };
|
||||
mkOverlay = name:
|
||||
final: prev:
|
||||
final.setAttrByPath [ name ] (mkPackage name prev);
|
||||
|
||||
allPackageNames = [ "d2" "d2plugin-tala" ];
|
||||
mkAllPackages = pkgs':
|
||||
listToAttrs
|
||||
(map
|
||||
(name: { inherit name; value = mkPackage pkgs' name; })
|
||||
allPackageNames);
|
||||
final.filterAttrs (n: v: n == name) (mkAllPackages prev);
|
||||
in
|
||||
{
|
||||
overlays = (listToAttrs
|
||||
|
@ -37,10 +39,7 @@
|
|||
// flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
basePackages = mkAllPackages pkgs;
|
||||
packages = with basePackages; {
|
||||
d2full = d2.override { withTala = true; };
|
||||
} // basePackages;
|
||||
packages = mkAllPackages pkgs;
|
||||
in
|
||||
{
|
||||
check = packages;
|
||||
|
|
52
pkgs/d2.nix
52
pkgs/d2.nix
|
@ -1,52 +0,0 @@
|
|||
{ lib
|
||||
, buildGoModule
|
||||
, makeWrapper
|
||||
, symlinkJoin
|
||||
, fetchFromGitHub
|
||||
, installShellFiles
|
||||
, d2plugin-tala
|
||||
, withTala ? false
|
||||
}:
|
||||
|
||||
let
|
||||
version = "2022-12-12";
|
||||
d2 = buildGoModule
|
||||
{
|
||||
pname = "d2";
|
||||
inherit version;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "terrastruct";
|
||||
repo = "d2";
|
||||
rev = "a557d1a6edeb18d692c1e1c20c3c0f0cffc2ed21";
|
||||
sha256 = "sha256-EzaBURGLnxSX+1FjYQLP7oxov7dGk7xhAnpV8DPzW/g=";
|
||||
};
|
||||
|
||||
vendorSha256 = "sha256-p0os+ap2k5nYWI4+Hf4pwJfHTXaPJldJmf6nznhuRFA=";
|
||||
|
||||
ldflags = [
|
||||
"-s"
|
||||
"-w"
|
||||
"-X oss.terrastruct.com/d2/lib/version.Version=${version}"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ installShellFiles ];
|
||||
|
||||
patches = [
|
||||
../patches/d2/402_preserve_leading_comment_spacing.patch
|
||||
];
|
||||
|
||||
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/d2/d2-unwrapped.nix
Normal file
36
pkgs/d2/d2-unwrapped.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ lib
|
||||
, buildGoModule
|
||||
, fetchFromGitHub
|
||||
, installShellFiles
|
||||
}:
|
||||
|
||||
let version = "2022-12-12"; in
|
||||
buildGoModule {
|
||||
pname = "d2";
|
||||
inherit version;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "terrastruct";
|
||||
repo = "d2";
|
||||
rev = "a557d1a6edeb18d692c1e1c20c3c0f0cffc2ed21";
|
||||
sha256 = "sha256-EzaBURGLnxSX+1FjYQLP7oxov7dGk7xhAnpV8DPzW/g=";
|
||||
};
|
||||
|
||||
vendorSha256 = "sha256-p0os+ap2k5nYWI4+Hf4pwJfHTXaPJldJmf6nznhuRFA=";
|
||||
|
||||
ldflags = [
|
||||
"-s"
|
||||
"-w"
|
||||
"-X oss.terrastruct.com/d2/lib/version.Version=${version}"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ installShellFiles ];
|
||||
|
||||
patches = [
|
||||
./patches/402_preserve_leading_comment_spacing.patch
|
||||
];
|
||||
|
||||
postInstall = "installManPage ci/release/template/man/d2.1";
|
||||
|
||||
subPackages = [ "." ];
|
||||
}
|
17
pkgs/d2/default.nix
Normal file
17
pkgs/d2/default.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ lib
|
||||
, makeWrapper
|
||||
, symlinkJoin
|
||||
, d2-unwrapped
|
||||
, d2plugin-tala
|
||||
, withTala ? false
|
||||
}:
|
||||
|
||||
symlinkJoin {
|
||||
name = "d2";
|
||||
paths = [ d2-unwrapped ] ++ lib.optional withTala [ d2plugin-tala ];
|
||||
buildInputs = [ makeWrapper ];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/d2 \
|
||||
--prefix PATH : "$out/bin"
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue