mirror of
https://github.com/status-im/nim-dagger.git
synced 2025-01-22 12:38:54 +00:00
nix: build nim compiler
Using nimbus build system since the codex now uses version of Nim >2. Tested with nim versions(>2) in nixpkgs but none of them work thus the removal of USE_SYSTEM_NIM and its logic. Signed-off-by: markoburcul <marko@status.im>
This commit is contained in:
parent
893f6d02ab
commit
d114e6e942
3
.gitignore
vendored
3
.gitignore
vendored
@ -9,6 +9,9 @@
|
|||||||
|
|
||||||
nimcache/
|
nimcache/
|
||||||
|
|
||||||
|
# Executables when using nix will be stored in result/ directory
|
||||||
|
result/
|
||||||
|
|
||||||
# Executables shall be put in an ignored build/ directory
|
# Executables shall be put in an ignored build/ directory
|
||||||
build/
|
build/
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
A development shell can be started using:
|
A development shell can be started using:
|
||||||
```sh
|
```sh
|
||||||
nix develop
|
nix develop '.?submodules=1#'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
12
nix/checksums.nix
Normal file
12
nix/checksums.nix
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> { } }:
|
||||||
|
|
||||||
|
let
|
||||||
|
tools = pkgs.callPackage ./tools.nix {};
|
||||||
|
sourceFile = ../vendor/nimbus-build-system/vendor/Nim/koch.nim;
|
||||||
|
in pkgs.fetchFromGitHub {
|
||||||
|
owner = "nim-lang";
|
||||||
|
repo = "checksums";
|
||||||
|
rev = tools.findKeyValue "^ +ChecksumsStableCommit = \"([a-f0-9]+)\"$" sourceFile;
|
||||||
|
# WARNING: Requires manual updates when Nim compiler version changes.
|
||||||
|
hash = "sha256-Bm5iJoT2kAvcTexiLMFBa9oU5gf7d4rWjo3OiN7obWQ=";
|
||||||
|
}
|
12
nix/csources.nix
Normal file
12
nix/csources.nix
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> { } }:
|
||||||
|
|
||||||
|
let
|
||||||
|
tools = pkgs.callPackage ./tools.nix {};
|
||||||
|
sourceFile = ../vendor/nimbus-build-system/vendor/Nim/config/build_config.txt;
|
||||||
|
in pkgs.fetchFromGitHub {
|
||||||
|
owner = "nim-lang";
|
||||||
|
repo = "csources_v2";
|
||||||
|
rev = tools.findKeyValue "^nim_csourcesHash=([a-f0-9]+)$" sourceFile;
|
||||||
|
# WARNING: Requires manual updates when Nim compiler version changes.
|
||||||
|
hash = "sha256-UCLtoxOcGYjBdvHx7A47x6FjLMi6VZqpSs65MN7fpBs=";
|
||||||
|
}
|
@ -3,15 +3,15 @@
|
|||||||
src ? ../.,
|
src ? ../.,
|
||||||
targets ? ["all"],
|
targets ? ["all"],
|
||||||
# Options: 0,1,2
|
# Options: 0,1,2
|
||||||
verbosity ? 0,
|
verbosity ? 1,
|
||||||
# Use system Nim compiler instead of building it with nimbus-build-system
|
|
||||||
useSystemNim ? true,
|
|
||||||
commit ? builtins.substring 0 7 (src.rev or "dirty"),
|
commit ? builtins.substring 0 7 (src.rev or "dirty"),
|
||||||
# These are the only platforms tested in CI and considered stable.
|
# These are the only platforms tested in CI and considered stable.
|
||||||
stableSystems ? [
|
stableSystems ? [
|
||||||
"x86_64-linux" "aarch64-linux"
|
"x86_64-linux" "aarch64-linux"
|
||||||
"x86_64-darwin" "aarch64-darwin"
|
"x86_64-darwin" "aarch64-darwin"
|
||||||
],
|
],
|
||||||
|
# Perform 2-stage bootstrap instead of 3-stage to save time.
|
||||||
|
quickAndDirty ? true,
|
||||||
circomCompatPkg ? (
|
circomCompatPkg ? (
|
||||||
builtins.getFlake "github:codex-storage/circom-compat-ffi"
|
builtins.getFlake "github:codex-storage/circom-compat-ffi"
|
||||||
).packages.${builtins.currentSystem}.default
|
).packages.${builtins.currentSystem}.default
|
||||||
@ -26,7 +26,7 @@ let
|
|||||||
revision = lib.substring 0 8 (src.rev or "dirty");
|
revision = lib.substring 0 8 (src.rev or "dirty");
|
||||||
|
|
||||||
tools = callPackage ./tools.nix {};
|
tools = callPackage ./tools.nix {};
|
||||||
in pkgs.gcc11Stdenv.mkDerivation rec {
|
in pkgs.gcc13Stdenv.mkDerivation rec {
|
||||||
|
|
||||||
pname = "codex";
|
pname = "codex";
|
||||||
|
|
||||||
@ -49,10 +49,7 @@ in pkgs.gcc11Stdenv.mkDerivation rec {
|
|||||||
in
|
in
|
||||||
with pkgs; [
|
with pkgs; [
|
||||||
cmake
|
cmake
|
||||||
pkg-config
|
|
||||||
nimble
|
|
||||||
which
|
which
|
||||||
nim-unwrapped-1
|
|
||||||
lsb-release
|
lsb-release
|
||||||
circomCompatPkg
|
circomCompatPkg
|
||||||
fakeGit
|
fakeGit
|
||||||
@ -66,11 +63,23 @@ in pkgs.gcc11Stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
makeFlags = targets ++ [
|
makeFlags = targets ++ [
|
||||||
"V=${toString verbosity}"
|
"V=${toString verbosity}"
|
||||||
"USE_SYSTEM_NIM=${if useSystemNim then "1" else "0"}"
|
"QUICK_AND_DIRTY_COMPILER=${if quickAndDirty then "1" else "0"}"
|
||||||
|
"QUICK_AND_DIRTY_NIMBLE=${if quickAndDirty then "1" else "0"}"
|
||||||
];
|
];
|
||||||
|
|
||||||
configurePhase = ''
|
configurePhase = ''
|
||||||
patchShebangs . > /dev/null
|
patchShebangs . vendor/nimbus-build-system > /dev/null
|
||||||
|
make nimbus-build-system-paths
|
||||||
|
'';
|
||||||
|
|
||||||
|
preBuild = ''
|
||||||
|
pushd vendor/nimbus-build-system/vendor/Nim
|
||||||
|
mkdir dist
|
||||||
|
cp -r ${callPackage ./nimble.nix {}} dist/nimble
|
||||||
|
cp -r ${callPackage ./checksums.nix {}} dist/checksums
|
||||||
|
cp -r ${callPackage ./csources.nix {}} csources_v2
|
||||||
|
chmod 777 -R dist/nimble csources_v2
|
||||||
|
popd
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
|
13
nix/nimble.nix
Normal file
13
nix/nimble.nix
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> { } }:
|
||||||
|
|
||||||
|
let
|
||||||
|
tools = pkgs.callPackage ./tools.nix {};
|
||||||
|
sourceFile = ../vendor/nimbus-build-system/vendor/Nim/koch.nim;
|
||||||
|
in pkgs.fetchFromGitHub {
|
||||||
|
owner = "nim-lang";
|
||||||
|
repo = "nimble";
|
||||||
|
fetchSubmodules = true;
|
||||||
|
rev = tools.findKeyValue "^ +NimbleStableCommit = \"([a-f0-9]+)\".+" sourceFile;
|
||||||
|
# WARNING: Requires manual updates when Nim compiler version changes.
|
||||||
|
hash = "sha256-Rz48sGUKZEAp+UySla+MlsOfsERekuGKw69Tm11fDz8=";
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user