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.

feat: add support for binary name

WeetHet f8b2300e 73d7bf6b

+41 -7
+21 -2
app/Main.hs
··· 1 1 module Main (main) where 2 2 3 + import Control.Exception (catch) 3 4 import Data.Attoparsec.Text (IResult (..), parse) 4 5 import Data.Map.Strict qualified as Map 5 6 import Data.Text (strip) 7 + import GHC.IO.Exception qualified as IEX 6 8 import Nix.Derivation (parseDerivation) 7 9 import Nix.Derivation qualified as DRV 8 10 import Options.Applicative ··· 20 22 buildArgStrs :: [(Text, Text)], 21 23 buildAttrs :: Maybe Text, 22 24 buildExpr :: Maybe Text, 25 + buildBinary :: Maybe Text, 23 26 buildIncludePaths :: [Text], 24 27 buildOptions :: [(Text, Text)], 25 28 buildRepair :: Bool, ··· 77 80 <> short 'E' 78 81 <> metavar "expr" 79 82 <> help "Interpret argument as a Nix expression" 83 + ) 84 + ) 85 + <*> optional 86 + ( strOption 87 + ( long "binary" 88 + <> short 'B' 89 + <> metavar "binary" 90 + <> help "Use binary name instead of meta.mainProgram" 80 91 ) 81 92 ) 82 93 <*> many ··· 253 264 254 265 case buildExpr opts of 255 266 Just exprText -> do 256 - binPath <- toString <$> mainProgram opts exprText 267 + binPath <- 268 + toString 269 + <$> fromMaybe 270 + (mainProgram opts exprText) 271 + (buildBinary opts <&> pure) 257 272 outPath <- binOutputOrOut opts exprText 258 273 let attr = buildAttrs opts 259 274 let attrArgs = maybe [] (("-A" :) . one) attr ··· 265 280 executeFile (outPath </> "bin" </> binPath) False (map toString passthrough) Nothing 266 281 Nothing -> do 267 282 let file = getFile opts 268 - binPath <- toString <$> mainProgram opts file 283 + binPath <- 284 + toString 285 + <$> fromMaybe 286 + (mainProgram opts file) 287 + (buildBinary opts <&> pure) 269 288 outPath <- binOutputOrOut opts file 270 289 let attr = getAttr opts 271 290 let attrArgs = maybe [] (("-A" :) . one) attr
+14 -1
nix/devshell.nix
··· 1 1 { 2 + writeShellScriptBin, 2 3 haskellPackages, 3 4 4 5 cabal-install, ··· 9 10 10 11 src, 11 12 }: 13 + let 14 + runHLS = writeShellScriptBin "runHLS" '' 15 + exec direnv exec ${toString ../.} haskell-language-server-wrapper "$@" 16 + ''; 17 + in 12 18 haskellPackages.shellFor { 13 19 packages = hpkgs: [ 14 20 (hpkgs.callCabal2nix "nix-run" src { }) ··· 27 33 npins 28 34 ]; 29 35 30 - shellHook = "hpack"; 36 + shellHook = '' 37 + hpack 38 + 39 + if [ -d .idea ]; then 40 + mkdir -p .idea/bin 41 + ln -sf ${runHLS}/bin/runHLS .idea/bin/haskell-language-server-ij 42 + fi 43 + ''; 31 44 }
+6 -4
readme.txt
··· 1 1 Usage: nix-run [fileish] [-p|--package package] [--arg name value] 2 - [--argstr name value] [-A|--attr attrPath] [-E|--expr expr] 3 - [-I|--include [name=]path] [--option name value] [--repair] 4 - [-Q|--no-build-output] [-j|--max-jobs number] [--cores number] 2 + [--argstr name value] [-A|--attr attrPath] [-E|--expr expr] 3 + [-B|--binary binary] [-I|--include [name=]path] 4 + [--option name value] [--repair] [-Q|--no-build-output] 5 + [-j|--max-jobs number] [--cores number] 5 6 [--max-silent-time seconds] [--timeout seconds] [-k|--keep-going] 6 - [-K|--keep-failed] [--fallback] [--readonly-mode] [-v|--verbose] 7 + [-K|--keep-failed] [--fallback] [--readonly-mode] [-v|--verbose] 7 8 [--quiet] [--log-format format] [--check] 8 9 9 10 nix-run - run a Nix application ··· 15 16 --argstr name value Pass a string value for argument 'name' 16 17 -A,--attr attrPath Select attribute to build 17 18 -E,--expr expr Interpret argument as a Nix expression 19 + -B,--binary binary Use binary name instead of meta.mainProgram 18 20 -I,--include [name=]path Add a path to the Nix expression search path 19 21 --option name value Set Lix configuration option 20 22 --repair Fix corrupted or missing store paths by redownloading