mirror of
https://github.com/ilyakooo0/sawtooth-haskell-protos.git
synced 2024-08-15 17:40:31 +03:00
Initial commit
This commit is contained in:
commit
277a5a97af
31
.github/workflows/build_docs.yaml
vendored
Normal file
31
.github/workflows/build_docs.yaml
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
name: Package sources
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
linux:
|
||||||
|
name: Package sources
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- uses: cachix/install-nix-action@v12
|
||||||
|
- name: Build
|
||||||
|
id: build
|
||||||
|
run: |
|
||||||
|
nix-build
|
||||||
|
# echo "::set-output name=result::$(realpath result)"
|
||||||
|
tar cvzf sawtooth-haskell-protos-src.tar.gz $(realpath result)
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: docs
|
||||||
|
path: sawtooth-haskell-protos-src.tar.gz
|
||||||
|
- uses: "marvinpinto/action-automatic-releases@latest"
|
||||||
|
with:
|
||||||
|
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
automatic_release_tag: "latest"
|
||||||
|
# prerelease: true
|
||||||
|
# title: ""
|
||||||
|
files: |
|
||||||
|
sawtooth-haskell-protos-src.tar.gz
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
result
|
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Sawtooth Haskell Protobuf
|
||||||
|
|
||||||
|
Auto-generated Haskell package with [Hyperledger Sawtooth](https://github.com/hyperledger/sawtooth-core) protobuf API strcutures.
|
81
default.nix
Normal file
81
default.nix
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
{ sources ? import nix/sources.nix
|
||||||
|
, nixpkgs ? import sources.nixpkgs { }
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
proto3-suite = import sources.proto3-suite { };
|
||||||
|
sawtooth-haskell-protos-src = nixpkgs.stdenv.mkDerivation {
|
||||||
|
name = "sawtooth-haskell-protos-src";
|
||||||
|
buildInputs = [ proto3-suite.proto3-suite ];
|
||||||
|
src = sources.sawtooth-core + "/protos";
|
||||||
|
buildPhase = ''
|
||||||
|
for f in *.proto
|
||||||
|
do
|
||||||
|
sed -i -e "/syntax = \"proto3\";/a package $(basename $f .proto);" -e 's/import "/import "data\/sawtooth\//' $f
|
||||||
|
done
|
||||||
|
|
||||||
|
mkdir -p data/sawtooth
|
||||||
|
mv *.proto data/sawtooth
|
||||||
|
|
||||||
|
for f in data/sawtooth/**.proto
|
||||||
|
do
|
||||||
|
compile-proto-file --includeDir data/sawtooth --includeDir $(pwd) --proto $f --out out/src
|
||||||
|
done
|
||||||
|
|
||||||
|
cp ${./package.yaml} out/package.yaml
|
||||||
|
'';
|
||||||
|
installPhase = ''
|
||||||
|
mkdir $out
|
||||||
|
cp -a out/. $out/
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
sawtooth-haskell-protos =
|
||||||
|
nixpkgs.haskellPackages.callCabal2nix "sawtooth-haskell-protos" sawtooth-haskell-protos-src { };
|
||||||
|
sawtooth-haskell-protos-overlay = hself: hsuper: {
|
||||||
|
sawtooth-haskell-protos = hsuper.callCabal2nix "sawtooth-haskell-protos" sawtooth-haskell-protos-src { };
|
||||||
|
haskell-src = hsuper.callHackageDirect
|
||||||
|
{
|
||||||
|
pkg = "haskell-src";
|
||||||
|
ver = "1.0.3.1";
|
||||||
|
sha256 = "11s2qnnhchcbi6szvcglv4xxz3l6zw9w3pziycpwrigjvpigymd2";
|
||||||
|
} { };
|
||||||
|
insert-ordered-containers = hsuper.callHackageDirect
|
||||||
|
{
|
||||||
|
pkg = "insert-ordered-containers";
|
||||||
|
ver = "0.2.3.1";
|
||||||
|
sha256 = "0zxxjwzcsyc7a572f584w83aqygdc3q05pfarghj2v437nsnap29";
|
||||||
|
} { };
|
||||||
|
swagger2 = hsuper.callHackageDirect
|
||||||
|
{
|
||||||
|
pkg = "swagger2";
|
||||||
|
ver = "2.6";
|
||||||
|
sha256 = "0x0s34q9bmrik0vmzpc08r4jq5kbpb8x7h19ixhaakiafpjfm59l";
|
||||||
|
} { };
|
||||||
|
proto3-suite = nixpkgs.haskell.lib.dontCheck (hsuper.callHackageDirect
|
||||||
|
{
|
||||||
|
pkg = "proto3-suite";
|
||||||
|
ver = "0.4.0.2";
|
||||||
|
sha256 = "11bppmb524q6qvgyddi9s7pf1n1zs4ypqkqs2qb6i8nsgmxndd1l";
|
||||||
|
} { }
|
||||||
|
);
|
||||||
|
proto3-wire = hsuper.callHackageDirect
|
||||||
|
{
|
||||||
|
pkg = "proto3-wire";
|
||||||
|
ver = "1.2.0";
|
||||||
|
sha256 = "1jqz6zsli5zvlissy7mkgyrzkapjvgijx7kjva4fxjwdyd0hqix7";
|
||||||
|
} { };
|
||||||
|
http-media = nixpkgs.haskell.lib.doJailbreak (hsuper.callHackageDirect
|
||||||
|
{
|
||||||
|
pkg = "http-media";
|
||||||
|
ver = "0.8.0.0";
|
||||||
|
sha256 = "080xkljq1iq0i8wagg8kbzbp523p2awa98wpn9i4ph1dq8y8346y";
|
||||||
|
} { }
|
||||||
|
);
|
||||||
|
parameterized = nixpkgs.haskell.lib.dontCheck hsuper.parameterized;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit sawtooth-haskell-protos-src sawtooth-haskell-protos-overlay;
|
||||||
|
build = (nixpkgs.haskell.packages.ghc882.override {
|
||||||
|
overrides = sawtooth-haskell-protos-overlay;
|
||||||
|
}).sawtooth-haskell-protos;
|
||||||
|
}
|
50
nix/sources.json
Normal file
50
nix/sources.json
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"niv": {
|
||||||
|
"branch": "master",
|
||||||
|
"description": "Easy dependency management for Nix projects",
|
||||||
|
"homepage": "https://github.com/nmattia/niv",
|
||||||
|
"owner": "nmattia",
|
||||||
|
"repo": "niv",
|
||||||
|
"rev": "ba57d5a29b4e0f2085917010380ef3ddc3cf380f",
|
||||||
|
"sha256": "1kpsvc53x821cmjg1khvp1nz7906gczq8mp83664cr15h94sh8i4",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/nmattia/niv/archive/ba57d5a29b4e0f2085917010380ef3ddc3cf380f.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"branch": "release-20.03",
|
||||||
|
"description": "Nix Packages collection",
|
||||||
|
"homepage": "",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "5a9e4f07f714e811bded0a45ed8fe55c5c6048fd",
|
||||||
|
"sha256": "09s7h5qq866awkxz2l33b7x7lqmsm4xxzaqxlybj5bkdfxws2lb6",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/NixOS/nixpkgs/archive/5a9e4f07f714e811bded0a45ed8fe55c5c6048fd.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
},
|
||||||
|
"proto3-suite": {
|
||||||
|
"branch": "master",
|
||||||
|
"description": " Haskell Protobuf Implementation",
|
||||||
|
"homepage": null,
|
||||||
|
"owner": "awakesecurity",
|
||||||
|
"repo": "proto3-suite",
|
||||||
|
"rev": "0af901f9ef3b9719e08eae4fab8fd700d6c8047a",
|
||||||
|
"sha256": "0mpy35r6qd1v5sixhy2lqcn5x81rfj4dc079g1kpa4fb1f23dbha",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/awakesecurity/proto3-suite/archive/0af901f9ef3b9719e08eae4fab8fd700d6c8047a.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
},
|
||||||
|
"sawtooth-core": {
|
||||||
|
"branch": "master",
|
||||||
|
"description": "Core repository for Sawtooth Distributed Ledger",
|
||||||
|
"homepage": "https://wiki.hyperledger.org/display/sawtooth",
|
||||||
|
"owner": "hyperledger",
|
||||||
|
"repo": "sawtooth-core",
|
||||||
|
"rev": "be283f9cc4cbe53f8eed3b66b00a7fcffe58804f",
|
||||||
|
"sha256": "1d01jmaykyg0gii1q26i4g4bhl8k8g542aas0lgcj5qlipjfk7ha",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/hyperledger/sawtooth-core/archive/be283f9cc4cbe53f8eed3b66b00a7fcffe58804f.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
}
|
||||||
|
}
|
171
nix/sources.nix
Normal file
171
nix/sources.nix
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
# This file has been generated by Niv.
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
#
|
||||||
|
# The fetchers. fetch_<type> fetches specs of type <type>.
|
||||||
|
#
|
||||||
|
|
||||||
|
fetch_file = pkgs: name: spec:
|
||||||
|
let
|
||||||
|
name' = sanitizeName name + "-src";
|
||||||
|
in
|
||||||
|
if spec.builtin or true then
|
||||||
|
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
|
||||||
|
else
|
||||||
|
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
|
||||||
|
|
||||||
|
fetch_tarball = pkgs: name: spec:
|
||||||
|
let
|
||||||
|
name' = sanitizeName name + "-src";
|
||||||
|
in
|
||||||
|
if spec.builtin or true then
|
||||||
|
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
|
||||||
|
else
|
||||||
|
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
|
||||||
|
|
||||||
|
fetch_git = name: spec:
|
||||||
|
let
|
||||||
|
ref =
|
||||||
|
if spec ? ref then spec.ref else
|
||||||
|
if spec ? branch then "refs/heads/${spec.branch}" else
|
||||||
|
if spec ? tag then "refs/tags/${spec.tag}" else
|
||||||
|
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
|
||||||
|
in
|
||||||
|
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
|
||||||
|
|
||||||
|
fetch_local = spec: spec.path;
|
||||||
|
|
||||||
|
fetch_builtin-tarball = name: throw
|
||||||
|
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
|
||||||
|
$ niv modify ${name} -a type=tarball -a builtin=true'';
|
||||||
|
|
||||||
|
fetch_builtin-url = name: throw
|
||||||
|
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
|
||||||
|
$ niv modify ${name} -a type=file -a builtin=true'';
|
||||||
|
|
||||||
|
#
|
||||||
|
# Various helpers
|
||||||
|
#
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
|
||||||
|
sanitizeName = name:
|
||||||
|
(
|
||||||
|
concatMapStrings (s: if builtins.isList s then "-" else s)
|
||||||
|
(
|
||||||
|
builtins.split "[^[:alnum:]+._?=-]+"
|
||||||
|
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
# The set of packages used when specs are fetched using non-builtins.
|
||||||
|
mkPkgs = sources: system:
|
||||||
|
let
|
||||||
|
sourcesNixpkgs =
|
||||||
|
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
|
||||||
|
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
||||||
|
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
||||||
|
in
|
||||||
|
if builtins.hasAttr "nixpkgs" sources
|
||||||
|
then sourcesNixpkgs
|
||||||
|
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
|
||||||
|
import <nixpkgs> {}
|
||||||
|
else
|
||||||
|
abort
|
||||||
|
''
|
||||||
|
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
||||||
|
add a package called "nixpkgs" to your sources.json.
|
||||||
|
'';
|
||||||
|
|
||||||
|
# The actual fetching function.
|
||||||
|
fetch = pkgs: name: spec:
|
||||||
|
|
||||||
|
if ! builtins.hasAttr "type" spec then
|
||||||
|
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
||||||
|
else if spec.type == "file" then fetch_file pkgs name spec
|
||||||
|
else if spec.type == "tarball" then fetch_tarball pkgs name spec
|
||||||
|
else if spec.type == "git" then fetch_git name spec
|
||||||
|
else if spec.type == "local" then fetch_local spec
|
||||||
|
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
|
||||||
|
else if spec.type == "builtin-url" then fetch_builtin-url name
|
||||||
|
else
|
||||||
|
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
||||||
|
|
||||||
|
# If the environment variable NIV_OVERRIDE_${name} is set, then use
|
||||||
|
# the path directly as opposed to the fetched source.
|
||||||
|
replace = name: drv:
|
||||||
|
let
|
||||||
|
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
|
||||||
|
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
|
||||||
|
in
|
||||||
|
if ersatz == "" then drv else ersatz;
|
||||||
|
|
||||||
|
# Ports of functions for older nix versions
|
||||||
|
|
||||||
|
# a Nix version of mapAttrs if the built-in doesn't exist
|
||||||
|
mapAttrs = builtins.mapAttrs or (
|
||||||
|
f: set: with builtins;
|
||||||
|
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
|
||||||
|
);
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
|
||||||
|
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
|
||||||
|
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
||||||
|
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
||||||
|
concatMapStrings = f: list: concatStrings (map f list);
|
||||||
|
concatStrings = builtins.concatStringsSep "";
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
|
||||||
|
optionalAttrs = cond: as: if cond then as else {};
|
||||||
|
|
||||||
|
# fetchTarball version that is compatible between all the versions of Nix
|
||||||
|
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
|
||||||
|
let
|
||||||
|
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||||
|
in
|
||||||
|
if lessThan nixVersion "1.12" then
|
||||||
|
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
||||||
|
else
|
||||||
|
fetchTarball attrs;
|
||||||
|
|
||||||
|
# fetchurl version that is compatible between all the versions of Nix
|
||||||
|
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
|
||||||
|
let
|
||||||
|
inherit (builtins) lessThan nixVersion fetchurl;
|
||||||
|
in
|
||||||
|
if lessThan nixVersion "1.12" then
|
||||||
|
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
||||||
|
else
|
||||||
|
fetchurl attrs;
|
||||||
|
|
||||||
|
# Create the final "sources" from the config
|
||||||
|
mkSources = config:
|
||||||
|
mapAttrs (
|
||||||
|
name: spec:
|
||||||
|
if builtins.hasAttr "outPath" spec
|
||||||
|
then abort
|
||||||
|
"The values in sources.json should not have an 'outPath' attribute"
|
||||||
|
else
|
||||||
|
spec // { outPath = replace name (fetch config.pkgs name spec); }
|
||||||
|
) config.sources;
|
||||||
|
|
||||||
|
# The "config" used by the fetchers
|
||||||
|
mkConfig =
|
||||||
|
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
|
||||||
|
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
|
||||||
|
, system ? builtins.currentSystem
|
||||||
|
, pkgs ? mkPkgs sources system
|
||||||
|
}: rec {
|
||||||
|
# The sources, i.e. the attribute set of spec name to spec
|
||||||
|
inherit sources;
|
||||||
|
|
||||||
|
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
||||||
|
inherit pkgs;
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
|
15
package.yaml
Normal file
15
package.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
name: sawtooth-haskell-protos
|
||||||
|
synopsis: An autogenerated module with Hyperledger Sawtooth protobuf types
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- base
|
||||||
|
- vector
|
||||||
|
- text
|
||||||
|
- deepseq
|
||||||
|
- bytestring
|
||||||
|
- proto3-suite
|
||||||
|
- containers
|
||||||
|
- proto3-wire
|
||||||
|
|
||||||
|
library:
|
||||||
|
source-dirs: src
|
Loading…
Reference in New Issue
Block a user