Skip to content

Instantly share code, notes, and snippets.

@cryptix
Created April 9, 2021 09:30
Show Gist options
  • Save cryptix/9dc8806fe44f266d47f550b23b703ff8 to your computer and use it in GitHub Desktop.
Save cryptix/9dc8806fe44f266d47f550b23b703ff8 to your computer and use it in GitHub Desktop.
NixOS Shell for cabal-desktop development
with import <nixpkgs> {};
with pkgs;
let cabalEnv = buildEnv {
name = "cabal-desktop-env";
paths = [
# npm sodium stuff
clang
gnumake
libtool
autoconf
automake
m4
# electron stuff
alsaLib
atk
at-spi2-atk
at-spi2-core
binutils
bzip2
cairo
cups
dbus.lib
expat
fontconfig
freetype
fuse
gdk_pixbuf
glib
glibc
gtk3-x11
libuuid
libcap
libgnome_keyring3
libgpgerror
libnotify
libsodium
libappindicator-gtk3
nspr
nss
pango
python
readline
systemd
udev
xdg_utils
xorg.libX11
xorg.libXScrnSaver
xorg.libXcomposite
xorg.libXcursor
xorg.libXdamage
xorg.libXext
xorg.libXfixes
xorg.libXi
xorg.libXrandr
xorg.libXrender
xorg.libXtst
xorg.libxcb
zlib
];
extraOutputsToInstall = [ "lib" "dev" "out" ];
}; in
(pkgs.buildFHSUserEnv {
name = "cabal-desktop-chroot";
targetPkgs = pkgs: (with pkgs; [
nodejs-14_x
git
unzip
cabalEnv
]);
extraOutputsToInstall = [ "lib" "dev" "out" ];
extraBuildCommands = ''
(cd usr/lib64 && ln -sv libbz2.so.1.0.* libbz2.so.1.0)
'';
# see to compile native modules for electron and not the nodejs of the env
# https://www.electronjs.org/docs/tutorial/using-native-node-modules#using-npm
profile = ''
export npm_config_cache="/tmp/cabal-desktop-npm-cache/"
export npm_config_devdir="/tmp/cabal-desktop-gyp/"
export ELECTRON_CACHE="/tmp/cabal-desktop-electron-cache/"
export npm_config_target=7.1.13 # from package.json
# The architecture of Electron, see https://electronjs.org/docs/tutorial/support#supported-platforms
# for supported architectures.
export npm_config_arch=x64
export npm_config_target_arch=x64
# Download headers for Electron.
export npm_config_disturl=https://electronjs.org/headers
# Tell node-pre-gyp that we are building for Electron.
export npm_config_runtime=electron
# Tell node-pre-gyp to build module from source code.
export npm_config_build_from_source=true
export CC=clang
export CXX=clang++
export CFLAGS="$NIX_CFLAGS_COMPILE"
export CXXFLAGS="$NIX_CFLAGS_COMPILE"
export LDFLAGS="$NIX_LDFLAGS_BEFORE"
'';
}).env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment