on master help sign in
Pin <nixpkgs> in obelisk nix-shell's
commit6dead611eee444bdb60b5cfed91a42986aa9eb4f authorElliot Cameron <eacameron@gmail.com> dateTue 17 Dec 2019, 09:49 (7 years ago) parent1a28d67
2 files changed+7−5
ChangeLog.md+1−1 lib/command/src/Obelisk/Command/Project.hs+6−4
ChangeLog.md+1−1
@@ -11,7 +11,7 @@ This project's release branch is `master`. This log is written from the perspect
1111* Add support in obelisk-route for single parameters in URL paths
1212* Bump reflex-platform so that obelisk now uses reflex-dom 0.5.2.0
1313* Use a `--pure` nix shell in `ob run` for parity with `ob repl` and more resilience against "works on my machine".
14−* Use `--keep NIX_PATH` for all pure shells so references to `<nixpkgs>` continues to work.
14+* Pin usages of `<nixpkgs>` in obelisk thunks, etc. to the nixpkgs used by the project's obelisk impl.
1515* Backport ACMEv2 support in obelisk server to regain LetsEncrypt account creation.
1616* Enable https in `ob run`
1717* `ob run` now handles ghci errors better, and includes a custom ghcid
lib/command/src/Obelisk/Command/Project.hs+6−4
@@ -1,6 +1,7 @@
11{-# LANGUAGE FlexibleContexts #-}
22{-# LANGUAGE LambdaCase #-}
33{-# LANGUAGE OverloadedStrings #-}
4+{-# LANGUAGE TemplateHaskell #-}
45module Obelisk.Command.Project
56 ( InitSource (..)
67 , initProject
@@ -29,6 +30,7 @@ import System.IO.Unsafe (unsafePerformIO)
2930import System.Posix (FileStatus, FileMode, CMode (..), UserID, deviceID, fileID, fileMode, fileOwner, getFileStatus, getRealUserID)
3031import System.Posix.Files
3132import System.Process (CreateProcess, cwd, proc, waitForProcess, delegate_ctlc)
33+import System.Which (staticWhich)
3234
3335import GitHub.Data.GitData (Branch)
3436import GitHub.Data.Name (Name)
@@ -241,16 +243,16 @@ inImpureProjectShell shellName command = withProjectRoot "." $ \root ->
241243
242244projectShell :: MonadObelisk m => FilePath -> Bool -> String -> Maybe String -> m ()
243245projectShell root isPure shellName command = do
246+ let nixPath = $(staticWhich "nix")
247+ nixpkgsPath <- fmap T.strip $ readProcessAndLogStderr Debug $ proc nixPath ["eval", "(import .obelisk/impl {}).nixpkgs.path"]
244248 (_, _, _, ph) <- createProcess_ "runNixShellAttr" $ setCtlc $ setCwd (Just root) $ proc "nix-shell" $
245249 [ "default.nix"] <>
246− -- Keep $NIX_PATH in the env for --pure shells so '<nixpkgs>' works in sub-commands
247− -- TODO: Don't use <nixpkgs> for anything!
248− (if isPure then [ "--pure", "--keep", "NIX_PATH" ] else []) <>
250+ ["--pure" | isPure] <>
249251 [ "-A"
250252 , "shells." <> shellName
251253 ] <> case command of
252254 Nothing -> []
253− Just c -> ["--run", c]
255+ Just c -> ["--run", "export NIX_PATH=nixpkgs=" <> T.unpack nixpkgsPath <> "; " <> c] -- TODO: Escape nixpkgsPath
254256 void $ liftIO $ waitForProcess ph
255257
256258setCtlc :: CreateProcess -> CreateProcess