git.iko.soy/sawtooth-haskell-protos
on master help sign in
Initial commit
commit277a5a97af76063f878c413a84574fe60fbffb48 authoriko <ilyakooo0@gmail.com> dateWed 25 Nov 2020, 15:37 (6 years ago)
7 files changed+352
.github/workflows/build_docs.yaml+31 .gitignore+1 README.md+3 default.nix+81 nix/sources.json+50 nix/sources.nix+171 package.yaml+15
.github/workflows/build_docs.yamlnew file+31
@@ -0,0 +1,31 @@
1+name: Package sources
2+on:
3+ push:
4+ branches:
5+ - master
6+
7+jobs:
8+ linux:
9+ name: Package sources
10+ runs-on: ubuntu-latest
11+ steps:
12+ - uses: actions/checkout@v1
13+ - uses: cachix/install-nix-action@v12
14+ - name: Build
15+ id: build
16+ run: |
17+ nix-build
18+ # echo "::set-output name=result::$(realpath result)"
19+ tar cvzf sawtooth-haskell-protos-src.tar.gz $(realpath result)
20+ - uses: actions/upload-artifact@v2
21+ with:
22+ name: docs
23+ path: sawtooth-haskell-protos-src.tar.gz
24+ - uses: "marvinpinto/action-automatic-releases@latest"
25+ with:
26+ repo_token: "${{ secrets.GITHUB_TOKEN }}"
27+ automatic_release_tag: "latest"
28+ # prerelease: true
29+ # title: ""
30+ files: |
31+ sawtooth-haskell-protos-src.tar.gz
.gitignorenew file+1
@@ -0,0 +1 @@
1+result
README.mdnew file+3
@@ -0,0 +1,3 @@
1+# Sawtooth Haskell Protobuf
2+
3+Auto-generated Haskell package with [Hyperledger Sawtooth](https://github.com/hyperledger/sawtooth-core) protobuf API strcutures.
default.nixnew file+81
@@ -0,0 +1,81 @@
1+{ sources ? import nix/sources.nix
2+, nixpkgs ? import sources.nixpkgs { }
3+}:
4+let
5+ proto3-suite = import sources.proto3-suite { };
6+ sawtooth-haskell-protos-src = nixpkgs.stdenv.mkDerivation {
7+ name = "sawtooth-haskell-protos-src";
8+ buildInputs = [ proto3-suite.proto3-suite ];
9+ src = sources.sawtooth-core + "/protos";
10+ buildPhase = ''
11+ for f in *.proto
12+ do
13+ sed -i -e "/syntax = \"proto3\";/a package $(basename $f .proto);" -e 's/import "/import "data\/sawtooth\//' $f
14+ done
15+
16+ mkdir -p data/sawtooth
17+ mv *.proto data/sawtooth
18+
19+ for f in data/sawtooth/**.proto
20+ do
21+ compile-proto-file --includeDir data/sawtooth --includeDir $(pwd) --proto $f --out out/src
22+ done
23+
24+ cp ${./package.yaml} out/package.yaml
25+ '';
26+ installPhase = ''
27+ mkdir $out
28+ cp -a out/. $out/
29+ '';
30+ };
31+ sawtooth-haskell-protos =
32+ nixpkgs.haskellPackages.callCabal2nix "sawtooth-haskell-protos" sawtooth-haskell-protos-src { };
33+ sawtooth-haskell-protos-overlay = hself: hsuper: {
34+ sawtooth-haskell-protos = hsuper.callCabal2nix "sawtooth-haskell-protos" sawtooth-haskell-protos-src { };
35+ haskell-src = hsuper.callHackageDirect
36+ {
37+ pkg = "haskell-src";
38+ ver = "1.0.3.1";
39+ sha256 = "11s2qnnhchcbi6szvcglv4xxz3l6zw9w3pziycpwrigjvpigymd2";
40+ } { };
41+ insert-ordered-containers = hsuper.callHackageDirect
42+ {
43+ pkg = "insert-ordered-containers";
44+ ver = "0.2.3.1";
45+ sha256 = "0zxxjwzcsyc7a572f584w83aqygdc3q05pfarghj2v437nsnap29";
46+ } { };
47+ swagger2 = hsuper.callHackageDirect
48+ {
49+ pkg = "swagger2";
50+ ver = "2.6";
51+ sha256 = "0x0s34q9bmrik0vmzpc08r4jq5kbpb8x7h19ixhaakiafpjfm59l";
52+ } { };
53+ proto3-suite = nixpkgs.haskell.lib.dontCheck (hsuper.callHackageDirect
54+ {
55+ pkg = "proto3-suite";
56+ ver = "0.4.0.2";
57+ sha256 = "11bppmb524q6qvgyddi9s7pf1n1zs4ypqkqs2qb6i8nsgmxndd1l";
58+ } { }
59+ );
60+ proto3-wire = hsuper.callHackageDirect
61+ {
62+ pkg = "proto3-wire";
63+ ver = "1.2.0";
64+ sha256 = "1jqz6zsli5zvlissy7mkgyrzkapjvgijx7kjva4fxjwdyd0hqix7";
65+ } { };
66+ http-media = nixpkgs.haskell.lib.doJailbreak (hsuper.callHackageDirect
67+ {
68+ pkg = "http-media";
69+ ver = "0.8.0.0";
70+ sha256 = "080xkljq1iq0i8wagg8kbzbp523p2awa98wpn9i4ph1dq8y8346y";
71+ } { }
72+ );
73+ parameterized = nixpkgs.haskell.lib.dontCheck hsuper.parameterized;
74+ };
75+in
76+{
77+ inherit sawtooth-haskell-protos-src sawtooth-haskell-protos-overlay;
78+ build = (nixpkgs.haskell.packages.ghc882.override {
79+ overrides = sawtooth-haskell-protos-overlay;
80+ }).sawtooth-haskell-protos;
81+}
nix/sources.jsonnew file+50
@@ -0,0 +1,50 @@
1+{
2+ "niv": {
3+ "branch": "master",
4+ "description": "Easy dependency management for Nix projects",
5+ "homepage": "https://github.com/nmattia/niv",
6+ "owner": "nmattia",
7+ "repo": "niv",
8+ "rev": "ba57d5a29b4e0f2085917010380ef3ddc3cf380f",
9+ "sha256": "1kpsvc53x821cmjg1khvp1nz7906gczq8mp83664cr15h94sh8i4",
10+ "type": "tarball",
11+ "url": "https://github.com/nmattia/niv/archive/ba57d5a29b4e0f2085917010380ef3ddc3cf380f.tar.gz",
12+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13+ },
14+ "nixpkgs": {
15+ "branch": "release-20.03",
16+ "description": "Nix Packages collection",
17+ "homepage": "",
18+ "owner": "NixOS",
19+ "repo": "nixpkgs",
20+ "rev": "5a9e4f07f714e811bded0a45ed8fe55c5c6048fd",
21+ "sha256": "09s7h5qq866awkxz2l33b7x7lqmsm4xxzaqxlybj5bkdfxws2lb6",
22+ "type": "tarball",
23+ "url": "https://github.com/NixOS/nixpkgs/archive/5a9e4f07f714e811bded0a45ed8fe55c5c6048fd.tar.gz",
24+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
25+ },
26+ "proto3-suite": {
27+ "branch": "master",
28+ "description": " Haskell Protobuf Implementation",
29+ "homepage": null,
30+ "owner": "awakesecurity",
31+ "repo": "proto3-suite",
32+ "rev": "0af901f9ef3b9719e08eae4fab8fd700d6c8047a",
33+ "sha256": "0mpy35r6qd1v5sixhy2lqcn5x81rfj4dc079g1kpa4fb1f23dbha",
34+ "type": "tarball",
35+ "url": "https://github.com/awakesecurity/proto3-suite/archive/0af901f9ef3b9719e08eae4fab8fd700d6c8047a.tar.gz",
36+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
37+ },
38+ "sawtooth-core": {
39+ "branch": "master",
40+ "description": "Core repository for Sawtooth Distributed Ledger",
41+ "homepage": "https://wiki.hyperledger.org/display/sawtooth",
42+ "owner": "hyperledger",
43+ "repo": "sawtooth-core",
44+ "rev": "be283f9cc4cbe53f8eed3b66b00a7fcffe58804f",
45+ "sha256": "1d01jmaykyg0gii1q26i4g4bhl8k8g542aas0lgcj5qlipjfk7ha",
46+ "type": "tarball",
47+ "url": "https://github.com/hyperledger/sawtooth-core/archive/be283f9cc4cbe53f8eed3b66b00a7fcffe58804f.tar.gz",
48+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
49+ }
50+}
nix/sources.nixnew file+171
@@ -0,0 +1,171 @@
1+# This file has been generated by Niv.
2+
3+let
4+
5+ #
6+ # The fetchers. fetch_<type> fetches specs of type <type>.
7+ #
8+
9+ fetch_file = pkgs: name: spec:
10+ let
11+ name' = sanitizeName name + "-src";
12+ in
13+ if spec.builtin or true then
14+ builtins_fetchurl { inherit (spec) url sha256; name = name'; }
15+ else
16+ pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
17+
18+ fetch_tarball = pkgs: name: spec:
19+ let
20+ name' = sanitizeName name + "-src";
21+ in
22+ if spec.builtin or true then
23+ builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
24+ else
25+ pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
26+
27+ fetch_git = name: spec:
28+ let
29+ ref =
30+ if spec ? ref then spec.ref else
31+ if spec ? branch then "refs/heads/${spec.branch}" else
32+ if spec ? tag then "refs/tags/${spec.tag}" else
33+ abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
34+ in
35+ builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
36+
37+ fetch_local = spec: spec.path;
38+
39+ fetch_builtin-tarball = name: throw
40+ ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
41+ $ niv modify ${name} -a type=tarball -a builtin=true'';
42+
43+ fetch_builtin-url = name: throw
44+ ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
45+ $ niv modify ${name} -a type=file -a builtin=true'';
46+
47+ #
48+ # Various helpers
49+ #
50+
51+ # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
52+ sanitizeName = name:
53+ (
54+ concatMapStrings (s: if builtins.isList s then "-" else s)
55+ (
56+ builtins.split "[^[:alnum:]+._?=-]+"
57+ ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
58+ )
59+ );
60+
61+ # The set of packages used when specs are fetched using non-builtins.
62+ mkPkgs = sources: system:
63+ let
64+ sourcesNixpkgs =
65+ import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
66+ hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
67+ hasThisAsNixpkgsPath = <nixpkgs> == ./.;
68+ in
69+ if builtins.hasAttr "nixpkgs" sources
70+ then sourcesNixpkgs
71+ else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
72+ import <nixpkgs> {}
73+ else
74+ abort
75+ ''
76+ Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
77+ add a package called "nixpkgs" to your sources.json.
78+ '';
79+
80+ # The actual fetching function.
81+ fetch = pkgs: name: spec:
82+
83+ if ! builtins.hasAttr "type" spec then
84+ abort "ERROR: niv spec ${name} does not have a 'type' attribute"
85+ else if spec.type == "file" then fetch_file pkgs name spec
86+ else if spec.type == "tarball" then fetch_tarball pkgs name spec
87+ else if spec.type == "git" then fetch_git name spec
88+ else if spec.type == "local" then fetch_local spec
89+ else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
90+ else if spec.type == "builtin-url" then fetch_builtin-url name
91+ else
92+ abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
93+
94+ # If the environment variable NIV_OVERRIDE_${name} is set, then use
95+ # the path directly as opposed to the fetched source.
96+ replace = name: drv:
97+ let
98+ saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
99+ ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
100+ in
101+ if ersatz == "" then drv else ersatz;
102+
103+ # Ports of functions for older nix versions
104+
105+ # a Nix version of mapAttrs if the built-in doesn't exist
106+ mapAttrs = builtins.mapAttrs or (
107+ f: set: with builtins;
108+ listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
109+ );
110+
111+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
112+ range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
113+
114+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
115+ stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
116+
117+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
118+ stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
119+ concatMapStrings = f: list: concatStrings (map f list);
120+ concatStrings = builtins.concatStringsSep "";
121+
122+ # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
123+ optionalAttrs = cond: as: if cond then as else {};
124+
125+ # fetchTarball version that is compatible between all the versions of Nix
126+ builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
127+ let
128+ inherit (builtins) lessThan nixVersion fetchTarball;
129+ in
130+ if lessThan nixVersion "1.12" then
131+ fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
132+ else
133+ fetchTarball attrs;
134+
135+ # fetchurl version that is compatible between all the versions of Nix
136+ builtins_fetchurl = { url, name ? null, sha256 }@attrs:
137+ let
138+ inherit (builtins) lessThan nixVersion fetchurl;
139+ in
140+ if lessThan nixVersion "1.12" then
141+ fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
142+ else
143+ fetchurl attrs;
144+
145+ # Create the final "sources" from the config
146+ mkSources = config:
147+ mapAttrs (
148+ name: spec:
149+ if builtins.hasAttr "outPath" spec
150+ then abort
151+ "The values in sources.json should not have an 'outPath' attribute"
152+ else
153+ spec // { outPath = replace name (fetch config.pkgs name spec); }
154+ ) config.sources;
155+
156+ # The "config" used by the fetchers
157+ mkConfig =
158+ { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
159+ , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
160+ , system ? builtins.currentSystem
161+ , pkgs ? mkPkgs sources system
162+ }: rec {
163+ # The sources, i.e. the attribute set of spec name to spec
164+ inherit sources;
165+
166+ # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
167+ inherit pkgs;
168+ };
169+
170+in
171+mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
package.yamlnew file+15
@@ -0,0 +1,15 @@
1+name: sawtooth-haskell-protos
2+synopsis: An autogenerated module with Hyperledger Sawtooth protobuf types
3+
4+dependencies:
5+ - base
6+ - vector
7+ - text
8+ - deepseq
9+ - bytestring
10+ - proto3-suite
11+ - containers
12+ - proto3-wire
13+
14+library:
15+ source-dirs: src