mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-25 09:17:27 +03:00
Merge pull request #17 from unisonweb/topic/nix
Cleaned up build system
This commit is contained in:
commit
512214e237
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
# Haskell
|
||||
dist
|
||||
cabal-dev
|
||||
*.o
|
||||
@ -12,5 +13,11 @@ node/store
|
||||
tags
|
||||
**cabal.sandbox.config
|
||||
.cabal-sandbox/**
|
||||
|
||||
# Nix
|
||||
result
|
||||
|
||||
# Misc
|
||||
*~
|
||||
.DS_Store
|
||||
.virthualenv
|
||||
|
@ -1 +0,0 @@
|
||||
Placeholder for Haskell-based Unison editor directory
|
16
editor/cache
16
editor/cache
@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
|
||||
if ! type -P nix-shell >/dev/null ; then
|
||||
. ~/.nix-profile/etc/profile.d/nix.sh
|
||||
if ! type -P nix-shell >/dev/null ; then
|
||||
echo "It looks like Nix isn't working. Please make sure you can run nix-shell, then retry the $0, or submit an issue at $REPO/issues"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
PLATFORMS=$(eval "echo $(nix-instantiate --eval -E '(import ./nixpkgs {}).stdenv.lib.concatStringsSep " " (import ./.).platforms')")
|
||||
|
||||
ROOTS=$(nix-build -I . -j 8 --no-out-link -E "import ./shell.nix {}")
|
||||
|
||||
nix-copy-closure --gzip --to "$1" $ROOTS
|
@ -1,53 +0,0 @@
|
||||
# This file should not be run directly; it exists to share setup code between the various scripts in try-reflex
|
||||
# Before running this script, DIR should be defined equal to the directory containing this script
|
||||
|
||||
REPO="https://github.com/unisonweb/platform"
|
||||
|
||||
NIXOPTS="--option extra-binary-caches https://ryantrinkle.com:5443/ -j 8"
|
||||
|
||||
trap "echo 'It looks like a problem occurred. Please submit an issue at $REPO/issues'; exit 1" ERR
|
||||
|
||||
echo "If you have any trouble with this script, please submit an issue at $REPO/issues"
|
||||
|
||||
(
|
||||
|
||||
cd "$DIR"
|
||||
|
||||
if [ ! -d /nix ] ; then
|
||||
if ! type -P curl >/dev/null ; then
|
||||
echo "Please make sure that 'curl' is installed and can be run from this shell"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "In order to continue, $0 must install the Nix package manager. This requires root access, so you will be prompted for your password. If you do not wish to continue, just hit Ctrl-C at the password prompt."
|
||||
./installNix.sh
|
||||
fi
|
||||
|
||||
)
|
||||
|
||||
if ! type -P nix-shell >/dev/null ; then
|
||||
. ~/.nix-profile/etc/profile.d/nix.sh
|
||||
if ! type -P nix-shell >/dev/null ; then
|
||||
echo "It looks like Nix isn't working. Please make sure you can run nix-shell, then retry the $0, or submit an issue at $REPO/issues"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
(
|
||||
|
||||
cd "$DIR"
|
||||
|
||||
|
||||
if ! type -P git >/dev/null ; then
|
||||
echo "Please make sure that 'git' is installed and can be run from this shell"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for x in nixpkgs reflex reflex-dom ; do
|
||||
if [ ! "$(ls -A "$x")" ] ; then
|
||||
|
||||
git submodule update --init --recursive "$x"
|
||||
fi
|
||||
done
|
||||
|
||||
)
|
@ -1,51 +1,12 @@
|
||||
let overrideCabal = drv: f: (drv.override (args: args // {
|
||||
mkDerivation = drv: args.mkDerivation (drv // f drv);
|
||||
})) // {
|
||||
overrideScope = scope: overrideCabal (drv.overrideScope scope) f;
|
||||
};
|
||||
nixpkgs = import ./nixpkgs {config.allowUnfree = true;};
|
||||
extendHaskellPackages = haskellPackages: haskellPackages.override {
|
||||
overrides = self: super: {
|
||||
reflex = self.callPackage ./reflex {};
|
||||
reflex-dom = self.callPackage ./reflex-dom {};
|
||||
unison-shared = self.callPackage ../shared {};
|
||||
ghcjs-dom = overrideCabal super.ghcjs-dom (drv: {
|
||||
src = nixpkgs.fetchgit {
|
||||
url = git://github.com/xionite/ghcjs-dom.git;
|
||||
rev = "2d5a0aa64454f2c084b1a7c53cadb59b274d1386";
|
||||
sha256 = "8450b1a0de67cf6bb6c304c244e211331da8f5befdf92c089498c4394c14fcc2";
|
||||
};
|
||||
});
|
||||
active = overrideCabal super.active (drv: {
|
||||
version = "0.1.0.19";
|
||||
sha256 = "1zzzrjpfwxzf0zbz8vcnpfqi7djvrfxglhkvw1s6yj5gcblg2rcw";
|
||||
doCheck = false;
|
||||
});
|
||||
thyme = overrideCabal super.thyme (drv: {
|
||||
doCheck = false;
|
||||
});
|
||||
orgmode-parse = overrideCabal super.orgmode-parse (with self; drv: {
|
||||
version = "0.1.0.4";
|
||||
sha256 = "098zl8nyph459zyla0y2mkqiy78zp74yzadrnwa6xv07i5zs125h";
|
||||
buildDepends = [
|
||||
aeson attoparsec free hashable text thyme unordered-containers
|
||||
];
|
||||
testDepends = [
|
||||
aeson attoparsec hashable HUnit tasty tasty-hunit text thyme
|
||||
unordered-containers
|
||||
];
|
||||
doCheck = false;
|
||||
});
|
||||
HaskellForMaths = overrideCabal super.HaskellForMaths (drv: {
|
||||
version = "0.4.8";
|
||||
sha256 = "0yn2nj6irmj24j1djvnnq26i2lbf9g9x1wdhmcrk519glcn5k64j";
|
||||
buildDepends = [ self.semigroups ] ++ drv.buildDepends; # For some reason, without the spurious import of self.semigroups, HaskellForMaths will fail to build the environment for HaskellForMaths on ghcjs (it works on ghc)
|
||||
});
|
||||
};
|
||||
};
|
||||
in rec {
|
||||
inherit nixpkgs;
|
||||
ghc = extendHaskellPackages nixpkgs.pkgs.haskell-ng.packages.ghc7101;
|
||||
ghcjs = extendHaskellPackages nixpkgs.pkgs.haskell-ng.packages.ghcjs;
|
||||
platforms = [ "ghcjs" ] ++ (if !nixpkgs.stdenv.isDarwin then [ "ghc" ] else []);
|
||||
{ mkDerivation, base, reflex, reflex-dom, stdenv, unison-shared }:
|
||||
mkDerivation {
|
||||
pname = "unison-editor";
|
||||
version = "0.1";
|
||||
src = ./.;
|
||||
isLibrary = true;
|
||||
isExecutable = true;
|
||||
buildDepends = [ base reflex reflex-dom unison-shared ];
|
||||
homepage = "http://unisonweb.org";
|
||||
description = "The Unison programming language and platform";
|
||||
license = stdenv.lib.licenses.mit;
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script installs the Nix package manager on your system by
|
||||
# downloading a binary distribution and running its installer script
|
||||
# (which in turn creates and populates /nix).
|
||||
|
||||
{ # Prevent execution if this script was only partially downloaded
|
||||
|
||||
unpack=nix-binary-tarball-unpack
|
||||
|
||||
require_util() {
|
||||
type "$1" > /dev/null 2>&1 || which "$1" > /dev/null 2>&1 ||
|
||||
oops "you do not have \`$1' installed, which i need to $2"
|
||||
}
|
||||
|
||||
oops() {
|
||||
echo "$0: $@" >&2
|
||||
rm -rf "$unpack"
|
||||
exit 1
|
||||
}
|
||||
|
||||
case "$(uname -s).$(uname -m)" in
|
||||
Linux.x86_64) system=x86_64-linux;;
|
||||
Linux.i?86) system=i686-linux;;
|
||||
Darwin.x86_64) system=x86_64-darwin;;
|
||||
*) oops "sorry, there is no binary distribution of Nix for your platform";;
|
||||
esac
|
||||
|
||||
url="https://nixos.org/releases/nix/nix-1.8/nix-1.8-$system.tar.bz2"
|
||||
|
||||
require_util curl "download the binary tarball"
|
||||
require_util bzcat "decompress the binary tarball"
|
||||
require_util tar "unpack the binary tarball"
|
||||
|
||||
echo "unpacking Nix binary tarball for $system from \`$url'..."
|
||||
mkdir "$unpack" || oops "failed to create \`$unpack' directory"
|
||||
curl -L "$url" | bzcat | tar x -C "$unpack" || oops "failed to unpack \`$url'"
|
||||
|
||||
[ -e "$unpack"/*/install ] ||
|
||||
oops "installation script is missing from the binary tarball!"
|
||||
|
||||
"$unpack"/*/install
|
||||
rm -rf "$unpack"
|
||||
|
||||
} # End of wrapping
|
@ -1,12 +0,0 @@
|
||||
{ mkDerivation, reflex, reflex-dom, stdenv, unison-shared }:
|
||||
mkDerivation {
|
||||
pname = "unison-editor";
|
||||
version = "0.1";
|
||||
src = ./.;
|
||||
isLibrary = true;
|
||||
isExecutable = true;
|
||||
buildDepends = [ reflex reflex-dom unison-shared ];
|
||||
homepage = "http://unisonweb.org";
|
||||
description = "The Unison programming language and platform";
|
||||
license = stdenv.lib.licenses.mit;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
with (import <nixpkgs> {}).pkgs;
|
||||
let modifiedHaskellPackages = haskellngPackages.override {
|
||||
overrides = self: super: {
|
||||
unison-shared = self.callPackage ../shared {};
|
||||
unison-editor = self.callPackage ./. {};
|
||||
};
|
||||
};
|
||||
in modifiedHaskellPackages.unison-editor.env
|
@ -1 +0,0 @@
|
||||
Subproject commit 7f7dbb7c36b0f636f82a25722ebb2e89b43a69b1
|
@ -1,23 +0,0 @@
|
||||
{ haskellPackages, platform }:
|
||||
|
||||
with haskellPackages;
|
||||
|
||||
[
|
||||
##############################################################################
|
||||
# Add general packages here #
|
||||
##############################################################################
|
||||
reflex
|
||||
reflex-dom
|
||||
unison-shared
|
||||
|
||||
] ++ (if platform == "ghcjs" then [
|
||||
##############################################################################
|
||||
# Add ghcjs-only packages here #
|
||||
##############################################################################
|
||||
|
||||
] else []) ++ (if platform == "ghc" then [
|
||||
##############################################################################
|
||||
# Add ghc-only packages here #
|
||||
##############################################################################
|
||||
|
||||
] else [])
|
@ -1 +0,0 @@
|
||||
Subproject commit 2653f40d0ec8ef1d0372e941a8bcde991fd79979
|
@ -1 +0,0 @@
|
||||
Subproject commit 517b1e0de1f113e1df302e4ae6f181bf6ec1642a
|
13
editor/shell
13
editor/shell
@ -1,13 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
|
||||
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
|
||||
. "$DIR/common-setup.sh"
|
||||
|
||||
echo "Entering sandbox..."
|
||||
echo "This rather janky script and setup adapted from <https://github.com/ryantrinkle/try-reflex>"
|
||||
echo "Do 'cd main' then 'cabal configure --ghcjs' and 'cabal build' as normal"
|
||||
echo "Then open dist/build/editor/editor.jsexe/index.html in a browser"
|
||||
|
||||
nix-shell "$DIR/shell.nix" $NIXOPTS "$@"
|
@ -1,15 +1 @@
|
||||
{ }:
|
||||
let this = import ./.;
|
||||
reflexEnv =
|
||||
platform: (builtins.getAttr platform this).ghcWithPackages
|
||||
(p: import ./packages.nix { haskellPackages = p; inherit platform; });
|
||||
in this.nixpkgs.runCommand "shell" {
|
||||
buildCommand = ''
|
||||
echo "$propagatedBuildInputs $buildInputs $nativeBuildInputs $propagatedNativeBuildInputs" > $out
|
||||
'';
|
||||
buildInputs = [
|
||||
this.nixpkgs.nodejs
|
||||
this.nixpkgs.curl
|
||||
this.ghc.cabal-install
|
||||
] ++ builtins.map reflexEnv this.platforms;
|
||||
} ""
|
||||
(import ../shell-common.nix) "editor" [ "ghc7101" "ghcjs" ]
|
||||
|
44
env.nix
Normal file
44
env.nix
Normal file
@ -0,0 +1,44 @@
|
||||
let
|
||||
defaultPkgs = import <nixpkgs> {};
|
||||
|
||||
unison-src = defaultPkgs.fetchgitLocal ./.;
|
||||
|
||||
# Should be a fixpoint, right now clobbers other `packages.*`. see nixpkgs #7659
|
||||
extender = nixpkgs: let
|
||||
|
||||
importer = self: super: dir: {
|
||||
name = "unison-${dir}";
|
||||
value = let
|
||||
src = unison-src + "/${dir}";
|
||||
inputs = { inherit (nixpkgs) stdenv; } // self;
|
||||
vanilla = nixpkgs.stdenv.lib.callPackageWith inputs src {};
|
||||
in nixpkgs.haskell-ng.lib.overrideCabal vanilla (_: { inherit src; });
|
||||
};
|
||||
|
||||
overrider = dirs: {
|
||||
overrides = self: super: with builtins;
|
||||
listToAttrs (map (importer self super) dirs);
|
||||
};
|
||||
|
||||
brokenOverrideHack = super: dirs: let
|
||||
self = super // (overrider dirs).overrides self super;
|
||||
in self;
|
||||
|
||||
in (nixpkgs // {
|
||||
# Should be a fixpoint so we can replace original. see nixpkgs #7659
|
||||
unisonPackages.ghc7101 = brokenOverrideHack nixpkgs.reflexPackages.ghc7101
|
||||
[ "editor" "shared" "node" ];
|
||||
unisonPackages.ghcjs = brokenOverrideHack nixpkgs.reflexPackages.ghcjs
|
||||
[ "editor" "shared" ];
|
||||
});
|
||||
|
||||
try-reflex = defaultPkgs.fetchFromGitHub {
|
||||
owner = "unisonweb";
|
||||
repo = "try-reflex";
|
||||
rev = "663b9bef61f4b87f9c3183d28f0efd1be9b91ae8";
|
||||
sha256 = "1bi3ndxyv57f58xxazmln1dyg5agp1pxyinh6n7hn7x6kh9czcp2";
|
||||
};
|
||||
|
||||
reflexPkgs = import "${try-reflex}/deps" {};
|
||||
|
||||
in extender reflexPkgs
|
@ -7,9 +7,7 @@
|
||||
mkDerivation {
|
||||
pname = "unison-node";
|
||||
version = "0.1";
|
||||
src = builtins.filterSource
|
||||
(path: type: type != "directory" || (baseNameOf path != ".git" && baseNameOf path != "dist"))
|
||||
./.;
|
||||
src = ./.;
|
||||
isLibrary = true;
|
||||
isExecutable = true;
|
||||
buildDepends = [
|
||||
@ -25,4 +23,5 @@ mkDerivation {
|
||||
homepage = "http://unisonweb.org";
|
||||
description = "The Unison programming language and platform";
|
||||
license = stdenv.lib.licenses.mit;
|
||||
doHaddock = false;
|
||||
}
|
||||
|
@ -1,8 +1 @@
|
||||
with (import <nixpkgs> {}).pkgs;
|
||||
let modifiedHaskellPackages = haskellngPackages.override {
|
||||
overrides = self: super: {
|
||||
unison-shared = self.callPackage ../shared {};
|
||||
unison-node = self.callPackage ./. {};
|
||||
};
|
||||
};
|
||||
in modifiedHaskellPackages.unison-node.env
|
||||
(import ../env.nix).unisonPackages.ghc7101.unison-node.env
|
||||
|
@ -4,9 +4,7 @@
|
||||
mkDerivation {
|
||||
pname = "unison-shared";
|
||||
version = "0.1";
|
||||
src = builtins.filterSource
|
||||
(path: type: type != "directory" || (baseNameOf path != ".git" && baseNameOf path != "dist"))
|
||||
./.;
|
||||
src = ./.;
|
||||
buildDepends = [
|
||||
aeson base base64-bytestring bytestring containers mtl text
|
||||
transformers vector
|
||||
|
@ -1,2 +1 @@
|
||||
with (import <nixpkgs> {}).pkgs;
|
||||
(haskellngPackages.callPackage ./. {}).env
|
||||
(import ../shell-common.nix) "shared" [ "ghc7101" "ghcjs" ]
|
||||
|
10
shell-common.nix
Normal file
10
shell-common.nix
Normal file
@ -0,0 +1,10 @@
|
||||
nameRaw: plats: let
|
||||
name = "unison-${nameRaw}";
|
||||
nixpkgs = import ./env.nix;
|
||||
in with builtins; with nixpkgs.stdenv.lib; let
|
||||
f = plat: {
|
||||
name = plat;
|
||||
value = (getAttr name (getAttr plat nixpkgs.unisonPackages)).env;
|
||||
};
|
||||
|
||||
in listToAttrs (map f plats)
|
Loading…
Reference in New Issue
Block a user