Skip to content
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

Fix MacOS builds on Big Sur+ #1020

Open
wants to merge 4 commits into
base: develop
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
4 changes: 2 additions & 2 deletions dep/reflex-platform/github.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"repo": "reflex-platform",
"branch": "develop",
"private": false,
"rev": "6c8830e059a6d2859cb1b65acefed3c2f1d216d3",
"sha256": "sha256:06kv45yq8qan0p22wzj5c9mx11ns1wddyqjr1xasjjkf6gaf0080"
"rev": "ae415044d5ef35d947f0689a66f349ae9e2b7aee",
"sha256": "0mpipci4mxpaqfn2iqc6gwh0n11rvp1l2fz7g703gp12djr8srfd"
}
5 changes: 3 additions & 2 deletions haskell-overlays/obelisk.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ in
obelisk-asset-manifest = self.callCabal2nix "obelisk-asset-manifest" (obeliskCleanSource ../lib/asset/manifest) {};
obelisk-asset-serve-snap = self.callCabal2nix "obelisk-asset-serve-snap" (obeliskCleanSource ../lib/asset/serve-snap) {};
obelisk-backend = self.callCabal2nix "obelisk-backend" (obeliskCleanSource ../lib/backend) {};
obelisk-command = haskellLib.overrideCabal (self.callCabal2nix "obelisk-command" (obeliskCleanSource ../lib/command) {}) {
obelisk-command = haskellLib.overrideCabal (self.callCabal2nix "obelisk-command" (obeliskCleanSource ../lib/command) {}) (drv: {
librarySystemDepends = [
pkgs.jre
pkgs.git
Expand All @@ -26,7 +26,8 @@ in
pkgs.which
(haskellLib.justStaticExecutables self.ghcid)
];
};

});
obelisk-frontend = self.callCabal2nix "obelisk-frontend" (obeliskCleanSource ../lib/frontend) {};
obelisk-run = onLinux (self.callCabal2nix "obelisk-run" (obeliskCleanSource ../lib/run) {}) (pkg:
haskellLib.overrideCabal pkg (drv: { librarySystemDepends = [ pkgs.iproute ]; })
Expand Down
6 changes: 4 additions & 2 deletions lib/command/src/Obelisk/Command/Nix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module Obelisk.Command.Nix
, nixShellConfig_common
, nixShellConfig_pure
, nixShellConfig_run
, nixShellConfig_env
, OutLink (..)
, Target (..)
, target_attr
Expand Down Expand Up @@ -165,15 +166,16 @@ data NixShellConfig = NixShellConfig
{ _nixShellConfig_common :: NixCommonConfig
, _nixShellConfig_pure :: Bool
, _nixShellConfig_run :: Maybe String
}
, _nixShellConfig_env :: [( String, String )]
}

makeLenses ''NixShellConfig

instance HasNixCommonConfig NixShellConfig where
nixCommonConfig = nixShellConfig_common

instance Default NixShellConfig where
def = NixShellConfig def False Nothing
def = NixShellConfig def False Nothing [("","")]

data NixCmd
= NixCmd_Build NixBuildConfig
Expand Down
9 changes: 5 additions & 4 deletions lib/command/src/Obelisk/Command/Project.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import System.PosixCompat.Types
import System.PosixCompat.User
import qualified System.Process as Proc
import Text.ShellEscape (sh, bash, bytes)
import qualified Data.Map as Map

import GitHub.Data.GitData (Branch)
import GitHub.Data.Name (Name)
Expand Down Expand Up @@ -311,10 +312,10 @@ nixShellRunConfig root isPure command = do
& nixShellConfig_pure .~ isPure
& nixShellConfig_common . nixCmdConfig_target .~ (def & target_path .~ Nothing)
& nixShellConfig_run .~ (command <&> \cs -> unwords $ concat
[ ["export", BSU.toString . bytes . bash $ "NIX_PATH=nixpkgs=" <> encodeUtf8 nixpkgsPath, ";"]
, maybe [] (\v -> ["export", BSU.toString . bytes . bash $ "NIX_REMOTE=" <> encodeUtf8 (T.pack v), ";"]) nixRemote
[ maybe [] (\v -> ["export", BSU.toString . bytes . bash $ "NIX_REMOTE=" <> encodeUtf8 (T.pack v), ";"]) nixRemote
, [cs]
])
& nixShellConfig_env .~ [( "NIX_PATH", ("nixpkgs=" ++ (BSU.toString (encodeUtf8 nixpkgsPath))) )]

-- | Escape using ANSI C-style quotes @$''@
-- This does not work with all shells! Ideally, we would control exactly which shell is used,
Expand All @@ -333,8 +334,8 @@ shEscape :: String -> String
shEscape = BSU.toString . bytes . sh . BSU.fromString

nixShellRunProc :: NixShellConfig -> ProcessSpec
nixShellRunProc cfg = setDelegateCtlc True $ proc nixShellPath $ runNixShellConfig cfg

nixShellRunProc cfg = let p = setDelegateCtlc True $ proc nixShellPath $ runNixShellConfig cfg
in setEnvOverride (\oldMap -> (Map.union (Map.fromList (_nixShellConfig_env cfg)) oldMap)) p
Comment on lines +337 to +338
Copy link

@parenthetical parenthetical Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do

nixShellRunProc cfg = 
    setEnvOverride (\oldMap -> (Map.union (Map.fromList (_nixShellConfig_env cfg)) oldMap))
    $ setDelegateCtlc True
    $ proc nixShellPath
    $ runNixShellConfig cfg

mkObNixShellProc
:: MonadObelisk m
=> FilePath -- ^ Path to project root
Expand Down