Skip to content

Commit

Permalink
Update inputs to nixos-23.11
Browse files Browse the repository at this point in the history
Note: Upgrades Emscripten to 3.1.47
  • Loading branch information
georgestagg committed Nov 30, 2023
1 parent f6c2878 commit bf59cda
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG BASE=ubuntu:22.04
FROM $BASE
ENV DEBIAN_FRONTEND=noninteractive TZ=UTC
ARG EMSCRIPTEN_VERSION=3.1.45
ARG EMSCRIPTEN_VERSION=3.1.47

# Install prerequisites for building LLVM, R, and webR wasm system libraries
RUN apt-get update && apt-get -y install --no-install-recommends \
Expand Down
27 changes: 5 additions & 22 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 13 additions & 19 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
description = "LLVM Flang for WebAssembly";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
# Use this commit to get Emscripten 3.1.45
# See https://www.nixhub.io/packages/emscripten
nixpkgs-emscripten.url =
"github:NixOS/nixpkgs/75a52265bda7fd25e06e3a67dee3f0354e73243c";
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
};

outputs = { self, nixpkgs, nixpkgs-emscripten }:
outputs = { self, nixpkgs }:
let
allSystems =
[ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
Expand All @@ -19,7 +15,6 @@
nixpkgs.lib.genAttrs allSystems (system:
f {
pkgs = import nixpkgs { inherit system; };
pkgs-emscripten = import nixpkgs-emscripten { inherit system; };
inherit system;

flang-source = nixpkgs.legacyPackages.${system}.fetchgit {
Expand All @@ -31,14 +26,15 @@
});

in {
packages = forAllSystems ({ pkgs, pkgs-emscripten, flang-source, ... }: {
packages = forAllSystems ({ pkgs, flang-source, ... }: {
default = pkgs.stdenv.mkDerivation {
name = "flang-wasm";
src = ./.;

nativeBuildInputs = with pkgs; [
cacert # Needed for git clone to work on https repos
cmake
emscripten
git
libxml2
llvmPackages_16.bintools
Expand All @@ -48,18 +44,16 @@
zlib
];

propagatedNativeBuildInputs = [ pkgs-emscripten.emscripten ];

# The automatic configuration by stdenv.mkDerivation tries to do some
# cmake configuration, which causes the build to fail.
dontConfigure = true;

buildPhase = ''
if [ ! -d $(pwd)/.emscripten_cache-${pkgs-emscripten.emscripten.version} ]; then
cp -R ${pkgs-emscripten.emscripten}/share/emscripten/cache/ $(pwd)/.emscripten_cache-${pkgs-emscripten.emscripten.version}
chmod u+rwX -R $(pwd)/.emscripten_cache-${pkgs-emscripten.emscripten.version}
if [ ! -d $(pwd)/.emscripten_cache-${pkgs.emscripten.version} ]; then
cp -R ${pkgs.emscripten}/share/emscripten/cache/ $(pwd)/.emscripten_cache-${pkgs.emscripten.version}
chmod u+rwX -R $(pwd)/.emscripten_cache-${pkgs.emscripten.version}
fi
export EM_CACHE=$(pwd)/.emscripten_cache-${pkgs-emscripten.emscripten.version}
export EM_CACHE=$(pwd)/.emscripten_cache-${pkgs.emscripten.version}
echo emscripten cache dir: $EM_CACHE
CMAKE_BUILD_PARALLEL_LEVEL=$NIX_BUILD_CORES make \
Expand All @@ -75,7 +69,7 @@
});

# Development environment output
devShells = forAllSystems ({ pkgs, pkgs-emscripten, system, ... }: {
devShells = forAllSystems ({ pkgs, system, ... }: {
default = pkgs.mkShell {

# Get the nativeBuildInputs from packages.default
Expand All @@ -97,11 +91,11 @@
# widespread use, we'll be able to use
# https://github.com/NixOS/nix/issues/8034
shellHook = ''
if [ ! -d $(pwd)/.emscripten_cache-${pkgs-emscripten.emscripten.version} ]; then
cp -R ${pkgs-emscripten.emscripten}/share/emscripten/cache/ $(pwd)/.emscripten_cache-${pkgs-emscripten.emscripten.version}
chmod u+rwX -R $(pwd)/.emscripten_cache-${pkgs-emscripten.emscripten.version}
if [ ! -d $(pwd)/.emscripten_cache-${pkgs.emscripten.version} ]; then
cp -R ${pkgs.emscripten}/share/emscripten/cache/ $(pwd)/.emscripten_cache-${pkgs.emscripten.version}
chmod u+rwX -R $(pwd)/.emscripten_cache-${pkgs.emscripten.version}
fi
export EM_CACHE=$(pwd)/.emscripten_cache-${pkgs-emscripten.emscripten.version}
export EM_CACHE=$(pwd)/.emscripten_cache-${pkgs.emscripten.version}
echo emscripten cache dir: $EM_CACHE
'';
};
Expand Down

0 comments on commit bf59cda

Please sign in to comment.