first nix changes

This commit is contained in:
Ivan FB 2026-04-03 02:42:52 +02:00
parent 97ef267f39
commit 7d7c072dbb
No known key found for this signature in database
GPG Key ID: DF0C67A04C543270
8 changed files with 1147 additions and 223 deletions

57
flake.lock generated
View File

@ -2,27 +2,48 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1757590060,
"narHash": "sha256-EWwwdKLMZALkgHFyKW7rmyhxECO74+N+ZO5xTDnY/5c=",
"lastModified": 1770464364,
"narHash": "sha256-z5NJPSBwsLf/OfD8WTmh79tlSU8XgIbwmk6qB1/TFzY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0ef228213045d2cdb5a169a95d63ded38670b293",
"rev": "23d72dabcb3b12469f57b37170fcbc1789bd7457",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0ef228213045d2cdb5a169a95d63ded38670b293",
"rev": "23d72dabcb3b12469f57b37170fcbc1789bd7457",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay",
"zerokit": "zerokit"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1775099554,
"narHash": "sha256-3xBsGnGDLOFtnPZ1D3j2LU19wpAlYefRKTlkv648rU0=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "8d6387ed6d8e6e6672fd3ed4b61b59d44b124d99",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"rust-overlay_2": {
"inputs": {
"nixpkgs": [
"zerokit",
@ -30,11 +51,11 @@
]
},
"locked": {
"lastModified": 1748399823,
"narHash": "sha256-kahD8D5hOXOsGbNdoLLnqCL887cjHkx98Izc37nDjlA=",
"lastModified": 1771211437,
"narHash": "sha256-lcNK438i4DGtyA+bPXXyVLHVmJjYpVKmpux9WASa3ro=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "d68a69dc71bc19beb3479800392112c2f6218159",
"rev": "c62195b3d6e1bb11e0c2fb2a494117d3b55d410f",
"type": "github"
},
"original": {
@ -48,21 +69,21 @@
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": "rust-overlay"
"rust-overlay": "rust-overlay_2"
},
"locked": {
"lastModified": 1762211504,
"narHash": "sha256-SbDoBElFYJ4cYebltxlO2lYnz6qOaDAVY6aNJ5bqHDE=",
"ref": "refs/heads/master",
"rev": "3160d9504d07791f2fc9b610948a6cf9a58ed488",
"revCount": 342,
"type": "git",
"url": "https://github.com/vacp2p/zerokit"
"lastModified": 1771279884,
"narHash": "sha256-tzkQPwSl4vPTUo1ixHh6NCENjsBDroMKTjifg2q8QX8=",
"owner": "vacp2p",
"repo": "zerokit",
"rev": "53b18098e6d5d046e3eb1ac338a8f4f651432477",
"type": "github"
},
"original": {
"rev": "3160d9504d07791f2fc9b610948a6cf9a58ed488",
"type": "git",
"url": "https://github.com/vacp2p/zerokit"
"owner": "vacp2p",
"repo": "zerokit",
"rev": "53b18098e6d5d046e3eb1ac338a8f4f651432477",
"type": "github"
}
}
},

111
flake.nix
View File

@ -1,88 +1,71 @@
{
description = "Logos Messaging Nim build flake";
description = "logos-delivery nim build flake";
nixConfig = {
extra-substituters = [ "https://nix-cache.status.im/" ];
extra-trusted-public-keys = [ "nix-cache.status.im-1:x/93lOfLU+duPplwMSBR+OlY4+mo+dCN7n0mr4oPwgY=" ];
extra-trusted-public-keys = [
"nix-cache.status.im-1:x/93lOfLU+duPplwMSBR+OlY4+mo+dCN7n0mr4oPwgY="
];
};
inputs = {
# We are pinning the commit because ultimately we want to use same commit across different projects.
# A commit from nixpkgs 24.11 release : https://github.com/NixOS/nixpkgs/tree/release-24.11
nixpkgs.url = "github:NixOS/nixpkgs/0ef228213045d2cdb5a169a95d63ded38670b293";
# WARNING: Remember to update commit and use 'nix flake update' to update flake.lock.
# Pinning the commit to use same commit across different projects.
# A commit from nixpkgs 25.11 release: https://github.com/NixOS/nixpkgs/tree/release-25.11
nixpkgs.url = "github:NixOS/nixpkgs?rev=23d72dabcb3b12469f57b37170fcbc1789bd7457";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
# External flake input: Zerokit pinned to a specific commit.
# Update the rev here when a new zerokit version is needed.
zerokit = {
url = "git+https://github.com/vacp2p/zerokit?rev=3160d9504d07791f2fc9b610948a6cf9a58ed488";
url = "github:vacp2p/zerokit/53b18098e6d5d046e3eb1ac338a8f4f651432477";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, zerokit }:
outputs = { self, nixpkgs, rust-overlay, zerokit }:
let
stableSystems = [
systems = [
"x86_64-linux" "aarch64-linux"
"x86_64-darwin" "aarch64-darwin"
"x86_64-windows" "i686-linux"
"i686-windows"
"x86_64-windows"
];
forAllSystems = f: nixpkgs.lib.genAttrs stableSystems (system: f system);
forAllSystems = nixpkgs.lib.genAttrs systems;
pkgsFor = forAllSystems (
system: import nixpkgs {
inherit system;
config = {
android_sdk.accept_license = true;
allowUnfree = true;
pkgsFor = system: import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
in {
packages = forAllSystems (system:
let
pkgs = pkgsFor system;
mkPkg = zerokitRln: import ./nix/default.nix {
inherit pkgs zerokitRln;
src = ./.;
};
overlays = [
(final: prev: {
androidEnvCustom = prev.callPackage ./nix/pkgs/android-sdk { };
androidPkgs = final.androidEnvCustom.pkgs;
androidShell = final.androidEnvCustom.shell;
})
];
in rec {
liblogosdelivery = mkPkg zerokit.packages.${system}.rln;
libwaku = mkPkg zerokit.packages.${system}.rln;
default = liblogosdelivery;
}
);
in rec {
packages = forAllSystems (system: let
pkgs = pkgsFor.${system};
in rec {
libwaku-android-arm64 = pkgs.callPackage ./nix/default.nix {
inherit stableSystems;
src = self;
targets = ["libwaku-android-arm64"];
abidir = "arm64-v8a";
zerokitRln = zerokit.packages.${system}.rln-android-arm64;
};
libwaku = pkgs.callPackage ./nix/default.nix {
inherit stableSystems;
src = self;
targets = ["libwaku"];
zerokitRln = zerokit.packages.${system}.rln;
};
wakucanary = pkgs.callPackage ./nix/default.nix {
inherit stableSystems;
src = self;
targets = ["wakucanary"];
zerokitRln = zerokit.packages.${system}.rln;
};
liblogosdelivery = pkgs.callPackage ./nix/default.nix {
inherit stableSystems;
src = self;
targets = ["liblogosdelivery"];
zerokitRln = zerokit.packages.${system}.rln;
};
default = libwaku;
});
devShells = forAllSystems (system: {
default = pkgsFor.${system}.callPackage ./nix/shell.nix {};
});
devShells = forAllSystems (system:
let
pkgs = pkgsFor system;
in {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
nim-2_2
nimble
];
};
}
);
};
}

619
nimble.lock Normal file
View File

@ -0,0 +1,619 @@
{
"version": 2,
"packages": {
"nim": {
"version": "2.2.4",
"vcsRevision": "911e0dbb1f76de61fa0215ab1bb85af5334cc9a8",
"url": "https://github.com/nim-lang/Nim.git",
"downloadMethod": "git",
"dependencies": [],
"checksums": {
"sha1": "b4bb510bd58b8fccf53a122a42699d8070b92c3e"
}
},
"unittest2": {
"version": "0.2.5",
"vcsRevision": "26f2ef3ae0ec72a2a75bfe557e02e88f6a31c189",
"url": "https://github.com/status-im/nim-unittest2",
"downloadMethod": "git",
"dependencies": [
"nim"
],
"checksums": {
"sha1": "02bb3751ba9ddc3c17bfd89f2e41cb6bfb8fc0c9"
}
},
"bearssl": {
"version": "0.2.7",
"vcsRevision": "3b341f30d8c619b9a75c154243f9a55468a404e2",
"url": "https://github.com/status-im/nim-bearssl",
"downloadMethod": "git",
"dependencies": [
"nim",
"unittest2"
],
"checksums": {
"sha1": "a85aab15b1b9a8b2438e9a128ac2eba41227da79"
}
},
"bearssl_pkey_decoder": {
"version": "#21dd3710df9345ed2ad8bf8f882761e07863b8e0",
"vcsRevision": "21dd3710df9345ed2ad8bf8f882761e07863b8e0",
"url": "https://github.com/vacp2p/bearssl_pkey_decoder",
"downloadMethod": "git",
"dependencies": [
"nim",
"bearssl"
],
"checksums": {
"sha1": "21b42e2e6ddca6c875d3fc50f36a5115abf51714"
}
},
"jwt": {
"version": "#18f8378de52b241f321c1f9ea905456e89b95c6f",
"vcsRevision": "18f8378de52b241f321c1f9ea905456e89b95c6f",
"url": "https://github.com/vacp2p/nim-jwt.git",
"downloadMethod": "git",
"dependencies": [
"nim",
"bearssl",
"bearssl_pkey_decoder"
],
"checksums": {
"sha1": "bcfd6fc9c5e10a52b87117219b7ab5c98136bc8e"
}
},
"testutils": {
"version": "0.8.1",
"vcsRevision": "6ce5e5e2301ccbc04b09d27ff78741ff4d352b4d",
"url": "https://github.com/status-im/nim-testutils",
"downloadMethod": "git",
"dependencies": [
"nim",
"unittest2"
],
"checksums": {
"sha1": "96a11cf8b84fa9bd12d4a553afa1cc4b7f9df4e3"
}
},
"nimble": {
"version": "0.22.3",
"vcsRevision": "42ef70c2102a942c46f13eb76872326edd525cec",
"url": "https://github.com/nim-lang/nimble",
"downloadMethod": "git",
"dependencies": [
"nim"
],
"checksums": {
"sha1": "e8c74830841e7a316237b44ad0777a83fbeddff9"
}
},
"db_connector": {
"version": "0.1.0",
"vcsRevision": "29450a2063970712422e1ab857695c12d80112a6",
"url": "https://github.com/nim-lang/db_connector",
"downloadMethod": "git",
"dependencies": [
"nim"
],
"checksums": {
"sha1": "4f2e67d0e4b61af9ac5575509305660b473f01a4"
}
},
"results": {
"version": "0.5.1",
"vcsRevision": "df8113dda4c2d74d460a8fa98252b0b771bf1f27",
"url": "https://github.com/arnetheduck/nim-results",
"downloadMethod": "git",
"dependencies": [
"nim"
],
"checksums": {
"sha1": "a9c011f74bc9ed5c91103917b9f382b12e82a9e7"
}
},
"nat_traversal": {
"version": "0.0.1",
"vcsRevision": "860e18c37667b5dd005b94c63264560c35d88004",
"url": "https://github.com/status-im/nim-nat-traversal",
"downloadMethod": "git",
"dependencies": [
"nim",
"results"
],
"checksums": {
"sha1": "1a376d3e710590ef2c48748a546369755f0a7c97"
}
},
"stew": {
"version": "0.5.0",
"vcsRevision": "4382b18f04b3c43c8409bfcd6b62063773b2bbaa",
"url": "https://github.com/status-im/nim-stew",
"downloadMethod": "git",
"dependencies": [
"nim",
"results",
"unittest2"
],
"checksums": {
"sha1": "db22942939773ab7d5a0f2b2668c237240c67dd6"
}
},
"zlib": {
"version": "0.1.0",
"vcsRevision": "e680f269fb01af2c34a2ba879ff281795a5258fe",
"url": "https://github.com/status-im/nim-zlib",
"downloadMethod": "git",
"dependencies": [
"nim",
"stew",
"results"
],
"checksums": {
"sha1": "bbde4f5a97a84b450fef7d107461e5f35cf2b47f"
}
},
"httputils": {
"version": "0.4.1",
"vcsRevision": "f142cb2e8bd812dd002a6493b6082827bb248592",
"url": "https://github.com/status-im/nim-http-utils",
"downloadMethod": "git",
"dependencies": [
"nim",
"stew",
"results",
"unittest2"
],
"checksums": {
"sha1": "016774ab31c3afff9a423f7d80584905ee59c570"
}
},
"chronos": {
"version": "4.2.2",
"vcsRevision": "45f43a9ad8bd8bcf5903b42f365c1c879bd54240",
"url": "https://github.com/status-im/nim-chronos",
"downloadMethod": "git",
"dependencies": [
"nim",
"results",
"stew",
"bearssl",
"httputils",
"unittest2"
],
"checksums": {
"sha1": "3a4c9477df8cef20a04e4f1b54a2d74fdfc2a3d0"
}
},
"metrics": {
"version": "0.2.1",
"vcsRevision": "a1296caf3ebb5f30f51a5feae7749a30df2824c2",
"url": "https://github.com/status-im/nim-metrics",
"downloadMethod": "git",
"dependencies": [
"nim",
"chronos",
"results",
"stew"
],
"checksums": {
"sha1": "84bb09873d7677c06046f391c7b473cd2fcff8a2"
}
},
"faststreams": {
"version": "0.5.0",
"vcsRevision": "ce27581a3e881f782f482cb66dc5b07a02bd615e",
"url": "https://github.com/status-im/nim-faststreams",
"downloadMethod": "git",
"dependencies": [
"nim",
"stew",
"unittest2"
],
"checksums": {
"sha1": "ee61e507b805ae1df7ec936f03f2d101b0d72383"
}
},
"snappy": {
"version": "0.1.0",
"vcsRevision": "00bfcef94f8ef6981df5d5b994897f6695badfb2",
"url": "https://github.com/status-im/nim-snappy",
"downloadMethod": "git",
"dependencies": [
"nim",
"faststreams",
"unittest2",
"results",
"stew"
],
"checksums": {
"sha1": "e572d60d6a3178c5b1cde2400c51ad771812cd3d"
}
},
"serialization": {
"version": "0.5.2",
"vcsRevision": "b0f2fa32960ea532a184394b0f27be37bd80248b",
"url": "https://github.com/status-im/nim-serialization",
"downloadMethod": "git",
"dependencies": [
"nim",
"faststreams",
"unittest2",
"stew"
],
"checksums": {
"sha1": "fa35c1bb76a0a02a2379fe86eaae0957c7527cb8"
}
},
"toml_serialization": {
"version": "0.2.18",
"vcsRevision": "b5b387e6fb2a7cc75d54a269b07cc6218361bd46",
"url": "https://github.com/status-im/nim-toml-serialization",
"downloadMethod": "git",
"dependencies": [
"nim",
"faststreams",
"serialization",
"stew"
],
"checksums": {
"sha1": "76ae1c2af5dd092849b41750ff29217980dc9ca3"
}
},
"confutils": {
"version": "0.1.0",
"vcsRevision": "7728f6bd81a1eedcfe277d02ea85fdb805bcc05a",
"url": "https://github.com/status-im/nim-confutils",
"downloadMethod": "git",
"dependencies": [
"nim",
"stew",
"serialization",
"results"
],
"checksums": {
"sha1": "8bc8c30b107fdba73b677e5f257c6c42ae1cdc8e"
}
},
"json_serialization": {
"version": "0.4.4",
"vcsRevision": "c343b0e243d9e17e2c40f3a8a24340f7c4a71d44",
"url": "https://github.com/status-im/nim-json-serialization",
"downloadMethod": "git",
"dependencies": [
"nim",
"faststreams",
"serialization",
"stew",
"results"
],
"checksums": {
"sha1": "8b3115354104858a0ac9019356fb29720529c2bd"
}
},
"chronicles": {
"version": "0.12.2",
"vcsRevision": "27ec507429a4eb81edc20f28292ee8ec420be05b",
"url": "https://github.com/status-im/nim-chronicles",
"downloadMethod": "git",
"dependencies": [
"nim",
"faststreams",
"serialization",
"json_serialization",
"testutils"
],
"checksums": {
"sha1": "02febb20d088120b2836d3306cfa21f434f88f65"
}
},
"presto": {
"version": "0.1.1",
"vcsRevision": "d66043dd7ede146442e6c39720c76a20bde5225f",
"url": "https://github.com/status-im/nim-presto",
"downloadMethod": "git",
"dependencies": [
"nim",
"chronos",
"chronicles",
"metrics",
"results",
"stew"
],
"checksums": {
"sha1": "8df97c45683abe2337bdff43b844c4fbcc124ca2"
}
},
"stint": {
"version": "0.8.2",
"vcsRevision": "470b7892561b5179ab20bd389a69217d6213fe58",
"url": "https://github.com/status-im/nim-stint",
"downloadMethod": "git",
"dependencies": [
"nim",
"stew",
"unittest2"
],
"checksums": {
"sha1": "d8f871fd617e7857192d4609fe003b48942a8ae5"
}
},
"minilru": {
"version": "0.1.0",
"vcsRevision": "6dd93feb60f4cded3c05e7af7209cf63fb677893",
"url": "https://github.com/status-im/nim-minilru",
"downloadMethod": "git",
"dependencies": [
"nim",
"results",
"unittest2"
],
"checksums": {
"sha1": "0be03a5da29fdd4409ea74a60fd0ccce882601b4"
}
},
"sqlite3_abi": {
"version": "3.52.0.0",
"vcsRevision": "4b79c5e1882b7fc6c00aec311daf1ed50ad653d5",
"url": "https://github.com/arnetheduck/nim-sqlite3-abi",
"downloadMethod": "git",
"dependencies": [
"nim"
],
"checksums": {
"sha1": "b56b489a7cb01eef8821d66d38d411923a14316d"
}
},
"dnsclient": {
"version": "0.3.4",
"vcsRevision": "23214235d4784d24aceed99bbfe153379ea557c8",
"url": "https://github.com/ba0f3/dnsclient.nim",
"downloadMethod": "git",
"dependencies": [
"nim"
],
"checksums": {
"sha1": "65262c7e533ff49d6aca5539da4bc6c6ce132f40"
}
},
"unicodedb": {
"version": "0.13.2",
"vcsRevision": "66f2458710dc641dd4640368f9483c8a0ec70561",
"url": "https://github.com/nitely/nim-unicodedb",
"downloadMethod": "git",
"dependencies": [
"nim"
],
"checksums": {
"sha1": "739102d885d99bb4571b1955f5f12aee423c935b"
}
},
"regex": {
"version": "0.26.3",
"vcsRevision": "4593305ed1e49731fc75af1dc572dd2559aad19c",
"url": "https://github.com/nitely/nim-regex",
"downloadMethod": "git",
"dependencies": [
"nim",
"unicodedb"
],
"checksums": {
"sha1": "4d24e7d7441137cd202e16f2359a5807ddbdc31f"
}
},
"nimcrypto": {
"version": "0.7.3",
"vcsRevision": "b3dbc9c4d08e58c5b7bfad6dc7ef2ee52f2f4c08",
"url": "https://github.com/cheatfate/nimcrypto",
"downloadMethod": "git",
"dependencies": [
"nim"
],
"checksums": {
"sha1": "f72b90fe3f4da09efa482de4f8729e7ee4abea2f"
}
},
"websock": {
"version": "0.2.2",
"vcsRevision": "3918ce3900c83e1cc7496232a307709f195f7acd",
"url": "https://github.com/status-im/nim-websock",
"downloadMethod": "git",
"dependencies": [
"nim",
"chronos",
"httputils",
"chronicles",
"stew",
"nimcrypto",
"bearssl",
"results",
"zlib"
],
"checksums": {
"sha1": "3c424661eff56c925b01e1cd1a911ff744e72962"
}
},
"json_rpc": {
"version": "0.5.4",
"vcsRevision": "b6e40a776fa2d00b97a9366761fb7da18f31ae5c",
"url": "https://github.com/status-im/nim-json-rpc",
"downloadMethod": "git",
"dependencies": [
"nim",
"stew",
"nimcrypto",
"stint",
"chronos",
"httputils",
"chronicles",
"websock",
"serialization",
"json_serialization",
"unittest2"
],
"checksums": {
"sha1": "d8e8be795fcf098f4ce03b5826f6b3153f6a6e07"
}
},
"lsquic": {
"version": "#4fb03ee7bfb39aecb3316889fdcb60bec3d0936f",
"vcsRevision": "4fb03ee7bfb39aecb3316889fdcb60bec3d0936f",
"url": "https://github.com/vacp2p/nim-lsquic",
"downloadMethod": "git",
"dependencies": [
"nim",
"zlib",
"stew",
"chronos",
"nimcrypto",
"unittest2",
"chronicles"
],
"checksums": {
"sha1": "f465fa994346490d0924d162f53d9b5aec62f948"
}
},
"secp256k1": {
"version": "0.6.0.3.2",
"vcsRevision": "d8f1288b7c72f00be5fc2c5ea72bf5cae1eafb15",
"url": "https://github.com/status-im/nim-secp256k1",
"downloadMethod": "git",
"dependencies": [
"nim",
"stew",
"results",
"nimcrypto"
],
"checksums": {
"sha1": "6618ef9de17121846a8c1d0317026b0ce8584e10"
}
},
"eth": {
"version": "0.9.0",
"vcsRevision": "d9135e6c3c5d6d819afdfb566aa8d958756b73a8",
"url": "https://github.com/status-im/nim-eth",
"downloadMethod": "git",
"dependencies": [
"nim",
"nimcrypto",
"stint",
"secp256k1",
"chronos",
"chronicles",
"stew",
"nat_traversal",
"metrics",
"sqlite3_abi",
"confutils",
"testutils",
"unittest2",
"results",
"minilru",
"snappy"
],
"checksums": {
"sha1": "2e01b0cfff9523d110562af70d19948280f8013e"
}
},
"web3": {
"version": "0.8.0",
"vcsRevision": "cdfe5601d2812a58e54faf53ee634452d01e5918",
"url": "https://github.com/status-im/nim-web3",
"downloadMethod": "git",
"dependencies": [
"nim",
"chronicles",
"chronos",
"bearssl",
"eth",
"faststreams",
"json_rpc",
"serialization",
"json_serialization",
"nimcrypto",
"stew",
"stint",
"results"
],
"checksums": {
"sha1": "26a112af032ef1536f97da2ca7364af618a11b80"
}
},
"dnsdisc": {
"version": "0.1.0",
"vcsRevision": "38f2e0f52c0a8f032ef4530835e519d550706d9e",
"url": "https://github.com/status-im/nim-dnsdisc",
"downloadMethod": "git",
"dependencies": [
"nim",
"bearssl",
"chronicles",
"chronos",
"eth",
"secp256k1",
"stew",
"testutils",
"unittest2",
"nimcrypto",
"results"
],
"checksums": {
"sha1": "055b882a0f6b1d1e57a25a7af99d2e5ac6268154"
}
},
"libp2p": {
"version": "#ff8d51857b4b79a68468e7bcc27b2026cca02996",
"vcsRevision": "ff8d51857b4b79a68468e7bcc27b2026cca02996",
"url": "https://github.com/vacp2p/nim-libp2p.git",
"downloadMethod": "git",
"dependencies": [
"nim",
"nimcrypto",
"dnsclient",
"bearssl",
"chronicles",
"chronos",
"metrics",
"secp256k1",
"stew",
"websock",
"unittest2",
"results",
"serialization",
"lsquic",
"jwt"
],
"checksums": {
"sha1": "fa2a7552c6ec860717b77ce34cf0b7afe4570234"
}
},
"taskpools": {
"version": "0.1.0",
"vcsRevision": "9e8ccc754631ac55ac2fd495e167e74e86293edb",
"url": "https://github.com/status-im/nim-taskpools",
"downloadMethod": "git",
"dependencies": [
"nim"
],
"checksums": {
"sha1": "09e1b2fdad55b973724d61227971afc0df0b7a81"
}
},
"ffi": {
"version": "0.1.3",
"vcsRevision": "06111de155253b34e47ed2aaed1d61d08d62cc1b",
"url": "https://github.com/logos-messaging/nim-ffi",
"downloadMethod": "git",
"dependencies": [
"nim",
"chronos",
"chronicles",
"taskpools"
],
"checksums": {
"sha1": "6f9d49375ea1dc71add55c72ac80a808f238e5b0"
}
}
},
"tasks": {}
}

View File

@ -1,149 +1,78 @@
{
pkgs,
src ? ../.,
targets ? ["libwaku-android-arm64"],
verbosity ? 1,
useSystemNim ? true,
quickAndDirty ? true,
stableSystems ? [
"x86_64-linux" "aarch64-linux"
],
abidir ? null,
zerokitRln,
}:
assert pkgs.lib.assertMsg ((src.submodules or true) == true)
"Unable to build without submodules. Append '?submodules=1#' to the URI.";
{ pkgs, src, zerokitRln }:
let
inherit (pkgs) stdenv lib writeScriptBin callPackage;
deps = import ./deps.nix { inherit pkgs; };
nimSrc = pkgs.callPackage ./nim.nix {};
nimbleSrc = pkgs.callPackage ./nimble.nix {};
androidManifest = "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"com.example.mylibrary\" />";
pathArgs =
builtins.concatStringsSep " "
(map (p: "--path:${p}") (builtins.attrValues deps));
tools = pkgs.callPackage ./tools.nix {};
version = tools.findKeyValue "^version = \"([a-f0-9.-]+)\"$" ../waku.nimble;
revision = lib.substring 0 8 (src.rev or src.dirtyRev or "00000000");
copyLibwaku = lib.elem "libwaku" targets;
copyLiblogosdelivery = lib.elem "liblogosdelivery" targets;
copyWakunode2 = lib.elem "wakunode2" targets;
hasKnownInstallTarget = copyLibwaku || copyLiblogosdelivery || copyWakunode2;
in stdenv.mkDerivation {
pname = "logos-messaging-nim";
version = "${version}-${revision}";
libExt =
if pkgs.stdenv.hostPlatform.isWindows then "dll"
else if pkgs.stdenv.hostPlatform.isDarwin then "dylib"
else "so";
in
pkgs.stdenv.mkDerivation {
pname = "liblogosdelivery";
version = "dev";
inherit src;
# Runtime dependencies
buildInputs = with pkgs; [
openssl gmp zip
nativeBuildInputs = with pkgs; [
nim-2_2
git
];
# Dependencies that should only exist in the build environment.
nativeBuildInputs = let
# Fix for Nim compiler calling 'git rev-parse' and 'lsb_release'.
fakeGit = writeScriptBin "git" "echo ${version}";
in with pkgs; [
cmake which zerokitRln nim-unwrapped-2_2 fakeGit
] ++ lib.optionals stdenv.isDarwin [
pkgs.darwin.cctools gcc # Necessary for libbacktrace
];
buildInputs = [ zerokitRln ];
# Environment variables required for Android builds
ANDROID_SDK_ROOT = "${pkgs.androidPkgs.sdk}";
ANDROID_NDK_HOME = "${pkgs.androidPkgs.ndk}";
NIMFLAGS = "-d:disableMarchNative -d:git_revision_override=${revision}";
XDG_CACHE_HOME = "/tmp";
buildPhase = ''
export HOME=$TMPDIR
export XDG_CACHE_HOME=$TMPDIR/.cache
export NIMBLE_DIR=$TMPDIR/.nimble
export NIMCACHE=$TMPDIR/nimcache
makeFlags = targets ++ [
"V=${toString verbosity}"
"QUICK_AND_DIRTY_COMPILER=${if quickAndDirty then "1" else "0"}"
"QUICK_AND_DIRTY_NIMBLE=${if quickAndDirty then "1" else "0"}"
"USE_SYSTEM_NIM=${if useSystemNim then "1" else "0"}"
"LIBRLN_FILE=${zerokitRln}/lib/librln.${if abidir != null then "so" else "a"}"
"POSTGRES=1"
];
mkdir -p build $NIMCACHE
configurePhase = ''
patchShebangs . vendor/nimbus-build-system > /dev/null
echo "== Building liblogosdelivery (dynamic) =="
nim c \
--noNimblePath \
${pathArgs} \
--lib:${nimSrc}/lib \
--nimblePath:${nimbleSrc} \
--passL:"-L${zerokitRln}/lib -lrln" \
--out:build/liblogosdelivery.${libExt} \
--app:lib \
--threads:on \
--opt:size \
--noMain \
--mm:refc \
--header \
--nimcache:$NIMCACHE \
liblogosdelivery/liblogosdelivery.nim
# build_nim.sh guards "rm -rf dist/checksums" with NIX_BUILD_TOP != "/build",
# but on macOS the nix sandbox uses /private/tmp/... so the check fails and
# dist/checksums (provided via preBuild) gets deleted. Fix the check to skip
# the removal whenever NIX_BUILD_TOP is set (i.e. any nix build).
substituteInPlace vendor/nimbus-build-system/scripts/build_nim.sh \
--replace 'if [[ "''${NIX_BUILD_TOP}" != "/build" ]]; then' \
'if [[ -z "''${NIX_BUILD_TOP}" ]]; then'
make nimbus-build-system-paths
make nimbus-build-system-nimble-dir
echo "== Building liblogosdelivery (static) =="
nim c \
--noNimblePath \
${pathArgs} \
--lib:${nimSrc}/lib \
--nimblePath:${nimbleSrc} \
--passL:"-L${zerokitRln}/lib -lrln" \
--out:build/liblogosdelivery.a \
--app:staticlib \
--threads:on \
--opt:size \
--noMain \
--mm:refc \
--nimcache:$NIMCACHE \
liblogosdelivery/liblogosdelivery.nim
'';
# For the Nim v2.2.4 built with NBS we added sat and zippy
preBuild = lib.optionalString (!useSystemNim) ''
pushd vendor/nimbus-build-system/vendor/Nim
mkdir dist
mkdir -p dist/nimble/vendor/sat
mkdir -p dist/nimble/vendor/checksums
mkdir -p dist/nimble/vendor/zippy
cp -r ${callPackage ./nimble.nix {}}/. dist/nimble
cp -r ${callPackage ./checksums.nix {}}/. dist/checksums
cp -r ${callPackage ./csources.nix {}}/. csources_v2
cp -r ${callPackage ./sat.nix {}}/. dist/nimble/vendor/sat
cp -r ${callPackage ./checksums.nix {}}/. dist/nimble/vendor/checksums
cp -r ${callPackage ./zippy.nix {}}/. dist/nimble/vendor/zippy
chmod 777 -R dist/nimble csources_v2
popd
'';
installPhase = if abidir != null then ''
mkdir -p $out/jni
cp -r ./build/android/${abidir}/* $out/jni/
echo '${androidManifest}' > $out/jni/AndroidManifest.xml
cd $out && zip -r libwaku.aar *
'' else ''
mkdir -p $out/bin $out/include
# Copy artifacts from build directory (created by Make during buildPhase)
# Note: build/ is in the source tree, not result/ (which is a post-build symlink)
if [ -d build ]; then
${lib.optionalString copyLibwaku ''
cp build/libwaku.{so,dylib,dll,a,lib} $out/bin/ 2>/dev/null || true
''}
${lib.optionalString copyLiblogosdelivery ''
cp build/liblogosdelivery.{so,dylib,dll,a,lib} $out/bin/ 2>/dev/null || true
''}
${lib.optionalString copyWakunode2 ''
cp build/wakunode2 $out/bin/ 2>/dev/null || true
''}
${lib.optionalString (!hasKnownInstallTarget) ''
cp build/lib*.{so,dylib,dll,a,lib} $out/bin/ 2>/dev/null || true
''}
fi
# Copy header files
${lib.optionalString copyLibwaku ''
cp library/libwaku.h $out/include/ 2>/dev/null || true
''}
${lib.optionalString copyLiblogosdelivery ''
installPhase = ''
mkdir -p $out/lib $out/include
cp build/liblogosdelivery.${libExt} $out/lib/ 2>/dev/null || true
cp build/liblogosdelivery.a $out/lib/ 2>/dev/null || true
cp liblogosdelivery/liblogosdelivery.h $out/include/ 2>/dev/null || true
''}
${lib.optionalString (!hasKnownInstallTarget) ''
cp library/libwaku.h $out/include/ 2>/dev/null || true
cp liblogosdelivery/liblogosdelivery.h $out/include/ 2>/dev/null || true
''}
'';
meta = with pkgs.lib; {
description = "NWaku derivation to build libwaku for mobile targets using Android NDK and Rust.";
homepage = "https://github.com/status-im/nwaku";
license = licenses.mit;
platforms = stableSystems;
};
}

272
nix/deps.nix Normal file
View File

@ -0,0 +1,272 @@
# AUTOGENERATED from nimble.lock — do not edit manually.
# Regenerate with: ./tools/gen-nix-deps.sh nimble.lock nix/deps.nix
{ pkgs }:
{
unittest2 = pkgs.fetchgit {
url = "https://github.com/status-im/nim-unittest2";
rev = "26f2ef3ae0ec72a2a75bfe557e02e88f6a31c189";
sha256 = "1n8n36kad50m97b64y7bzzknz9n7szffxhp0bqpk3g2v7zpda8sw";
fetchSubmodules = true;
};
bearssl = pkgs.fetchgit {
url = "https://github.com/status-im/nim-bearssl";
rev = "3b341f30d8c619b9a75c154243f9a55468a404e2";
sha256 = "059avc2dh39vv9c3a1qayah98fjm5pw04r3dn2bqrgs6vf7licmv";
fetchSubmodules = true;
};
bearssl_pkey_decoder = pkgs.fetchgit {
url = "https://github.com/vacp2p/bearssl_pkey_decoder";
rev = "21dd3710df9345ed2ad8bf8f882761e07863b8e0";
sha256 = "0bl3f147zmkazbhdkr4cj1nipf9rqiw3g4hh1j424k9hpl55zdpg";
fetchSubmodules = true;
};
jwt = pkgs.fetchgit {
url = "https://github.com/vacp2p/nim-jwt.git";
rev = "18f8378de52b241f321c1f9ea905456e89b95c6f";
sha256 = "1986czmszdxj6g9yr7xn1fx8y2y9mwpb3f1bn9nc6973qawsdm0p";
fetchSubmodules = true;
};
testutils = pkgs.fetchgit {
url = "https://github.com/status-im/nim-testutils";
rev = "6ce5e5e2301ccbc04b09d27ff78741ff4d352b4d";
sha256 = "1vbkr6i5yxhc2ai3b7rbglhmyc98f99x874fqdp6a152a6kqgwxy";
fetchSubmodules = true;
};
db_connector = pkgs.fetchgit {
url = "https://github.com/nim-lang/db_connector";
rev = "29450a2063970712422e1ab857695c12d80112a6";
sha256 = "11dna09ccdhj3pzpqa04j7a95ibx907z6n1ff33yf0n92qa4x59z";
fetchSubmodules = true;
};
results = pkgs.fetchgit {
url = "https://github.com/arnetheduck/nim-results";
rev = "df8113dda4c2d74d460a8fa98252b0b771bf1f27";
sha256 = "1h7amas16sbhlr7zb7n3jb5434k98ji375vzw72k1fsc86vnmcr9";
fetchSubmodules = true;
};
nat_traversal = pkgs.fetchgit {
url = "https://github.com/status-im/nim-nat-traversal";
rev = "860e18c37667b5dd005b94c63264560c35d88004";
sha256 = "0319k5bbl468phwfnvlrh7725sc80rnf7m9gyj0i3cb5hb9q78bs";
fetchSubmodules = true;
};
stew = pkgs.fetchgit {
url = "https://github.com/status-im/nim-stew";
rev = "4382b18f04b3c43c8409bfcd6b62063773b2bbaa";
sha256 = "0mx9g5m636h3sk5pllcpylk51brf7lx91izx3gc23k3ih3hrxyk2";
fetchSubmodules = true;
};
zlib = pkgs.fetchgit {
url = "https://github.com/status-im/nim-zlib";
rev = "e680f269fb01af2c34a2ba879ff281795a5258fe";
sha256 = "1xw9f1gjsgqihdg7kdkbaq1wankgnx2vn9l3ihc6nqk2jzv5bvk5";
fetchSubmodules = true;
};
httputils = pkgs.fetchgit {
url = "https://github.com/status-im/nim-http-utils";
rev = "f142cb2e8bd812dd002a6493b6082827bb248592";
sha256 = "03msj4zdxraz4qx9cidb17g7v0asazxv91nng6xxbzjxz0qaqxw6";
fetchSubmodules = true;
};
chronos = pkgs.fetchgit {
url = "https://github.com/status-im/nim-chronos";
rev = "45f43a9ad8bd8bcf5903b42f365c1c879bd54240";
sha256 = "1v1n59zfzznp97pvwgs9kf136bqmv4x2s2y9f24msspa7qv27w39";
fetchSubmodules = true;
};
metrics = pkgs.fetchgit {
url = "https://github.com/status-im/nim-metrics";
rev = "a1296caf3ebb5f30f51a5feae7749a30df2824c2";
sha256 = "02vxqy20g8012ks939ac25ksc25k727q84si0p2cmihy5bw1a3qm";
fetchSubmodules = true;
};
faststreams = pkgs.fetchgit {
url = "https://github.com/status-im/nim-faststreams";
rev = "ce27581a3e881f782f482cb66dc5b07a02bd615e";
sha256 = "0y6bw2scnmr8cxj4fg18w7f34l2bh9qwg5nhlgd84m9fpr5bqarn";
fetchSubmodules = true;
};
snappy = pkgs.fetchgit {
url = "https://github.com/status-im/nim-snappy";
rev = "00bfcef94f8ef6981df5d5b994897f6695badfb2";
sha256 = "117mam97mkjjj1hs8svc07679k5ayww9yigi74yq8dyqm6fpbl6l";
fetchSubmodules = true;
};
serialization = pkgs.fetchgit {
url = "https://github.com/status-im/nim-serialization";
rev = "b0f2fa32960ea532a184394b0f27be37bd80248b";
sha256 = "0wip1fjx7ka39ck1g1xvmyarzq1p5dlngpqil6zff8k8z5skiz27";
fetchSubmodules = true;
};
toml_serialization = pkgs.fetchgit {
url = "https://github.com/status-im/nim-toml-serialization";
rev = "b5b387e6fb2a7cc75d54a269b07cc6218361bd46";
sha256 = "175swdj01rz57h1hvflkyaz4x76qbfn0174ysrk3qk385i1zlg5z";
fetchSubmodules = true;
};
confutils = pkgs.fetchgit {
url = "https://github.com/status-im/nim-confutils";
rev = "7728f6bd81a1eedcfe277d02ea85fdb805bcc05a";
sha256 = "18bj1ilx10jm2vmqx2wy2xl9rzy7alymi2m4n9jgpa4sbxnfh0x3";
fetchSubmodules = true;
};
json_serialization = pkgs.fetchgit {
url = "https://github.com/status-im/nim-json-serialization";
rev = "c343b0e243d9e17e2c40f3a8a24340f7c4a71d44";
sha256 = "0i8sq51nqj8lshf6bfixaz9a7sq0ahsbvq3chkxdvv4khsqvam91";
fetchSubmodules = true;
};
chronicles = pkgs.fetchgit {
url = "https://github.com/status-im/nim-chronicles";
rev = "27ec507429a4eb81edc20f28292ee8ec420be05b";
sha256 = "1xx9fcfwgcaizq3s7i3s03mclz253r5j8va38l9ycl19fcbc96z9";
fetchSubmodules = true;
};
presto = pkgs.fetchgit {
url = "https://github.com/status-im/nim-presto";
rev = "d66043dd7ede146442e6c39720c76a20bde5225f";
sha256 = "1hrppcak32aigrdv3mqk124w81yy9jv1prs57vqqhfj83gl930vi";
fetchSubmodules = true;
};
stint = pkgs.fetchgit {
url = "https://github.com/status-im/nim-stint";
rev = "470b7892561b5179ab20bd389a69217d6213fe58";
sha256 = "1isfwmbj98qfi5pm9acy0yyvq0vlz38nxp30xl43jx2mmaga2w22";
fetchSubmodules = true;
};
minilru = pkgs.fetchgit {
url = "https://github.com/status-im/nim-minilru";
rev = "6dd93feb60f4cded3c05e7af7209cf63fb677893";
sha256 = "1xgx4j56ais3hk8b51zhnfs9q85g2afkp3y1j9ky5iziqvcs2sml";
fetchSubmodules = true;
};
sqlite3_abi = pkgs.fetchgit {
url = "https://github.com/arnetheduck/nim-sqlite3-abi";
rev = "4b79c5e1882b7fc6c00aec311daf1ed50ad653d5";
sha256 = "0qa6p2vnxmf6r2w19mfydr5rzv7bg1lfxccnpdhk0akzxnc7i5gy";
fetchSubmodules = true;
};
dnsclient = pkgs.fetchgit {
url = "https://github.com/ba0f3/dnsclient.nim";
rev = "23214235d4784d24aceed99bbfe153379ea557c8";
sha256 = "03mf3lw5c0m5nq9ppa49nylrl8ibkv2zzlc0wyhqg7w09kz6hks6";
fetchSubmodules = true;
};
unicodedb = pkgs.fetchgit {
url = "https://github.com/nitely/nim-unicodedb";
rev = "66f2458710dc641dd4640368f9483c8a0ec70561";
sha256 = "092z3glgdb7rmwajm7dmqzvralkm7ixighixk8ycf8sf17zm72ck";
fetchSubmodules = true;
};
regex = pkgs.fetchgit {
url = "https://github.com/nitely/nim-regex";
rev = "4593305ed1e49731fc75af1dc572dd2559aad19c";
sha256 = "1b666qws5sva3n5allin0ycvnqlzdjd7xzprpdvv632ccqddzcl9";
fetchSubmodules = true;
};
nimcrypto = pkgs.fetchgit {
url = "https://github.com/cheatfate/nimcrypto";
rev = "b3dbc9c4d08e58c5b7bfad6dc7ef2ee52f2f4c08";
sha256 = "1v4rz42lwcazs6isi3kmjylkisr84mh0kgmlqycx4i885dn3g0l4";
fetchSubmodules = true;
};
websock = pkgs.fetchgit {
url = "https://github.com/status-im/nim-websock";
rev = "3918ce3900c83e1cc7496232a307709f195f7acd";
sha256 = "16zvdjyasfpb04708d072rpvg12pyz3gmszi3md5brmlhbc3x8jp";
fetchSubmodules = true;
};
json_rpc = pkgs.fetchgit {
url = "https://github.com/status-im/nim-json-rpc";
rev = "b6e40a776fa2d00b97a9366761fb7da18f31ae5c";
sha256 = "0c86glijpzcxdb5fagdk98hm9dmsrgw179nn3ixbapl48pvly9nr";
fetchSubmodules = true;
};
lsquic = pkgs.fetchgit {
url = "https://github.com/vacp2p/nim-lsquic";
rev = "4fb03ee7bfb39aecb3316889fdcb60bec3d0936f";
sha256 = "0qdhcd4hyp185szc9sv3jvwdwc9zp3j0syy7glxv13k9bchfmkfg";
fetchSubmodules = true;
};
secp256k1 = pkgs.fetchgit {
url = "https://github.com/status-im/nim-secp256k1";
rev = "d8f1288b7c72f00be5fc2c5ea72bf5cae1eafb15";
sha256 = "1qjrmwbngb73f6r1fznvig53nyal7wj41d1cmqfksrmivk2sgrn2";
fetchSubmodules = true;
};
eth = pkgs.fetchgit {
url = "https://github.com/status-im/nim-eth";
rev = "d9135e6c3c5d6d819afdfb566aa8d958756b73a8";
sha256 = "15r6aszalnbk6mkyfbv5rnz5vcf1mmgj6yg332wry53xsd2ipg7r";
fetchSubmodules = true;
};
web3 = pkgs.fetchgit {
url = "https://github.com/status-im/nim-web3";
rev = "cdfe5601d2812a58e54faf53ee634452d01e5918";
sha256 = "1j52vcqw868qs40bh4wzfw5cvvnywp2q0dnzhfajh31xws98jc27";
fetchSubmodules = true;
};
dnsdisc = pkgs.fetchgit {
url = "https://github.com/status-im/nim-dnsdisc";
rev = "38f2e0f52c0a8f032ef4530835e519d550706d9e";
sha256 = "0dk787ny49n41bmzhlrvm87giwajr01gwdw9nlmphch89rdqpxxn";
fetchSubmodules = true;
};
libp2p = pkgs.fetchgit {
url = "https://github.com/vacp2p/nim-libp2p.git";
rev = "ff8d51857b4b79a68468e7bcc27b2026cca02996";
sha256 = "08y4s0zhqzsd780bwaixfqbi79km0mcq5g8nyw7awfvcbjqsa53l";
fetchSubmodules = true;
};
taskpools = pkgs.fetchgit {
url = "https://github.com/status-im/nim-taskpools";
rev = "9e8ccc754631ac55ac2fd495e167e74e86293edb";
sha256 = "1y78l33vdjxmb9dkr455pbphxa73rgdsh8m9gpkf4d9b1wm1yivy";
fetchSubmodules = true;
};
ffi = pkgs.fetchgit {
url = "https://github.com/logos-messaging/nim-ffi";
rev = "06111de155253b34e47ed2aaed1d61d08d62cc1b";
sha256 = "0rb0d2i519amgsp7q0bn6m5465z1vwj4rab89529pyiivh3fgh8j";
fetchSubmodules = true;
};
}

17
nix/nim.nix Normal file
View File

@ -0,0 +1,17 @@
# Fetches the Nim source tree at the exact revision pinned in nimble.lock.
# The compiler binary is still pkgs.nim-2_2 (pre-built); this source is
# used to pin the stdlib to the same commit.
# Regenerate sha256 with:
# nix shell nixpkgs#nix-prefetch-git --command \
# nix-prefetch-git --url <url> --rev <vcsRevision> --fetch-submodules
{ pkgs }:
let
lock = builtins.fromJSON (builtins.readFile ../nimble.lock);
entry = lock.packages.nim;
in
pkgs.fetchgit {
url = entry.url;
rev = entry.vcsRevision;
sha256 = "1g4nxbwbc6h174gbpa3gcs47xwk6scbmiqlp0nq1ig3af8fcqcnj";
fetchSubmodules = true;
}

View File

@ -1,12 +1,15 @@
{ pkgs ? import <nixpkgs> { } }:
# Fetches Nimble at the exact revision pinned in nimble.lock.
# Regenerate sha256 with:
# nix shell nixpkgs#nix-prefetch-git --command \
# nix-prefetch-git --url <url> --rev <vcsRevision> --fetch-submodules
{ pkgs }:
let
tools = pkgs.callPackage ./tools.nix {};
sourceFile = ../vendor/nimbus-build-system/vendor/Nim/koch.nim;
in pkgs.fetchFromGitHub {
owner = "nim-lang";
repo = "nimble";
rev = tools.findKeyValue "^ +NimbleStableCommit = \"([a-f0-9]+)\".*$" sourceFile;
# WARNING: Requires manual updates when Nim compiler version changes.
hash = "sha256-8iutVgNzDtttZ7V+7S11KfLEuwhKA9TsgS51mlUI08k=";
lock = builtins.fromJSON (builtins.readFile ../nimble.lock);
entry = lock.packages.nimble;
in
pkgs.fetchgit {
url = entry.url;
rev = entry.vcsRevision;
sha256 = "1q3mpv0b5a0hhvdfn2c1f03hjbdwfam894vym14i3dm23qin2i5z";
fetchSubmodules = true;
}

80
tools/gen-nix-deps.sh Executable file
View File

@ -0,0 +1,80 @@
#!/usr/bin/env bash
# Generates nix/deps.nix from nimble.lock using nix-prefetch-git.
# Usage: ./tools/gen-nix-deps.sh [nimble.lock] [nix/deps.nix]
set -euo pipefail
usage() {
cat <<EOF
Usage:
$0 <nimble.lock> <output.nix>
Example:
$0 nimble.lock nix/deps.nix
EOF
}
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
usage; exit 0
fi
if [[ $# -ne 2 ]]; then
usage; exit 1
fi
LOCKFILE="$1"
OUTFILE="$2"
command -v jq >/dev/null || { echo "error: jq required"; exit 1; }
command -v nix-prefetch-git >/dev/null || { echo "error: nix-prefetch-git required"; exit 1; }
if [[ ! -f "$LOCKFILE" ]]; then
echo "[!] $LOCKFILE not found"
echo "[*] Generating $LOCKFILE via 'nimble lock'"
nimble lock
fi
echo "[*] Generating $OUTFILE from $LOCKFILE"
mkdir -p "$(dirname "$OUTFILE")"
cat > "$OUTFILE" <<'EOF'
# AUTOGENERATED from nimble.lock — do not edit manually.
# Regenerate with: ./tools/gen-nix-deps.sh nimble.lock nix/deps.nix
{ pkgs }:
{
EOF
jq -c '
.packages
| to_entries[]
| select(.value.downloadMethod == "git")
| select(.key != "nim" and .key != "nimble")
' "$LOCKFILE" | while read -r entry; do
name=$(jq -r '.key' <<<"$entry")
url=$(jq -r '.value.url' <<<"$entry")
rev=$(jq -r '.value.vcsRevision' <<<"$entry")
echo " [*] Prefetching $name @ $rev"
sha=$(nix-prefetch-git \
--url "$url" \
--rev "$rev" \
--fetch-submodules \
| jq -r '.sha256')
cat >> "$OUTFILE" <<EOF
${name} = pkgs.fetchgit {
url = "${url}";
rev = "${rev}";
sha256 = "${sha}";
fetchSubmodules = true;
};
EOF
done
cat >> "$OUTFILE" <<'EOF'
}
EOF
echo "[✓] Wrote $OUTFILE"