initial commit

This commit is contained in:
Dmitriy Pleshevskiy 2022-11-25 00:13:47 +03:00
parent aa54944eb0
commit 50bb6b14a5
Signed by: pleshevskiy
GPG Key ID: 1B59187B161C0215
4 changed files with 124 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
# direnv
.direnv
.envrc
# nix builds
result

41
flake.lock Normal file
View File

@ -0,0 +1,41 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1669261230,
"narHash": "sha256-AjddxRPd5y5jge77281P3O8+Cnafj842Xg59rwV4x+0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8e8b5f3b1e899bf5d250279578c0283705b8cdb4",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

44
flake.nix Normal file
View File

@ -0,0 +1,44 @@
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }:
let
inherit (builtins) listToAttrs mapAttrs;
mkPackage = pkgs: name: pkgs.callPackage ./pkgs/${name}.nix { };
mkApp = drv: flake-utils.lib.mkApp { inherit drv; };
mkOverlay = name:
final: prev:
final.setAttrByPath [ name ] (mkPackage name prev);
allPackageNames = [ "d2" ];
mkAllPackages = pkgs':
listToAttrs
(map
(name: { inherit name; value = mkPackage pkgs' name; })
allPackageNames);
in
{
overlays = (listToAttrs
(map
(name: { inherit name; value = mkOverlay name; })
allPackageNames
)
) // {
all = final: prev: mkAllPackages prev;
};
}
// flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
packages = mkAllPackages pkgs;
in
{
check = packages;
inherit packages;
apps = mapAttrs (name: mkApp) packages;
});
}

33
pkgs/d2.nix Normal file
View File

@ -0,0 +1,33 @@
{ lib
, buildGoModule
, fetchFromGitHub
, installShellFiles
}:
let version = "0.0.13"; in
buildGoModule {
pname = "d2";
inherit version;
src = fetchFromGitHub {
owner = "terrastruct";
repo = "d2";
rev = "v${version}";
sha256 = "sha256-2abGQmgwqxWFk7NScdgfEjRYZF2rw8kxTKRwcl2LRg0=";
};
vendorSha256 = "sha256-/BEl4UqOL4Ux7I2eubNH2YGGl4DxntpI5WN9ggvYu80=";
ldflags = [
"-s"
"-w"
"-X oss.terrastruct.com/d2/lib/version.Version=${version}"
];
nativeBuildInputs = [ installShellFiles ];
postInstall = "installManPage ci/release/template/man/d2.1";
subPackages = [ "cmd/d2" ];
}