Skip to content

allow the user to specifiy a custom STACK_ROOT directory #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/check-nix-is-updated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ fail_stack2nix_check() {
exit 1
}

\time ~/.local/bin/stack2nix --hackage-snapshot 2018-09-04T08:56:04Z . > $scriptDir/../stack2nix.nix
\time /usr/bin/env stack2nix --hackage-snapshot 2018-09-04T08:56:04Z . > $scriptDir/../stack2nix.nix

git diff --text --exit-code || fail_stack2nix_check
9 changes: 8 additions & 1 deletion src/Stack2nix/External/Stack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,19 @@ import System.Directory (canonicalizePat
import System.FilePath (makeRelative,
(</>))
import Text.PrettyPrint.HughesPJClass (Doc)
import System.Environment (lookupEnv)

data PackageRef
= HackagePackage PackageIdentifierRevision
| NonHackagePackage PackageIdentifier (PackageLocation FilePath)
deriving (Eq, Show)

getStackRoot :: IO String
getStackRoot = fromMaybe defaultStackRoot <$> lookupEnv stackRootEnv
where
stackRootEnv = "S2N_STACK_ROOT"
defaultStackRoot = "/tmp/s2n"

genNixFile :: Args -> Version -> FilePath -> Maybe String -> Maybe String -> DB.HackageDB -> PackageRef -> IO (Either Doc Derivation)
genNixFile args ghcVersion baseDir uri argRev hackageDB pkgRef = do
cwd <- getCurrentDirectory
Expand Down Expand Up @@ -143,7 +150,7 @@ runPlan :: FilePath
-> Args
-> IO ()
runPlan baseDir remoteUri args@Args{..} = do
let stackRoot = "/tmp/s2n"
stackRoot <- getStackRoot
createDirectoryIfMissing True stackRoot
let globals = globalOpts baseDir stackRoot args
let stackFile = baseDir </> argStackYaml
Expand Down
11 changes: 8 additions & 3 deletions stack2nix.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated using stack2nix 0.2.
# Generated using stack2nix 0.2.1.

{ pkgs ? (import <nixpkgs> {})
, compiler ? pkgs.haskell.packages.ghc843
Expand All @@ -11,6 +11,7 @@ let
self: {
array = null;
base = null;
bin-package-db = null;
binary = null;
bytestring = null;
containers = null;
Expand Down Expand Up @@ -6115,6 +6116,10 @@ inherit (pkgs.xorg) libXfixes;};
];
doHaddock = false;
doCheck = false;
preCheck = ''
export PATH="$PWD/dist/build/cabal2nix:$PATH"
export HOME="$TMPDIR/home"
'';
homepage = "https://github.com/nixos/cabal2nix#readme";
description = "Convert Cabal files into Nix build instructions";
license = stdenv.lib.licenses.bsd3;
Expand Down Expand Up @@ -32586,7 +32591,7 @@ inherit (pkgs) libjpeg; inherit (pkgs) libpng; inherit (pkgs) zlib;};
}:
mkDerivation {
pname = "stack2nix";
version = "0.2";
version = "0.2.1";
src = ./.;
configureFlags = [ "--ghc-option=-Werror" ];
isLibrary = true;
Expand Down Expand Up @@ -39136,7 +39141,7 @@ inherit (pkgs) libjpeg; inherit (pkgs) libpng; inherit (pkgs) zlib;};
pname = "yaml";
version = "0.8.32";
sha256 = "dc20f863deb4ee75395bf1f78268781db76be6209af67b70c05f6e1a09f47a31";
configureFlags = [ "-fsystem-libyaml" ];
configureFlags = [ "-f-system-libyaml" ];
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [
Expand Down