@@ -9,7 +9,6 @@
99{-# LANGUAGE TypeApplications #-}
1010module Obelisk.Command.Nix
1111 ( nixBuild
12− , withNixRemoteCheck
1312 , NixBuildConfig (..)
1413 , Target (..)
1514 , OutLink (..)
@@ -87,7 +86,7 @@ instance Default NixBuildConfig where
8786
8887nixBuild :: MonadObelisk m => NixBuildConfig -> m FilePath
8988nixBuild cfg = withSpinner' ("Running nix-build on " <> desc) (Just $ const $ "Built " <> desc) $ do
90− output <- withNixRemoteCheck $ readProcessAndLogStderr Debug $ proc "nix-build" $ mconcat
89+ output <- readProcessAndLogStderr Debug $ proc "nix-build" $ mconcat
9190 [[path], attrArg, args, outLink, buildersArg]
9291 -- Remove final newline that Nix appends
9392 Just (outPath, '\n') <- pure $ T.unsnoc output
@@ -108,31 +107,3 @@ nixBuild cfg = withSpinner' ("Running nix-build on " <> desc) (Just $ const $ "B
108107 [] -> []
109108 builders -> ["--builders", intercalate ";" builders]
110109
111−-- | If a nix command fails, and this may be related to the NIX_REMOTE issue,
112−-- tell the user what to do.
113−--
114−-- Added: June, 2018. Consider removing this eventually.
115−withNixRemoteCheck
116− :: MonadObelisk m
117− => (forall m'. MonadInfallibleObelisk m' => ExceptT ObeliskError m' a)
118− -> m a
119−withNixRemoteCheck f = do
120− status <- runExceptT f
121− case status of
122− Right a -> pure a
123− Left e -> throwError =<< case matching asProcessFailure e of
124− Left _ -> pure e
125− Right pf -> liftIO (lookupEnv "NIX_REMOTE") >>= \case
126− Just _ -> pure e
127− Nothing -> liftIO (writable <$> getPermissions "/nix/var/nix/db") >>= \case
128− True -> pure e
129− False -> pure $ ObeliskError_ProcessError pf $ Just $ T.unlines
130− [ "!!! "
131− , "!!! A nix command failed to run. You might need to set the NIX_REMOTE environment variable"
132− , "!!! to `daemon`. To do this, run the following before running obelisk:"
133− , "!!! "
134− , "!!! export NIX_REMOTE=daemon"
135− , "!!! "
136− , "!!! For details, see https://github.com/NixOS/nixpkgs/issues/5713"
137− , "!!! "
138− ]