A stable replacement for nix run in haskell
nix cli
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: make -A function with -E

WeetHet 2256ce50 2ce7b949

+9 -5
+9 -5
app/Main.hs
··· 211 211 argstrNix = unwords . fmap (\(n, v) -> n <> " = " <> "\"" <> v <> "\"" <> ";") $ argstrs 212 212 argsBlock = "{" <> (unwords [argNix, argstrNix]) <> " }" 213 213 214 - getExeExprFromExpr :: Text -> Text 215 - getExeExprFromExpr expr = 214 + getExeExprFromExpr :: Text -> Maybe Text -> Text 215 + getExeExprFromExpr expr attr = 216 216 unlines 217 217 [ "let", 218 218 " lib = import <nixpkgs/lib>;", 219 219 " drv = (" <> expr <> ");", 220 - "in lib.getExe drv" 220 + "in lib.getExe drv" <> attrSub 221 221 ] 222 + where 223 + attrSub = maybe "" ("." <>) attr 222 224 223 225 readProcessText :: FilePath -> [Text] -> Text -> IO Text 224 226 readProcessText cmd args input = toText <$> readProcess cmd (map toString args) (toString input) ··· 243 245 244 246 case buildExpr opts of 245 247 Just exprText -> do 246 - let expr = getExeExprFromExpr exprText 248 + let attr = buildAttrs opts 249 + let expr = getExeExprFromExpr exprText attr 247 250 binPath <- 248 251 readProcessText 249 252 "nix-instantiate" ··· 252 255 ++ if (buildReadonlyMode opts) then ["--readonly-mode"] else ["--read-write-mode"] 253 256 ) 254 257 "" 258 + let attrArgs = maybe [] (("-A" :) . one) attr 255 259 void $ 256 260 readProcessText 257 261 "nix-build" 258 - (["--no-out-link", "-E", expr] <> nixBuildArgs opts) 262 + (["--no-out-link", "-E", exprText] ++ attrArgs ++ nixBuildArgs opts) 259 263 "" 260 264 executeFileText (strip binPath) False passthrough Nothing 261 265 Nothing -> do