nix scaffolding for the rust build is now in place :)

This commit is contained in:
Quinn Dougherty 2022-08-16 18:26:10 -07:00
parent c2818a179b
commit 607bd60021
9 changed files with 1318 additions and 16 deletions

View File

@ -1,12 +1,52 @@
{
"nodes": {
"cargo2nix": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1655189312,
"narHash": "sha256-gpJ57OgIebUpO+7F00VltxSEy6dz2x6HeJ5BcRM8rDA=",
"owner": "cargo2nix",
"repo": "cargo2nix",
"rev": "c149357cc3d17f2849c73eb7a09d07a307cdcfe8",
"type": "github"
},
"original": {
"owner": "cargo2nix",
"ref": "release-0.11.0",
"repo": "cargo2nix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
@ -30,9 +70,24 @@
"type": "github"
}
},
"flake-utils_3": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gentype": {
"inputs": {
"flake-utils": "flake-utils_2",
"flake-utils": "flake-utils_3",
"nixpkgs": [
"nixpkgs"
]
@ -88,11 +143,37 @@
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"cargo2nix": "cargo2nix",
"flake-utils": "flake-utils_2",
"gentype": "gentype",
"hercules-ci-effects": "hercules-ci-effects",
"nixpkgs": "nixpkgs"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": [
"cargo2nix",
"flake-utils"
],
"nixpkgs": [
"cargo2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1653878966,
"narHash": "sha256-T51Gck/vrJZi1m+uTbhEFTRgZmE59sydVONadADv358=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "8526d618af012a923ca116be9603e818b502a8db",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},
"root": "root",

View File

@ -3,6 +3,10 @@
inputs = {
nixpkgs.url = "nixpkgs/nixos-22.05";
cargo2nix = {
url = "github:cargo2nix/cargo2nix/release-0.11.0";
inputs.nixpkgs.follows = "nixpkgs";
};
gentype = {
url = "github:quinn-dougherty/genType";
inputs.nixpkgs.follows = "nixpkgs";
@ -17,7 +21,7 @@
};
};
outputs = { self, nixpkgs, gentype, hercules-ci-effects, flake-utils, ... }:
outputs = { self, nixpkgs, gentype, hercules-ci-effects, cargo2nix, flake-utils, ... }:
let
version = builtins.substring 0 8 self.lastModifiedDate;
commonFn = pkgs: {
@ -26,20 +30,23 @@
which = [ pkgs.which ];
};
gentypeOutputFn = pkgs: gentype.outputs.packages.${pkgs.system}.default;
mcCacheFn = { pkgs, ... }:
import ./nix/squiggle-mcCache.nix { inherit pkgs; };
langFn = { pkgs, ... }:
import ./nix/squiggle-lang.nix {
inherit pkgs commonFn gentypeOutputFn;
inherit pkgs commonFn mcCacheFn gentypeOutputFn;
};
componentsFn = { pkgs, ... }:
import ./nix/squiggle-components.nix { inherit pkgs commonFn langFn; };
import ./nix/squiggle-components.nix { inherit pkgs commonFn mcCacheFn langFn; };
websiteFn = { pkgs, ... }:
import ./nix/squiggle-website.nix {
inherit pkgs commonFn langFn componentsFn;
inherit pkgs commonFn mcCacheFn langFn componentsFn;
};
# local machines
localFlake = { pkgs, ... }:
let
mcCache = mcCacheFn pkgs;
lang = langFn pkgs;
components = componentsFn pkgs;
website = websiteFn pkgs;
@ -54,6 +61,7 @@
# building
packages = flake-utils.lib.flattenTree {
default = website.docusaurus;
mc-wasm = mcCache.mc-cached;
lang-bundle = lang.bundle;
components = components.package-build;
storybook = components.site-build;
@ -62,7 +70,7 @@
# developing
devShells = flake-utils.lib.flattenTree {
default = (import ./nix/shell.nix { inherit pkgs; }).shell;
default = (import ./nix/shell.nix { inherit pkgs cargo2nix; }).shell;
};
};
@ -102,6 +110,7 @@
pkgs = import nixpkgs {
inherit system;
overlays = [
cargo2nix.overlays.default
(final: prev: {
# set the node version here
nodejs = prev.nodejs-18_x;

View File

@ -1,8 +1,18 @@
{ pkgs }:
{ pkgs, cargo2nix }:
with pkgs; {
shell = mkShell {
name = "SQUIGGLE_yarn-wasm-devshell";
buildInputs =
[ wasm-pack cargo yarn nodejs rustup pkg-config openssl nixfmt rustfmt ];
buildInputs = [
wasm-pack
cargo
yarn
nodejs
rustup
pkg-config
openssl
nixfmt
rustfmt
cargo2nix.outputs.packages.${pkgs.system}.default
];
};
}

View File

@ -1,7 +1,8 @@
{ pkgs, commonFn, langFn }:
{ pkgs, commonFn, mcCacheFn, langFn }:
rec {
common = commonFn pkgs;
mcCache = mcCacheFn pkgs;
lang = langFn pkgs;
componentsPackageJson = let
raw = pkgs.lib.importJSON ../packages/components/package.json;

View File

@ -1,7 +1,8 @@
{ pkgs, commonFn, gentypeOutputFn }:
{ pkgs, commonFn, mcCacheFn, gentypeOutputFn }:
rec {
common = commonFn pkgs;
mcCache = mcCacheFn pkgs;
yarn-source = pkgs.mkYarnPackage {
name = "squiggle-lang_source";
src = ../packages/squiggle-lang;
@ -38,6 +39,7 @@ rec {
'';
};
};
packageResolutions."@quri/par-cached-monte-carlo" = mcCache.mc-cached;
};
lint = pkgs.stdenv.mkDerivation {
name = "squiggle-lang-lint";

9
nix/squiggle-mcCache.nix Normal file
View File

@ -0,0 +1,9 @@
{ pkgs }:
rec {
rustPkgs = pkgs.rustBuilder.makePackageSet {
rustVersion = "1.60.0";
packageFun = import ./../packages/squiggle-mc-cached/Cargo.nix;
};
mc-cached = rustPkgs.workspace.squiggle-mc-cached-wasm {};
}

View File

@ -1,7 +1,8 @@
{ pkgs, commonFn, langFn, componentsFn }:
{ pkgs, commonFn, mcCacheFn, langFn, componentsFn }:
rec {
common = commonFn pkgs;
mcCache = mcCacheFn pkgs;
lang = langFn pkgs;
components = componentsFn pkgs;
websitePackageJson = let

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
cargo2nix