tried to get the nixification to work

This commit is contained in:
Quinn Dougherty 2022-08-16 22:22:03 -07:00
parent 07c3004c82
commit 84f0cfd3b0
6 changed files with 87 additions and 24 deletions

View File

@ -126,6 +126,26 @@
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1659610603,
"narHash": "sha256-LYgASYSPYo7O71WfeUOaEUzYfzuXm8c8eavJcel+pfI=",
"owner": "nix-community",
"repo": "naersk",
"rev": "c6a45e4277fa58abd524681466d3450f896dc094",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1660496378,
@ -147,6 +167,7 @@
"flake-utils": "flake-utils_2",
"gentype": "gentype",
"hercules-ci-effects": "hercules-ci-effects",
"naersk": "naersk",
"nixpkgs": "nixpkgs"
}
},

View File

@ -3,6 +3,10 @@
inputs = {
nixpkgs.url = "nixpkgs/nixos-22.05";
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
cargo2nix = {
url = "github:cargo2nix/cargo2nix/release-0.11.0";
inputs.nixpkgs.follows = "nixpkgs";
@ -21,18 +25,33 @@
};
};
outputs = { self, nixpkgs, gentype, hercules-ci-effects, cargo2nix
outputs = { self, nixpkgs, gentype, hercules-ci-effects, naersk, cargo2nix
, flake-utils, ... }:
let
version = builtins.substring 0 8 self.lastModifiedDate;
crossSystemForWasmPkgs = {
config = "wasm32-unknown-wasi-unknown";
system = "wasm32-wasi";
useLLVM = true;
};
overlays = [
cargo2nix.overlays.default
(final: prev: {
# set the node version here
nodejs = prev.nodejs-18_x;
# The override is the only way to get it into mkYarnModules
})
];
commonFn = pkgs: {
buildInputs = with pkgs; [ nodejs yarn ];
prettier = with pkgs.nodePackages; [ prettier ];
which = [ pkgs.which ];
};
naerskFn = { pkgs, rust, ... }: pkgs.callPackage naersk { cargo = rust; rustc = rust; };
gentypeOutputFn = pkgs: gentype.outputs.packages.${pkgs.system}.default;
mcFn = { pkgs, ... }:
import ./nix/squiggle-mc.nix { inherit pkgs commonFn; };
mcFn = { pkgs, wasmPkgs, ... }:
import ./nix/squiggle-mc.nix { inherit pkgs wasmPkgs commonFn naerskFn; };
langFn = { pkgs, ... }:
import ./nix/squiggle-lang.nix {
inherit pkgs commonFn mcFn gentypeOutputFn;
@ -47,9 +66,9 @@
};
# local machines
localFlake = { pkgs, ... }:
localFlake = { pkgs, wasmPkgs, ... }:
let
mc = mcFn pkgs;
mc = mcFn { inherit pkgs wasmPkgs; };
lang = langFn pkgs;
components = componentsFn pkgs;
website = websiteFn pkgs;
@ -67,6 +86,7 @@
packages = flake-utils.lib.flattenTree {
default = website.docusaurus;
mc-wasm = mc.lib;
mc-wasm2 = mc.lib2;
mc-wasm-pkg = mc.webpack-build-pkg;
lang-bundle = lang.bundle;
components = components.package-build;
@ -85,8 +105,9 @@
herc = let
hciSystem = "x86_64-linux";
hciPkgs = import nixpkgs { system = hciSystem; };
hciPkgsWasm = import nixpkgs { system = hciSystem; crossSystem = crossSystemForWasmPkgs; overlays = overlays; };
effects = hercules-ci-effects.lib.withPkgs hciPkgs;
mc = mcFn hciPkgs;
mc = mcFn hciPkgs hciPkgsWasm;
lang = langFn hciPkgs;
components = componentsFn hciPkgs;
website = websiteFn hciPkgs;
@ -122,15 +143,13 @@
# globals
pkgs = import nixpkgs {
inherit system;
overlays = [
cargo2nix.overlays.default
(final: prev: {
# set the node version here
nodejs = prev.nodejs-18_x;
# The override is the only way to get it into mkYarnModules
})
];
overlays = overlays;
};
pkgsWasm = import nixpkgs {
inherit system;
overlays = overlays;
crossSystem = crossSystemForWasmPkgs;
};
in localFlake pkgs) // herc;
in localFlake { pkgs = pkgs; wasmPkgs = pkgsWasm; }) // herc;
}

View File

@ -9,7 +9,7 @@ with pkgs; {
nodejs
rustup
pkg-config
openssl
libressl
nixfmt
rustfmt
cargo2nix.outputs.packages.${pkgs.system}.default

View File

@ -1,11 +1,30 @@
{ pkgs, commonFn }:
{ pkgs, wasmPkgs, commonFn, naerskFn }:
rec {
common = commonFn pkgs;
rustPkgs = pkgs.rustBuilder.makePackageSet {
rustVersion = "1.60.0";
packageFun = import ../packages/mc/Cargo.nix;
rustVersion = "1.61.0";
wasmTarget = "wasm32-unknown-unknown";
rust = pkgs.rust-bin.stable.${rustVersion}.default.override {
targets = [ wasmTarget ];
};
naersk = naerskFn { inherit pkgs rust; };
mc-pkg = naersk.buildPackage {
src = ../packages/mc;
copyLibs = true;
copyBins = true;
CARGO_BUILD_TARGET = wasmTarget;
nativeBuildInputs = common.buildInputs;
};
lib2 = mc-pkg;
rustPkgsWasm = wasmPkgs.rustBuilder.makePackageSet {
rustVersion = rustVersion;
packageFun = import ../packages/mc/Cargo.nix;
target = wasmTarget;
};
lib = (rustPkgsWasm.workspace.quri-squiggle-mc { }).out;
yarn-source = pkgs.mkYarnPackage {
name = "squiggle-mc_yarnsource";
buildInputs = common.buildInputs;
@ -20,7 +39,6 @@ rec {
buildPhase = "rustfmt --check src";
installPhase = "mkdir -p $out";
};
lib = rustPkgs.workspace.quri-squiggle-mc { };
webpack-build-pkg = pkgs.stdenv.mkDerivation {
name = "squiggle-mc-build";
src = yarn-source + "/libexec/@quri/squiggle-mc";

View File

@ -10,6 +10,13 @@ categories = ["wasm", "Monte Carlo"]
readme = "README.md"
edition = "2018"
[package.metadata.wasm-pack.profile.dev]
wasm-opt = false
[package.metadata.wasm-pack.profile.profiling]
wasm-opt = false
[package.metadata.wasm-pack.profile.release]
wasm-opt = false
[lib]
crate-type = ["cdylib"]
@ -21,6 +28,7 @@ lto = true
[features]
# If you uncomment this line, it will enable `wee_alloc`:
default = ["wee_alloc"]
# wasm-bindgen = [ "instant/wasm-bindgen" ]
[dependencies]
# The `wasm-bindgen` crate provides the bare minimum functionality needed

View File

@ -2504,9 +2504,6 @@
resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.21.tgz#5de5a2385a35309427f6011992b544514d559aa1"
integrity sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==
"@quri/par-cached-monte-carlo@file:packages/squiggle-mc-cached/pkg":
version "0.0.0"
"@quri/squiggle-components@^0.2.23":
version "0.2.24"
resolved "https://registry.yarnpkg.com/@quri/squiggle-components/-/squiggle-components-0.2.24.tgz#16a2d72fb16f46a0bf71388c85d1238927676923"