diff options
Diffstat (limited to 'Biz')
-rw-r--r-- | Biz/Bild.hs | 28 | ||||
-rw-r--r-- | Biz/Bild.nix | 4 | ||||
-rw-r--r-- | Biz/Bild/Builder.nix | 12 | ||||
-rw-r--r-- | Biz/Bild/Deps.hs | 2 | ||||
-rwxr-xr-x | Biz/Bot.scm | 2 | ||||
-rwxr-xr-x | Biz/Ide/ftags | 2 | ||||
-rwxr-xr-x | Biz/Ide/hooks/post-checkout | 4 | ||||
-rwxr-xr-x | Biz/Ide/hooks/post-merge | 2 | ||||
-rwxr-xr-x | Biz/Ide/hooks/pre-commit | 2 | ||||
-rwxr-xr-x | Biz/Ide/hooks/pre-push | 4 | ||||
-rwxr-xr-x | Biz/Ide/mktags | 16 | ||||
-rwxr-xr-x | Biz/Ide/ns | 2 | ||||
-rwxr-xr-x | Biz/Ide/push | 4 | ||||
-rwxr-xr-x | Biz/Ide/repl | 10 | ||||
-rwxr-xr-x | Biz/Ide/run | 2 | ||||
-rwxr-xr-x | Biz/Ide/ship | 4 | ||||
-rwxr-xr-x | Biz/Ide/tidy | 2 | ||||
-rw-r--r-- | Biz/Lint.hs | 2 | ||||
-rw-r--r-- | Biz/Mynion.py | 2 |
19 files changed, 53 insertions, 53 deletions
diff --git a/Biz/Bild.hs b/Biz/Bild.hs index 1e0422a..c1dfefd 100644 --- a/Biz/Bild.hs +++ b/Biz/Bild.hs @@ -163,7 +163,7 @@ main = Cli.Plan help move test_ pure |> Cli.main test_bildBild :: Test.Tree test_bildBild = Test.unit "can bild bild" <| do - root <- Env.getEnv "BIZ_ROOT" + root <- Env.getEnv "CODEROOT" path <- Dir.makeAbsolute "Biz/Bild.hs" case Namespace.fromPath root path of Nothing -> Test.assertFailure "can't find ns for bild" @@ -179,7 +179,7 @@ test_bildBild = test_bildExamples :: Test.Tree test_bildExamples = Test.unit "can bild examples" <| do - Env.getEnv "BIZ_ROOT" +> \root -> + Env.getEnv "CODEROOT" +> \root -> ["c", "hs", "lisp", "rs"] |> map ("Biz/Bild/Example." <>) |> traverse Dir.makeAbsolute @@ -194,7 +194,7 @@ test_bildExamples = move :: Cli.Arguments -> IO () move args = IO.hSetBuffering stdout IO.NoBuffering - >> Env.getEnv "BIZ_ROOT" +> \root -> + >> Env.getEnv "CODEROOT" +> \root -> Cli.getAllArgs args (Cli.argument "target") |> filter (not <. Namespace.isCab) |> filterM Dir.doesFileExist @@ -226,7 +226,7 @@ move args = | args `Cli.has` Cli.longOption "json" = Log.wipe >> putJSON targets >> pure [Exit.ExitSuccess] | otherwise = do - root <- Env.getEnv "BIZ_ROOT" + root <- Env.getEnv "CODEROOT" createHier root build isTest isLoud targets isTest = args `Cli.has` Cli.longOption "test" @@ -331,7 +331,7 @@ data Target = Target -- | Use this to just get a target to play with at the repl. dev_getTarget :: FilePath -> IO Target dev_getTarget fp = do - root <- Env.getEnv "BIZ_ROOT" + root <- Env.getEnv "CODEROOT" path <- Dir.makeAbsolute fp Namespace.fromPath root path |> \case @@ -446,7 +446,7 @@ analyze hmap ns = case Map.lookup ns hmap of analyzeOne :: Namespace -> IO (Maybe Target) analyzeOne namespace@(Namespace _ ext) = do let path = Namespace.toPath namespace - root <- Env.getEnv "BIZ_ROOT" + root <- Env.getEnv "CODEROOT" let abspath = root </> path let quapath = path user <- Env.getEnv "USER" /> Text.pack @@ -480,7 +480,7 @@ analyze hmap ns = case Map.lookup ns hmap of "\"import py_compile;import os;" <> "py_compile.compile(file='" <> str quapath - <> "', cfile=os.getenv('BIZ_ROOT')+'/_/int/" + <> "', cfile=os.getenv('CODEROOT')+'/_/int/" <> str quapath <> "', doraise=True)\"" ], @@ -531,13 +531,13 @@ analyze hmap ns = case Map.lookup ns hmap of compilerFlags = [ "-Werror", "-threaded", - "-i$BIZ_ROOT", + "-i$CODEROOT", "-odir", ".", "-hidir", ".", "--make", - "$BIZ_ROOT" </> quapath + "$CODEROOT" </> quapath ] ++ case out of Meta.Bin o -> @@ -665,7 +665,7 @@ analyze hmap ns = case Map.lookup ns hmap of Meta.Bin o -> map Text.pack - [ "$BIZ_ROOT" </> path, + [ "$CODEROOT" </> path, "-o", o ] @@ -681,7 +681,7 @@ analyze hmap ns = case Map.lookup ns hmap of detectHaskellImports :: Analysis -> [Text] -> IO (Set Meta.Dep, Set FilePath) detectHaskellImports hmap contentLines = - Env.getEnv "BIZ_ROOT" +> \root -> + Env.getEnv "CODEROOT" +> \root -> contentLines /> Text.unpack /> Regex.match haskellImports @@ -774,7 +774,7 @@ isSuccess _ = False test :: Bool -> Target -> IO (Exit.ExitCode, ByteString) test loud Target {..} = case compiler of Ghc -> do - root <- Env.getEnv "BIZ_ROOT" + root <- Env.getEnv "CODEROOT" run <| Proc { loud = loud, @@ -791,7 +791,7 @@ test loud Target {..} = case compiler of build :: Bool -> Bool -> Analysis -> IO [Exit.ExitCode] build andTest loud analysis = - Env.getEnv "BIZ_ROOT" +> \root -> + Env.getEnv "CODEROOT" +> \root -> forM (Map.elems analysis) <| \target@Target {..} -> fst </ case compiler of CPython -> case out of @@ -949,7 +949,7 @@ lispRequires = nixBuild :: Bool -> Target -> IO (Exit.ExitCode, ByteString) nixBuild loud target@(Target {..}) = - Env.getEnv "BIZ_ROOT" +> \root -> + Env.getEnv "CODEROOT" +> \root -> instantiate root |> run +> \case (_, "") -> panic "instantiate did not produce a drv" (Exit.ExitSuccess, drv) -> diff --git a/Biz/Bild.nix b/Biz/Bild.nix index b12b87a..c7c3207 100644 --- a/Biz/Bild.nix +++ b/Biz/Bild.nix @@ -6,7 +6,7 @@ let # put all of our stuff in the 'bild' namespace in nixpkgs // { bild = rec { # provided by .envrc - root = builtins.getEnv "BIZ_ROOT"; + root = builtins.getEnv "CODEROOT"; inherit (nixpkgs) sources; @@ -97,7 +97,7 @@ in nixpkgs // { bild = rec { USER = "nixbld"; HOSTNAME = "nix-sandbox"; # this is the default sandbox path where bild will be working: - BIZ_ROOT = "/build/biz"; + CODEROOT = "/build/biz"; # we need to remove the $src root because bild expects paths relative to the # working directory: TARGET = "." + lib.strings.removePrefix (toString src) (toString target); diff --git a/Biz/Bild/Builder.nix b/Biz/Bild/Builder.nix index f9eb31d..2ed3dd1 100644 --- a/Biz/Bild/Builder.nix +++ b/Biz/Bild/Builder.nix @@ -10,7 +10,7 @@ let analysis = builtins.fromJSON analysisJSON; build = _: target: let name = target.out; - root = builtins.getEnv "BIZ_ROOT"; + root = builtins.getEnv "CODEROOT"; mainModule = target.mainModule; compileLine = lib.strings.concatStringsSep " " ([target.compiler] ++ target.compilerFlags); @@ -51,18 +51,18 @@ let else lib.attrsets.attrVals target.sysdeps pkgs; - BIZ_ROOT = "."; + CODEROOT = "."; builders = { base = stdenv.mkDerivation rec { - inherit name src BIZ_ROOT preBuild; + inherit name src CODEROOT preBuild; buildInputs = langdeps_ ++ sysdeps_; installPhase = "install -D ${name} $out/bin/${name}"; buildPhase = compileLine; }; haskell = stdenv.mkDerivation rec { - inherit name src BIZ_ROOT preBuild; + inherit name src CODEROOT preBuild; nativeBuildInputs = [ makeWrapper ]; buildInputs = sysdeps_ ++ [ (bild.haskell.ghcWith (p: @@ -78,7 +78,7 @@ let }; c = stdenv.mkDerivation rec { - inherit name src BIZ_ROOT preBuild; + inherit name src CODEROOT preBuild; buildInputs = langdeps_ ++ sysdeps_; installPhase = "install -D ${name} $out/bin/${name}"; buildPhase = lib.strings.concatStringsSep " " [ @@ -91,7 +91,7 @@ let }; python = bild.python.buildPythonApplication rec { - inherit name src BIZ_ROOT; + inherit name src CODEROOT; propagatedBuildInputs = langdeps_ ++ sysdeps_; buildInputs = sysdeps_; nativeCheckInputs = [ black mypy ruff ]; diff --git a/Biz/Bild/Deps.hs b/Biz/Bild/Deps.hs index 17aae0d..08e3ee6 100644 --- a/Biz/Bild/Deps.hs +++ b/Biz/Bild/Deps.hs @@ -47,7 +47,7 @@ instance MonadUnliftIO NIO where getFindSourcesJson :: NIO FindSourcesJson -- getFindSourcesJson = ask getFindSourcesJson = do - root <- li <| getEnv "BIZ_ROOT" + root <- li <| getEnv "CODEROOT" pure <| AtPath <| root </> "Biz/Bild/Sources.json" li :: MonadIO io => IO a -> io a diff --git a/Biz/Bot.scm b/Biz/Bot.scm index af06585..81e04f0 100755 --- a/Biz/Bot.scm +++ b/Biz/Bot.scm @@ -2,7 +2,7 @@ ;; ;; Usage with ii: ;; -;; tail -f \#biz/out | guile -L $BIZ_ROOT -s Biz/Bot.scm +;; tail -f \#biz/out | guile -L $CODEROOT -s Biz/Bot.scm ;; (define-module (Biz Bot) #:export (main)) diff --git a/Biz/Ide/ftags b/Biz/Ide/ftags index bc4fda0..02d78c5 100755 --- a/Biz/Ide/ftags +++ b/Biz/Ide/ftags @@ -3,7 +3,7 @@ # search tags with fzf # set -euo pipefail - tags=${BIZ_ROOT:?}/tags + tags=${CODEROOT:?}/tags tag_search=$( awk 'BEGIN { FS="\t" } !/^!/ {print toupper($4)"\t"$1"\t"$2"\t"$3}' "$tags" \ | cut -c1-80 \ diff --git a/Biz/Ide/hooks/post-checkout b/Biz/Ide/hooks/post-checkout index ef0cfa1..73488b0 100755 --- a/Biz/Ide/hooks/post-checkout +++ b/Biz/Ide/hooks/post-checkout @@ -1,13 +1,13 @@ #!/usr/bin/env bash set -e -mktags=${BIZ_ROOT:?}/Biz/Ide/mktags +mktags=${CODEROOT:?}/Biz/Ide/mktags old=$1 new=$2 # filter out only the changed haskell files changed=($(git diff --diff-filter=d --name-only $old $new -- '*.hs')) if [[ ! -r tags ]] || [[ ! -r TAGS ]] then - $mktags "$BIZ_ROOT"/**/* + $mktags "$CODEROOT"/**/* elif [[ ${#changed[@]} -gt 0 ]] then $mktags $changed diff --git a/Biz/Ide/hooks/post-merge b/Biz/Ide/hooks/post-merge index f0d59a9..c21211f 100755 --- a/Biz/Ide/hooks/post-merge +++ b/Biz/Ide/hooks/post-merge @@ -1,2 +1,2 @@ #!/usr/bin/env bash -exec ${BIZ_ROOT:?}/Biz/Ide/hooks/post-checkout 'HEAD@{1}' HEAD +exec ${CODEROOT:?}/Biz/Ide/hooks/post-checkout 'HEAD@{1}' HEAD diff --git a/Biz/Ide/hooks/pre-commit b/Biz/Ide/hooks/pre-commit index 065a0f6..2b4575c 100755 --- a/Biz/Ide/hooks/pre-commit +++ b/Biz/Ide/hooks/pre-commit @@ -7,7 +7,7 @@ changed=($(git diff-index --cached --name-only HEAD)) for ns in ${changed[@]} do - version=$(${BIZ_ROOT:?}/Biz/Ide/version $ns) + version=$(${CODEROOT:?}/Biz/Ide/version $ns) if (( $version == -1 )); then echo "info: version: $ns: deleted" elif (( $version < 1 )); then diff --git a/Biz/Ide/hooks/pre-push b/Biz/Ide/hooks/pre-push index baf7a13..0c313cb 100755 --- a/Biz/Ide/hooks/pre-push +++ b/Biz/Ide/hooks/pre-push @@ -30,7 +30,7 @@ fi fi ## - if lint "${BIZ_ROOT:?}"/**/* + if lint "${CODEROOT:?}"/**/* then lint_result="good" else @@ -38,7 +38,7 @@ exit 1 fi ## - if bild --test "${BIZ_ROOT:?}"/**/* + if bild --test "${CODEROOT:?}"/**/* then test_result="good" else diff --git a/Biz/Ide/mktags b/Biz/Ide/mktags index b984fb1..c83f319 100755 --- a/Biz/Ide/mktags +++ b/Biz/Ide/mktags @@ -4,17 +4,17 @@ # set -euo pipefail files=$@ - vimtags=${BIZ_ROOT:?}/tags - emacstags=${BIZ_ROOT:?}/TAGS + vimtags=${CODEROOT:?}/tags + emacstags=${CODEROOT:?}/TAGS # if [[ ! -r $emacstags ]]; then echo Generating emacs TAGS from scratch... - fast-tags -e -R ${BIZ_ROOT:?} + fast-tags -e -R ${CODEROOT:?} ctags -e \ --append=yes \ --recurse=yes \ - --exclude="$BIZ_ROOT/_/*" \ - ${BIZ_ROOT:?} + --exclude="$CODEROOT/_/*" \ + ${CODEROOT:?} else fast-tags -e $files ctags -e \ @@ -25,12 +25,12 @@ # if [[ ! -r $vimtags ]]; then echo Generating vim tags from scratch... - fast-tags "${flags[@]}" -R ${BIZ_ROOT:?} + fast-tags "${flags[@]}" -R ${CODEROOT:?} ctags "${flags[@]}" \ --append=yes \ --recurse=yes \ - --exclude="${BIZ_ROOT:?}/_/*" \ - ${BIZ_ROOT:?} + --exclude="${CODEROOT:?}/_/*" \ + ${CODEROOT:?} else fast-tags "${flags[@]}" $files ctags "${flags[@]}" \ @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -euo pipefail -fd --exclude=_ -t f . ${BIZ_ROOT:?} | sed "s,${BIZ_ROOT:?}/*,,g" \ +fd --exclude=_ -t f . ${CODEROOT:?} | sed "s,${CODEROOT:?}/*,,g" \ | fzf \ --bind "alt-space:execute(bild {} && read -p [fin])" \ --bind "alt-enter:execute(vim {})" \ diff --git a/Biz/Ide/push b/Biz/Ide/push index c4bfb72..2238e06 100755 --- a/Biz/Ide/push +++ b/Biz/Ide/push @@ -2,14 +2,14 @@ # Eventually convert to haskell, see: # - https://github.com/awakesecurity/nix-deploy/blob/master/src/Main.hs # - http://www.haskellforall.com/2018/08/nixos-in-production.html -prefix=$(echo $PWD | sed -e "s|^${BIZ_ROOT:?}/*||g") +prefix=$(echo $PWD | sed -e "s|^${CODEROOT:?}/*||g") if [[ "$prefix" == "" ]] then target="$1" else target="$prefix.$1" fi -what=$(realpath "${BIZ_ROOT:?}/_/nix/$target") +what=$(realpath "${CODEROOT:?}/_/nix/$target") # hack: get the domain from the activation script. there does not seem # to be a way to get it from nix-instantiate where=$(rg -r '$2' -e '(domainname ")(.*)(")' "$what/activate") diff --git a/Biz/Ide/repl b/Biz/Ide/repl index 1401218..7230edd 100755 --- a/Biz/Ide/repl +++ b/Biz/Ide/repl @@ -31,7 +31,7 @@ fi exts=$(jq --raw-output '.[].namespace.ext' <<< $json | sort | uniq) packageSet=$(jq --raw-output '.[].packageSet' <<< $json) module=$(jq --raw-output '.[].mainModule' <<< $json) - BILD="(import ${BIZ_ROOT:?}/Biz/Bild.nix {})" + BILD="(import ${CODEROOT:?}/Biz/Bild.nix {})" for lib in ${sysdeps[@]}; do flags+=(--packages "$BILD.pkgs.${lib}") flags+=(--packages "$BILD.pkgs.pkg-config") @@ -46,14 +46,14 @@ fi echo "warn: repl: ghci does not support binding to a port" fi flags+=(--packages "$BILD.bild.haskell.ghcWith (h: with h; [$langdeps])") - command=${CMD:-"ghci -i${BIZ_ROOT:?} -ghci-script ${BIZ_ROOT:?}/.ghci ${targets[@]}"} + command=${CMD:-"ghci -i${CODEROOT:?} -ghci-script ${CODEROOT:?}/.ghci ${targets[@]}"} ;; Scm) for lib in ${langdeps[@]}; do flags+=(--packages "$BILD.guile-${lib}") done flags+=(--packages "$BILD.guile") - command=${CMD:-"guile -L ${BIZ_ROOT:?} -C ${BIZ_ROOT:?}/_/int --r7rs --listen=${PORT:-37146}"} + command=${CMD:-"guile -L ${CODEROOT:?} -C ${CODEROOT:?}/_/int --r7rs --listen=${PORT:-37146}"} ;; Lisp) flags+=(--packages "$BILD.bild.$packageSet (p: with p; [asdf swank $langdeps])") @@ -67,8 +67,8 @@ fi langdeps="$langdeps mypy" flags+=(--packages ruff) flags+=(--packages "$BILD.bild.python.pythonWith (p: with p; [$langdeps])") - PYTHONPATH=$BIZ_ROOT:$PYTHONPATH - pycommand="python -i $BIZ_ROOT/Biz/Repl.py $module ${targets[@]}" + PYTHONPATH=$CODEROOT:$PYTHONPATH + pycommand="python -i $CODEROOT/Biz/Repl.py $module ${targets[@]}" command=${CMD:-"$pycommand"} ;; *) diff --git a/Biz/Ide/run b/Biz/Ide/run index bf35e3e..f7b9d36 100755 --- a/Biz/Ide/run +++ b/Biz/Ide/run @@ -3,4 +3,4 @@ set -eu target=$1 shift out=$(rg --only-matching ": out (\w*)" -r '$1' $target) -exec "${BIZ_ROOT:?}/_/bin/$out" "$@" +exec "${CODEROOT:?}/_/bin/$out" "$@" diff --git a/Biz/Ide/ship b/Biz/Ide/ship index f817d29..33197c8 100755 --- a/Biz/Ide/ship +++ b/Biz/Ide/ship @@ -9,9 +9,9 @@ stuff=(${@}) if [[ ${#stuff[@]} -eq 0 ]] then - stuff=$(fd -t l . "$BIZ_ROOT/_" \ + stuff=$(fd -t l . "$CODEROOT/_" \ | fzf --multi \ - | sed "s,$BIZ_ROOT/_/nix/,,g" + | sed "s,$CODEROOT/_/nix/,,g" ) fi lint ${stuff[@]} diff --git a/Biz/Ide/tidy b/Biz/Ide/tidy index edea828..ec666ba 100755 --- a/Biz/Ide/tidy +++ b/Biz/Ide/tidy @@ -1,2 +1,2 @@ #!/usr/bin/env bash -rm -f $BIZ_ROOT/_/bin/* +rm -f $CODEROOT/_/bin/* diff --git a/Biz/Lint.hs b/Biz/Lint.hs index bc91f34..62ddba7 100644 --- a/Biz/Lint.hs +++ b/Biz/Lint.hs @@ -41,7 +41,7 @@ main = Cli.main <| Cli.Plan help move test pure move :: Cli.Arguments -> IO () move args = - Environment.getEnv "BIZ_ROOT" +> \root -> + Environment.getEnv "CODEROOT" +> \root -> case Cli.getAllArgs args (Cli.argument "file") of [] -> changedFiles diff --git a/Biz/Mynion.py b/Biz/Mynion.py index 6bb55e1..85eadc8 100644 --- a/Biz/Mynion.py +++ b/Biz/Mynion.py @@ -45,7 +45,7 @@ class Mynion(slixmpp.ClientXMPP): self.tokenizer = tokenizer self.generator = generator - root = os.getenv("BIZ_ROOT", "") + root = os.getenv("CODEROOT", "") # this should be parameterized somehow with open(os.path.join(root, "Biz", "Mynion", "Prompt.md")) as f: txt = f.read() |