Skip to content

Instantly share code, notes, and snippets.

@mgsloan
mgsloan / MIT-LICENSE.md
Created November 26, 2017 08:22
MIT license applies to all my public gists

All public gists which do not specify a different license, listed at https://gist.github.com/mgsloan, are covered by the MIT License, http://www.opensource.org/licenses/mit-license.php

Copyright 2017 Michael Sloan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT H

@mgsloan
mgsloan / pre-commit
Last active November 26, 2017 10:48
pre-commit hook to ensure no ignored files are in the commit (even if you used "git add --force")
#!/bin/sh
# Copyright 2017 Michael Sloan
# This file is MIT licensed.
changed="$(git diff --name-only --cached)"
changed_and_ignored="$(echo "$changed" | git check-ignore --stdin --no-index | tr -d '[:space:]')"
if test -z "$changed_and_ignored" ;
then
fn main() {
let mut x = 1;
wat(|i| { x += i; return x; });
println!("{}", x);
}
fn wat<F>(f: F) -> u32 where F: FnMut(u32) -> u32 {
foo(f)
}
@mgsloan
mgsloan / a_summary
Last active February 5, 2016 14:28
Using new-stack to build old-stack, using it to build itself, and then using old-stack to build new-stack. new-stack is stack-1.0.3, the current release, and old-stack is stack-0.1.0.0, the first stable release 7 months ago.
mgsloan@computer:~/fpco/stack$ git checkout v0.1.0.0
...
mgsloan@computer:~/fpco/stack$ stack build
...
Installing executable(s) in
/home/mgsloan/fpco/stack/.stack-work/install/x86_64-linux/lts-2.9/7.8.4/bin
Registering stack-0.1.0.0...
Completed 123 action(s).
cd ~/.stack/programs/x86_64-linux
mkdir ghc-7.10.2-temp
cd ghc-7.10.2-temp
tar -xf ../ghc-7.10.2.tar.xz
make configure --prefix=~/.stack/programs/x86_64-linux/ghc-7.10.2
make install
cd ../
rm -r ghc-7.10.2-temp
echo "installed" > ghc-7.10.2.installed
diff --git a/src/Stack/Build.hs b/src/Stack/Build.hs
index bb535e4..9710840 100644
--- a/src/Stack/Build.hs
+++ b/src/Stack/Build.hs
@@ -150,9 +150,8 @@ withLoadPackage menv inner = do
{ packageConfigEnableTests = False
, packageConfigEnableBenchmarks = False
, packageConfigFlags = flags
- , packageConfigGhcVersion = envConfigGhcVersion econfig
+ , packageConfigCompilerVersion = envConfigCompilerVersion econfig
diff --git a/src/Stack/Build.hs b/src/Stack/Build.hs
index bb535e4..9710840 100644
--- a/src/Stack/Build.hs
+++ b/src/Stack/Build.hs
@@ -150,9 +150,8 @@ withLoadPackage menv inner = do
{ packageConfigEnableTests = False
, packageConfigEnableBenchmarks = False
, packageConfigFlags = flags
- , packageConfigGhcVersion = envConfigGhcVersion econfig
+ , packageConfigCompilerVersion = envConfigCompilerVersion econfig
diff --git a/src/Stack/Build.hs b/src/Stack/Build.hs
index 9b00447..50b8d61 100644
--- a/src/Stack/Build.hs
+++ b/src/Stack/Build.hs
@@ -53,7 +53,7 @@ build :: M env m
=> (Set (Path Abs File) -> IO ()) -- ^ callback after discovering all local files
-> BuildOpts
-> m ()
-build setLocalFiles bopts = do
+build setLocalFiles bopts = errorWhenUnsupported bopts $ do
diff --git a/src/Stack/Build.hs b/src/Stack/Build.hs
index 9b00447..50b8d61 100644
--- a/src/Stack/Build.hs
+++ b/src/Stack/Build.hs
@@ -53,7 +53,7 @@ build :: M env m
=> (Set (Path Abs File) -> IO ()) -- ^ callback after discovering all local files
-> BuildOpts
-> m ()
-build setLocalFiles bopts = do
+build setLocalFiles bopts = errorWhenUnsupported bopts $ do
diff --git a/yesod-bin/BuildProgram.hs b/yesod-bin/BuildProgram.hs
new file mode 100644
index 0000000..2bdf11b
--- /dev/null
+++ b/yesod-bin/BuildProgram.hs
@@ -0,0 +1,50 @@
+module BuildProgram where
+
+import System.Exit (ExitCode (..), exitWith)
+import System.Process (ProcessHandle, createProcess, getProcessExitCode, proc)