2020-06-18 22:41:01 +00:00
|
|
|
{ pkgs ? import <nixpkgs> { }
|
2022-03-30 18:45:35 +00:00
|
|
|
, version ? pkgs.lib.removeSuffix "\n" (builtins.readFile ../VERSION)
|
2020-03-28 04:09:01 +00:00
|
|
|
}:
|
|
|
|
let
|
2020-03-28 23:02:40 +00:00
|
|
|
package = builtins.fromJSON (builtins.readFile ./package.json);
|
2020-06-18 22:41:01 +00:00
|
|
|
yarnPkg = pkgs.yarn2nix-moretea.mkYarnPackage rec {
|
2020-03-28 23:02:40 +00:00
|
|
|
name = "${package.name}-yarn-${package.version}";
|
|
|
|
src = null;
|
|
|
|
dontUnpack = true;
|
|
|
|
packageJSON = ./package.json;
|
|
|
|
yarnLock = ./yarn.lock;
|
|
|
|
preConfigure = ''
|
|
|
|
mkdir ${package.name}
|
|
|
|
cd ${package.name}
|
|
|
|
ln -s ${packageJSON} ./package.json
|
|
|
|
ln -s ${yarnLock} ./yarn.lock
|
|
|
|
'';
|
|
|
|
yarnPreBuild = ''
|
|
|
|
mkdir -p $HOME/.node-gyp/${pkgs.nodejs.version}
|
|
|
|
echo 9 > $HOME/.node-gyp/${pkgs.nodejs.version}/installVersion
|
|
|
|
ln -sfv ${pkgs.nodejs}/include $HOME/.node-gyp/${pkgs.nodejs.version}
|
|
|
|
'';
|
|
|
|
publishBinsFor =
|
2020-06-18 22:41:01 +00:00
|
|
|
[
|
|
|
|
"webpack"
|
2020-03-28 23:02:40 +00:00
|
|
|
"webpack-dev-server"
|
|
|
|
];
|
|
|
|
};
|
2020-06-18 22:41:01 +00:00
|
|
|
in
|
|
|
|
pkgs.stdenv.mkDerivation {
|
2020-03-28 23:02:40 +00:00
|
|
|
name = "${package.name}-${package.version}";
|
2020-03-28 04:09:01 +00:00
|
|
|
src = pkgs.lib.cleanSource ./.;
|
|
|
|
|
2021-01-23 16:25:43 +00:00
|
|
|
preferLocalBuild = true;
|
|
|
|
|
2020-03-28 04:09:01 +00:00
|
|
|
buildInputs =
|
2020-06-18 22:41:01 +00:00
|
|
|
[
|
|
|
|
yarnPkg
|
2020-03-28 23:02:40 +00:00
|
|
|
] ++
|
2020-03-28 04:09:01 +00:00
|
|
|
(with pkgs; [
|
|
|
|
nodejs
|
2020-03-28 23:02:40 +00:00
|
|
|
elm2nix
|
2020-03-28 04:09:01 +00:00
|
|
|
]) ++
|
|
|
|
(with pkgs.nodePackages; [
|
|
|
|
yarn
|
|
|
|
]) ++
|
|
|
|
(with pkgs.elmPackages; [
|
|
|
|
elm
|
|
|
|
elm-format
|
2020-03-30 07:27:22 +00:00
|
|
|
elm-language-server
|
|
|
|
elm-test
|
|
|
|
elm-analyse
|
2020-03-28 04:09:01 +00:00
|
|
|
]);
|
|
|
|
|
2020-06-12 12:29:04 +00:00
|
|
|
configurePhase = pkgs.elmPackages.fetchElmDeps {
|
|
|
|
elmPackages = import ./elm-srcs.nix;
|
|
|
|
elmVersion = pkgs.elmPackages.elm.version;
|
|
|
|
registryDat = ./registry.dat;
|
|
|
|
};
|
2020-03-28 23:02:40 +00:00
|
|
|
|
|
|
|
patchPhase = ''
|
|
|
|
rm -rf node_modules
|
|
|
|
ln -sf ${yarnPkg}/libexec/${package.name}/node_modules .
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
# Yarn writes cache directories etc to $HOME.
|
|
|
|
export HOME=$PWD/yarn_home
|
2020-06-18 22:41:01 +00:00
|
|
|
sed -i -e "s|process.env.ELASTICSEARCH_MAPPING_SCHEMA_VERSION|${version}|" src/index.js
|
2020-03-28 23:02:40 +00:00
|
|
|
yarn prod
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp -R ./dist/* $out/
|
2020-06-12 12:29:04 +00:00
|
|
|
cp netlify.toml $out/
|
2020-03-28 23:02:40 +00:00
|
|
|
'';
|
2020-03-28 04:09:01 +00:00
|
|
|
shellHook = ''
|
2022-03-30 18:45:35 +00:00
|
|
|
rm -rf frontend/node_modules
|
|
|
|
ln -sf ${yarnPkg}/libexec/${package.name}/node_modules frontend/
|
|
|
|
export PATH=$PWD/frontend/node_modules/.bin:$PATH
|
2020-06-18 22:41:01 +00:00
|
|
|
export ELASTICSEARCH_MAPPING_SCHEMA_VERSION=${version}
|
2020-03-28 23:02:40 +00:00
|
|
|
echo "============================"
|
2022-03-30 18:45:35 +00:00
|
|
|
echo "= To develop the frontend run: cd frontend && yarn dev ="
|
2020-03-28 23:02:40 +00:00
|
|
|
echo "============================"
|
2020-03-28 04:09:01 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
}
|