flake (migrated from quinn's fork and added devshell for wasm-pack
This commit is contained in:
parent
a2925dc177
commit
1cd10a9cad
68
flake.lock
Normal file
68
flake.lock
Normal file
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"nodes": {
|
||||
"gentype": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1660002716,
|
||||
"narHash": "sha256-Ig7Dt7d33nNCNlqRGc45uEJTXLRmpCeHrYNOd1AdObc=",
|
||||
"owner": "quinn-dougherty",
|
||||
"repo": "genType",
|
||||
"rev": "c7291db6465ac62800a49bacbe94ce4eb4abcbe0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "quinn-dougherty",
|
||||
"repo": "genType",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"hercules-ci-effects": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1655158531,
|
||||
"narHash": "sha256-5LeaONqA6pgSNeA39gzu5XUipw3mXNZ04LUiy2TVImU=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "hercules-ci-effects",
|
||||
"rev": "bda248e06dc44cbba9f4db350abbb10c3fe3b6fd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "hercules-ci-effects",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1660485612,
|
||||
"narHash": "sha256-sSLW1KaB1adKTJn9+Ja3h3AaS7QCZyhUKiSUStcLg80=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "6512b21eabb4d52e87ea2edcf31a288e67b2e4f8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-unstable",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"gentype": "gentype",
|
||||
"hercules-ci-effects": "hercules-ci-effects",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
313
flake.nix
Normal file
313
flake.nix
Normal file
|
@ -0,0 +1,313 @@
|
|||
{
|
||||
description = "Squiggle CI";
|
||||
# Derived from https://gitlab.com/Silvers_Gw2/Stats_Frontend/-/blob/cc5d783abd54e95363410592c390ca6925462262/flake.nix
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||
gentype = {
|
||||
url = "github:quinn-dougherty/genType";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
hercules-ci-effects = {
|
||||
url = "github:hercules-ci/hercules-ci-effects";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, gentype, hercules-ci-effects, ... }:
|
||||
let
|
||||
# globals
|
||||
system = "x86_64-linux";
|
||||
pkgs = import nixpkgs {
|
||||
system = system;
|
||||
overlays = [
|
||||
hercules-ci-effects.overlay
|
||||
(final: prev: {
|
||||
# set the node version here
|
||||
nodejs = prev.nodejs-16_x;
|
||||
# The override is the only way to get it into mkYarnModules
|
||||
})
|
||||
];
|
||||
};
|
||||
buildInputsCommon = with pkgs; [ nodejs yarn ];
|
||||
prettierCommon = with pkgs.nodePackages; [ prettier ];
|
||||
pkgWhich = [ pkgs.which ];
|
||||
|
||||
# To get prettier into later source trees
|
||||
monorepo-yarnPackage = pkgs.mkYarnPackage {
|
||||
name = "squiggle-monorepo_source";
|
||||
src = ./.;
|
||||
packageJSON = ./package.json;
|
||||
yarnLock = ./yarn.lock;
|
||||
};
|
||||
|
||||
# packages in subrepos
|
||||
lang-yarnPackage = pkgs.mkYarnPackage {
|
||||
name = "squiggle-lang_source";
|
||||
src = ./packages/squiggle-lang;
|
||||
packageJSON = ./packages/squiggle-lang/package.json;
|
||||
yarnLock = ./yarn.lock;
|
||||
# extraBuildInputs = prettierCommon;
|
||||
pkgConfig = {
|
||||
rescript = {
|
||||
buildInputs = pkgWhich ++ [ pkgs.gcc_multi ];
|
||||
postInstall = ''
|
||||
echo "PATCHELF'ING RESCRIPT EXECUTABLES (INCL NINJA)"
|
||||
# Patching interpreter for linux/*.exe's
|
||||
THE_LD=$(patchelf --print-interpreter $(which mkdir))
|
||||
patchelf --set-interpreter $THE_LD linux/*.exe && echo "- patched interpreter for linux/*.exe's"
|
||||
|
||||
# Replacing needed shared library for linux/ninja.exe
|
||||
THE_SO=$(find /nix/store/*/lib64 -name libstdc++.so.6 | head -n 1)
|
||||
patchelf --replace-needed libstdc++.so.6 $THE_SO linux/ninja.exe && echo "- replaced needed for linux/ninja.exe"
|
||||
'';
|
||||
};
|
||||
bisect_ppx = {
|
||||
buildInputs =
|
||||
pkgWhich; # ++ (with pkgs; [ ocaml nodePackages.esy ocamlPackages.bisect_ppx ]);
|
||||
postInstall = ''
|
||||
echo "PATCHELF'ING BISECT_PPX EXECUTABLE"
|
||||
THE_LD=$(patchelf --print-interpreter $(which mkdir))
|
||||
patchelf --set-interpreter $THE_LD bin/linux/ppx
|
||||
patchelf --set-interpreter $THE_LD bin/linux/bisect-ppx-report
|
||||
'';
|
||||
};
|
||||
gentype = {
|
||||
postInstall = ''
|
||||
mv gentype.exe ELFLESS-gentype.exe
|
||||
cp ${
|
||||
gentype.outputs.defaultPackage."${system}"
|
||||
}/GenType.exe gentype.exe
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
lang-lint = pkgs.stdenv.mkDerivation {
|
||||
name = "squiggle-lang-lint";
|
||||
src = lang-yarnPackage
|
||||
+ "/libexec/@quri/squiggle-lang/deps/@quri/squiggle-lang";
|
||||
buildInputs = buildInputsCommon ++ prettierCommon;
|
||||
buildPhase = ''
|
||||
yarn lint:prettier
|
||||
yarn lint:rescript
|
||||
'';
|
||||
installPhase = "mkdir -p $out";
|
||||
};
|
||||
lang-build = pkgs.stdenv.mkDerivation {
|
||||
name = "squiggle-lang-build";
|
||||
# `peggy` is in the `node_modules` that's adjacent to `deps`.
|
||||
src = lang-yarnPackage + "/libexec/@quri/squiggle-lang";
|
||||
buildInputs = buildInputsCommon;
|
||||
buildPhase = ''
|
||||
mv node_modules deps
|
||||
pushd deps/@quri/squiggle-lang
|
||||
yarn --offline build:peggy
|
||||
yarn --offline build:rescript
|
||||
yarn --offline build:typescript
|
||||
|
||||
# custom gitignore so that the flake keeps build artefacts
|
||||
mv .gitignore GITIGNORE
|
||||
sed -i /Reducer_Peggy_GeneratedParser.js/d GITIGNORE
|
||||
sed -i /\*.bs.js/d GITIGNORE
|
||||
sed -i /\*.gen.ts/d GITIGNORE
|
||||
sed -i /\*.gen.tsx/d GITIGNORE
|
||||
sed -i /\*.gen.js/d GITIGNORE
|
||||
sed -i /helpers.js/d GITIGNORE
|
||||
|
||||
popd
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
# mkdir -p $out/node_modules
|
||||
mv deps/@quri/squiggle-lang/GITIGNORE deps/@quri/squiggle-lang/.gitignore
|
||||
|
||||
# annoying hack because permissions on transitive dependencies later on
|
||||
mv deps/@quri/squiggle-lang/node_modules deps/@quri/squiggle-lang/NODE_MODULES
|
||||
mv deps/node_modules deps/@quri/squiggle-lang
|
||||
|
||||
# the proper install phase
|
||||
cp -r deps/@quri/squiggle-lang/. $out
|
||||
'';
|
||||
};
|
||||
lang-test = pkgs.stdenv.mkDerivation {
|
||||
name = "squiggle-lang-test";
|
||||
src = lang-build;
|
||||
buildInputs = buildInputsCommon;
|
||||
buildPhase = ''
|
||||
yarn --offline test
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r . $out
|
||||
'';
|
||||
};
|
||||
lang-bundle = pkgs.stdenv.mkDerivation {
|
||||
name = "squiggle-lang-bundle";
|
||||
src = lang-test;
|
||||
buildInputs = buildInputsCommon;
|
||||
buildPhase = ''
|
||||
yarn --offline bundle
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r dist $out
|
||||
cp *.json $out/dist
|
||||
'';
|
||||
};
|
||||
|
||||
componentsPackageJson =
|
||||
let
|
||||
raw = pkgs.lib.importJSON ./packages/components/package.json;
|
||||
modified = pkgs.lib.recursiveUpdate raw { dependencies.react-dom = "^18.2.0"; };
|
||||
packageJsonString = builtins.toJSON modified;
|
||||
in
|
||||
pkgs.writeText "packages/components/patched-package.json" packageJsonString;
|
||||
components-yarnPackage = pkgs.mkYarnPackage {
|
||||
name = "squiggle-components_source";
|
||||
buildInputs = buildInputsCommon;
|
||||
src = ./packages/components;
|
||||
packageJSON = componentsPackageJson;
|
||||
yarnLock = ./yarn.lock;
|
||||
packageResolutions."@quri/squiggle-lang" = lang-build;
|
||||
};
|
||||
components-lint = pkgs.stdenv.mkDerivation {
|
||||
name = "squiggle-components-lint";
|
||||
src = components-yarnPackage
|
||||
+ "/libexec/@quri/squiggle-components/deps/@quri/squiggle-components";
|
||||
buildInputs = buildInputsCommon ++ prettierCommon;
|
||||
buildPhase = "yarn lint";
|
||||
installPhase = "mkdir -p $out";
|
||||
};
|
||||
components-package-build = pkgs.stdenv.mkDerivation {
|
||||
name = "squiggle-components-package-build";
|
||||
src = components-yarnPackage + "/libexec/@quri/squiggle-components";
|
||||
buildInputs = buildInputsCommon;
|
||||
buildPhase = ''
|
||||
cp -r node_modules/@quri/squiggle-lang deps/@quri
|
||||
pushd deps/@quri/squiggle-components
|
||||
|
||||
yarn --offline build:cjs
|
||||
yarn --offline build:css
|
||||
popd
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
|
||||
# annoying hack because permissions on transitive dependencies later on
|
||||
mv deps/@quri/squiggle-components/node_modules deps/@quri/squiggle-components/NODE_MODULES
|
||||
mv node_modules deps/@quri/squiggle-components
|
||||
|
||||
# patching .gitignore so flake keeps build artefacts
|
||||
sed -i /dist/d deps/@quri/squiggle-components/.gitignore
|
||||
cp -r deps/@quri/squiggle-components/. $out
|
||||
'';
|
||||
};
|
||||
components-site-build = pkgs.stdenv.mkDerivation {
|
||||
name = "squiggle-components-storybook";
|
||||
src = components-package-build;
|
||||
buildInputs = buildInputsCommon;
|
||||
buildPhase = "yarn build:storybook";
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
|
||||
# patching .gitignore so flake keeps build artefacts
|
||||
sed -i /\build/d .gitignore
|
||||
sed -i /storybook-static/d .gitignore
|
||||
'';
|
||||
};
|
||||
|
||||
websitePackageJson =
|
||||
let
|
||||
raw = pkgs.lib.importJSON ./packages/website/package.json;
|
||||
modified = pkgs.lib.recursiveUpdate raw {
|
||||
dependencies.postcss-import = "^14.1.0";
|
||||
dependencies.tailwindcss = "^3.1.8";
|
||||
};
|
||||
packageJsonString = builtins.toJSON modified;
|
||||
in
|
||||
pkgs.writeText "packages/website/patched-package.json" packageJsonString;
|
||||
website-yarnPackage = pkgs.mkYarnPackage {
|
||||
name = "squiggle-website_source";
|
||||
src = ./packages/website;
|
||||
packageJSON = websitePackageJson;
|
||||
yarnLock = ./yarn.lock;
|
||||
packageResolutions."@quri/squiggle-lang" = lang-build;
|
||||
packageResolutions."@quri/squiggle-components" =
|
||||
components-package-build;
|
||||
workspaceDependencies = [ lang-yarnPackage components-yarnPackage ];
|
||||
};
|
||||
website-lint = pkgs.stdenv.mkDerivation {
|
||||
name = "squiggle-website-lint";
|
||||
buildInputs = buildInputsCommon ++ prettierCommon;
|
||||
src = website-yarnPackage
|
||||
+ "/libexec/squiggle-website/deps/squiggle-website";
|
||||
buildPhase = "yarn --offline lint";
|
||||
installPhase = "mkdir -p $out";
|
||||
};
|
||||
website = pkgs.stdenv.mkDerivation {
|
||||
name = "squiggle-website";
|
||||
buildInputs = buildInputsCommon;
|
||||
src = website-yarnPackage + "/libexec/squiggle-website";
|
||||
buildPhase = ''
|
||||
pushd deps/squiggle-website
|
||||
yarn --offline build
|
||||
popd
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r $src/build $out
|
||||
'';
|
||||
};
|
||||
in rec {
|
||||
|
||||
checks.${system} = {
|
||||
lang-lint = lang-lint;
|
||||
lang-test = lang-test;
|
||||
components-lint = components-lint;
|
||||
docusaurus-lint = website-lint;
|
||||
};
|
||||
packages.${system} = {
|
||||
default = website;
|
||||
lang-bundle = lang-bundle;
|
||||
components = components-package-build;
|
||||
storybook = components-site-build;
|
||||
docs-site = website;
|
||||
# tmp = {
|
||||
# lang-build = lang-build;
|
||||
# components-yarnPkg = components-yarnPackage;
|
||||
# components-lint = components-lint;
|
||||
# };
|
||||
};
|
||||
|
||||
# herc
|
||||
herculesCI.onPush = {
|
||||
lang.outputs = {
|
||||
squiggle-lang-lint = checks.${system}.lang-lint;
|
||||
squiggle-lang-test = checks.${system}.lang-test;
|
||||
squiggle-lang-build = lang-build;
|
||||
squiggle-lang-bundle = packages.${system}.lang-bundle;
|
||||
};
|
||||
components.outputs = {
|
||||
squiggle-components = packages.${system}.components;
|
||||
squiggle-components-lint = checks.${system}.components-lint;
|
||||
squiggle-components-storybook = packages.${system}.storybook;
|
||||
};
|
||||
docs-site.outputs = {
|
||||
squiggle-website = packages.${system}.docs-site;
|
||||
docusaurus-lint = checks.${system}.docusaurus-lint;
|
||||
};
|
||||
};
|
||||
devShells.${system}.default = pkgs.mkShell {
|
||||
name = "squiggle-wasm-development-shell";
|
||||
buildInputs = with pkgs; [
|
||||
wasm-pack
|
||||
cargo
|
||||
cargo-generate
|
||||
yarn
|
||||
rustup
|
||||
pkg-config
|
||||
openssl
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user