├── .gitignore
├── .npmignore
├── .vscode
└── launch.json
├── .vscodeignore
├── LICENSE
├── LICENSE.md
├── README.md
├── commands
├── pip
├── project
│ ├── clean
│ ├── commands
│ ├── publish
│ └── purge
├── shell
├── start
├── subrepo
└── tools
│ ├── file_system
│ ├── fornix
│ ├── git
│ ├── nix
│ ├── nodejs
│ ├── python
│ └── string
├── documentation
├── fornix_framework.md
├── images
│ ├── cd_tutorial.gif
│ ├── package_from_example.png
│ ├── package_name.png
│ └── package_versions.png
└── setup.md
├── icon.png
├── info.yaml
├── main
├── .keep
└── main.js
├── package-lock.json
├── package.json
├── pnpm-lock.yaml
├── poetry.lock
├── pyproject.toml
├── requirements.txt
└── settings
├── .cache
└── .keep
├── during_clean
├── 450_nix.sh
├── 500_git.sh
├── 600_cache_folder.sh
├── 801_python.sh
└── 804_nodejs.sh
├── during_manual_start
├── 022_000_setup_pythonpath.sh
├── 024_000_python_ignores.sh
├── 026_000_check_node_modules.sh
├── 081_000__ensure_all_commands_executable__.sh
└── 083_000_add_node_bin.sh
├── during_purge
├── 580_mac_library_caches.sh
├── 802_remove_venv.sh
└── 805_remove_node_modules.sh
├── during_start
├── 000_009__add_path_injections__.sh
├── 001_000__setup_zsh__.sh
├── 001_010__setup_nix_path__.sh
├── 001_010_enable_globbing.sh
├── 004_000_add_system_bin.sh
├── 005_000__setup_ld_path__.sh
├── 010_000__ssl_fix__.sh
├── 019_000_setup_python_venv.sh
├── 021_000_ensure_pip_modules.sh
├── 022_000_setup_pythonpath.sh
├── 024_000_python_ignores.sh
├── 02600_check_node_modules.sh
├── 026_000_check_node_modules.sh
├── 081_000__ensure_all_commands_executable__.sh
├── 082_000_add_commands_to_path.sh
├── 08300_add_node_bin.sh
├── 083_000_add_node_bin.sh
├── 083_100_npm_init.sh
├── 090_000_run_project_commands.sh
├── 091_000_commands_function.sh
├── 092_000_doit_function.sh
├── 092_000_resume_function.sh
├── 093_000_customize_ll_function.sh
├── 094_000_jeffs_git_shortcuts.sh
├── 095_000_customize_tree_function.sh
└── 099_050_finish_spaceship_setup_.sh
├── during_start_prep
├── 010_000_setting_up_env_message.sh
├── 032_000_link_pnpm_store.sh
├── 049_000_link_keychain.sh
├── 051_000_copy_git_config.sh
├── 052_000_copy_npmrc.sh
├── 053_000_copy_vsce.sh
├── 060_010_link_deno_store.sh
├── 060_010_link_nix_channel.sh
├── 060_010_link_tealdeer.sh
├── 089_000__sudo_injection__.sh
├── 091_000__logger_injection__.sh
├── 095_000_vim_injection.sh
├── 096_000_vscode_injection.sh
└── 097_000_atom_injection.sh
├── extensions
├── #standard
│ ├── #establish_extension.sh
│ └── commands
│ │ └── tools
│ │ ├── file_system
│ │ ├── add_execute_permission
│ │ ├── copy
│ │ ├── relative_link
│ │ ├── remove
│ │ └── storage
│ │ ├── fornix
│ │ ├── basic_init_example
│ │ ├── create_wrapped_command
│ │ ├── ensure_all_commands_executable
│ │ ├── inject_into_path
│ │ ├── merge_all_templates
│ │ └── trigger
│ │ └── string
│ │ ├── escape_grep_regex
│ │ ├── escape_shell_argument
│ │ ├── indent
│ │ ├── remove_doublequotes
│ │ ├── remove_spaces_from_names
│ │ └── unindent
├── git
│ ├── #establish_extension.sh
│ ├── commands
│ │ ├── ignore
│ │ └── mixin
│ ├── config
│ ├── during_cleaning.sh
│ ├── during_start_prep.sh
│ └── hooks
│ │ ├── fsmonitor-watchman
│ │ └── .keep
│ │ ├── post-merge
│ │ ├── .keep
│ │ └── 901_check_pip_modules
│ │ ├── post-update
│ │ ├── .keep
│ │ └── 901_check_pip_modules
│ │ ├── pre-applypatch
│ │ └── .keep
│ │ ├── pre-commit
│ │ ├── .keep
│ │ └── 002_prevent_large_files.sh
│ │ ├── pre-merge-commit
│ │ └── .keep
│ │ ├── pre-push
│ │ └── .keep
│ │ ├── pre-receive
│ │ └── .keep
│ │ ├── prepare-commit-msg
│ │ └── .keep
│ │ └── update
│ │ └── .keep
├── nix
│ ├── #establish_extension.sh
│ ├── cacert.pem
│ ├── commands
│ │ ├── fix_ssl
│ │ ├── force_patch_so_files
│ │ ├── lib_path_for
│ │ ├── long_eval
│ │ ├── package_path_for
│ │ └── raw_find
│ ├── during_clean.sh
│ ├── during_start.sh
│ ├── installer_helper
│ ├── nix.toml
│ ├── parse_dependencies.nix
│ ├── settings.toml
│ ├── shell.nix
│ └── uninstaller_helper
├── nodejs
│ ├── #establish_extension.sh
│ ├── commands
│ │ └── check_node_modules
│ ├── during_clean.sh
│ ├── during_purge.sh
│ └── during_start_prep.sh
├── os_mac
│ ├── #establish_extension.sh
│ ├── during_purge.sh
│ └── during_start_prep.sh
└── python
│ ├── #establish_extension.sh
│ ├── commands
│ ├── add_project_to_pythonpath
│ ├── ensure_pip_modules
│ ├── refresh_ignores
│ └── setup_venv
│ ├── during_clean.sh
│ └── during_purge.sh
├── fornix_core
├── home
├── .zshenv
└── .zshrc
└── requirements
├── advanced_system_tools.nix
└── system_tools.toml
/.gitignore:
--------------------------------------------------------------------------------
1 | #
2 | # Custom
3 | #
4 |
5 |
6 | #
7 | # standard
8 | #
9 | **/*.do_not_sync
10 | **/*.do_not_sync.*
11 | **/*.ignore
12 | **/*.ignore.*
13 | **/*.secret
14 | **/*.secret.*
15 |
16 | #
17 | # Linux
18 | #
19 | *~
20 |
21 | # temporary files which can be created if a process still has a handle open of a deleted file
22 | .fuse_hidden*
23 |
24 | # KDE directory preferences
25 | .directory
26 |
27 | # Linux trash folder which might appear on any partition or disk
28 | .Trash-*
29 |
30 | # .nfs files are created when an open file is removed but is still being accessed
31 | .nfs*
32 |
33 |
34 | #
35 | # MacOS
36 | #
37 | # General
38 | .DS_Store
39 | .AppleDouble
40 | .LSOverride
41 |
42 | # Thumbnails
43 | ._*
44 |
45 | # Files that might appear in the root of a volume
46 | .DocumentRevisions-V100
47 | .fseventsd
48 | .Spotlight-V100
49 | .TemporaryItems
50 | .Trashes
51 | .VolumeIcon.icns
52 | .com.apple.timemachine.donotpresent
53 |
54 | # Directories potentially created on remote AFP share
55 | .AppleDB
56 | .AppleDesktop
57 | Network Trash Folder
58 | Temporary Items
59 | .apdisk
60 |
61 | #
62 | # Windows
63 | #
64 |
65 | # visual studio projects
66 | *.cache/*
67 | **/*.cache/*
68 | \.idea
69 |
70 | # Windows thumbnail cache files
71 | Thumbs.db
72 | Thumbs.db:encryptable
73 | ehthumbs.db
74 | ehthumbs_vista.db
75 |
76 | # Dump file
77 | *.stackdump
78 |
79 | # Folder config file
80 | [Dd]esktop.ini
81 |
82 | # Recycle Bin used on file shares
83 | $RECYCLE.BIN/
84 |
85 | # Windows Installer files
86 | *.cab
87 | *.msi
88 | *.msix
89 | *.msm
90 | *.msp
91 |
92 | # Windows shortcuts
93 | *.lnk
94 |
95 | #
96 | # VS Code
97 | #
98 | .vscode/*
99 | !.vscode/settings.json
100 | !.vscode/tasks.json
101 | !.vscode/launch.json
102 | !.vscode/extensions.json
103 |
104 | #
105 | # Vim
106 | #
107 |
108 | # Swap
109 | [._]*.s[a-v][a-z]
110 | [._]*.sw[a-p]
111 | [._]s[a-rt-v][a-z]
112 | [._]ss[a-gi-z]
113 | [._]sw[a-p]
114 |
115 | # Session
116 | Session.vim
117 | Sessionx.vim
118 |
119 | # Temporary
120 | .netrwhist
121 | *~
122 | # Auto-generated tag files
123 | tags
124 | # Persistent undo
125 | [._]*.un~
126 |
127 | #
128 | # Sublime text
129 | #
130 |
131 | # Cache files for Sublime Text
132 | *.tmlanguage.cache
133 | *.tmPreferences.cache
134 | *.stTheme.cache
135 |
136 | # Workspace files are user-specific
137 | *.sublime-workspace
138 |
139 | # Project files should be checked into the repository, unless a significant
140 | # proportion of contributors will probably not be using Sublime Text
141 | # *.sublime-project
142 |
143 | # SFTP configuration file
144 | sftp-config.json
145 |
146 | # Package control specific files
147 | Package Control.last-run
148 | Package Control.ca-list
149 | Package Control.ca-bundle
150 | Package Control.system-ca-bundle
151 | Package Control.cache/
152 | Package Control.ca-certs/
153 | Package Control.merged-ca-bundle
154 | Package Control.user-ca-bundle
155 | oscrypto-ca-bundle.crt
156 | bh_unicode_properties.cache
157 |
158 | # Sublime-github package stores a github token in this file
159 | # https://packagecontrol.io/packages/sublime-github
160 | GitHub.sublime-settings
161 |
162 |
163 | #
164 | # X Code
165 | #
166 |
167 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
168 |
169 | ## User settings
170 | xcuserdata/
171 |
172 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
173 | *.xcscmblueprint
174 | *.xccheckout
175 |
176 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
177 | /build/
178 | DerivedData/
179 | *.moved-aside
180 | *.pbxuser
181 | !default.pbxuser
182 | *.mode1v3
183 | !default.mode1v3
184 | *.mode2v3
185 | !default.mode2v3
186 | *.perspectivev3
187 | !default.perspectivev3
188 |
189 | ## Xcode Patch
190 | *.xcodeproj/*
191 | !*.xcodeproj/project.pbxproj
192 | !*.xcodeproj/xcshareddata/
193 | !*.xcworkspace/contents.xcworkspacedata
194 | /*.gcno
195 |
196 |
197 | #
198 | # Node
199 | #
200 |
201 | # Logs
202 | npm-debug.log*
203 | yarn-debug.log*
204 | yarn-error.log*
205 | lerna-debug.log*
206 |
207 | # Diagnostic reports (https://nodejs.org/api/report.html)
208 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
209 |
210 | # Runtime data
211 | pids
212 | *.pid
213 | *.seed
214 | *.pid.lock
215 |
216 | # Directory for instrumented libs generated by jscoverage/JSCover
217 | lib-cov
218 |
219 | # Coverage directory used by tools like istanbul
220 | coverage
221 | *.lcov
222 |
223 | # nyc test coverage
224 | .nyc_output
225 |
226 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
227 | .grunt
228 |
229 | # Bower dependency directory (https://bower.io/)
230 | bower_components
231 |
232 | # node-waf configuration
233 | .lock-wscript
234 |
235 | # Compiled binary addons (https://nodejs.org/api/addons.html)
236 | /build/Release
237 |
238 | # Dependency directories
239 | node_modules/
240 | jspm_packages/
241 |
242 | # TypeScript v1 declaration files
243 | typings/
244 |
245 | # TypeScript cache
246 | *.tsbuildinfo
247 |
248 | # Optional npm cache directory
249 | .npm
250 |
251 | # Optional eslint cache
252 | .eslintcache
253 |
254 | # Optional REPL history
255 | .node_repl_history
256 |
257 | # Output of 'npm pack'
258 | *.tgz
259 |
260 | # Yarn Integrity file
261 | .yarn-integrity
262 |
263 | # dotenv environment variables file
264 | #.env
265 | #.env.test
266 |
267 | # parcel-bundler cache (https://parceljs.org/)
268 | .cache/*
269 |
270 | # next.js build output
271 | .next
272 |
273 | # nuxt.js build output
274 | .nuxt
275 |
276 | # vuepress build output
277 | .vuepress/dist
278 |
279 | # Serverless directories
280 | .serverless/
281 |
282 | # FuseBox cache
283 | .fusebox/
284 |
285 | # DynamoDB Local files
286 | .dynamodb/
287 |
288 | #
289 | # Python
290 | #
291 | # Byte-compiled / optimized / DLL files
292 | __pycache__/
293 | *.py[cod]
294 | *$py.class
295 |
296 | # C extensions
297 | *.so
298 |
299 | # Distribution / packaging
300 | .Python
301 | /build/
302 | develop-eggs/
303 | #dist/
304 | #downloads/
305 | eggs/
306 | .eggs/
307 | lib64/
308 | /parts/
309 | sdist/
310 | var/
311 | /wheels/
312 | pip-wheel-metadata/
313 | share/python-wheels/
314 | *.egg-info/
315 | .installed.cfg
316 | *.egg
317 | #MANIFEST
318 |
319 | # PyInstaller
320 | # Usually these files are written by a python script from a template
321 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
322 | #*.manifest
323 | #*.spec
324 |
325 | # Installer logs
326 | pip-log.txt
327 | pip-delete-this-directory.txt
328 |
329 | # Unit test / coverage reports
330 | htmlcov/
331 | .tox/
332 | .nox/
333 | .coverage
334 | .coverage.*
335 | .cache/*
336 | nosetests.xml
337 | coverage.xml
338 | *.cover
339 | .hypothesis/
340 | .pytest_cache/
341 |
342 | # Translations
343 | *.mo
344 | *.pot
345 |
346 | # Django stuff:
347 | local_settings.py
348 | db.sqlite3
349 | db.sqlite3-journal
350 |
351 | # Flask stuff:
352 | #instance/
353 | .webassets-cache
354 |
355 | # Scrapy stuff:
356 | .scrapy
357 |
358 | # Sphinx documentation
359 | docs/_build/
360 |
361 | # PyBuilder
362 | #target/
363 |
364 | # Jupyter Notebook
365 | .ipynb_checkpoints
366 |
367 | # IPython
368 | #profile_default/
369 | ipython_config.py
370 |
371 | # pyenv
372 | #.python-version
373 |
374 | # pipenv
375 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
376 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
377 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
378 | # install all needed dependencies.
379 | #Pipfile.lock
380 |
381 | # celery beat schedule file
382 | celerybeat-schedule
383 |
384 | # SageMath parsed files
385 | *.sage.py
386 |
387 | # Environments
388 | #.env
389 | .venv
390 | #env/
391 | venv/
392 | #ENV/
393 | env.bak/
394 | venv.bak/
395 |
396 | # Spyder project settings
397 | .spyderproject
398 | .spyproject
399 |
400 | # Rope project settings
401 | .ropeproject
402 |
403 | # mkdocs documentation
404 | #/site
405 |
406 | # mypy
407 | .mypy_cache/
408 | .dmypy.json
409 | dmypy.json
410 |
411 | # Pyre type checker
412 | .pyre/
413 |
414 | #
415 | # Ruby
416 | #
417 | *.gem
418 | .gnupg
419 | .gnupg_pre_2.1
420 | .ipython
421 | .irb_history
422 | .jupyter
423 | .keras
424 | .luarocks
425 | *.rbc
426 | #/.config
427 | /coverage/
428 | #/InstalledFiles
429 | #/pkg/
430 | /spec/reports/
431 | .mongorc.js
432 | #/spec/examples.txt
433 | /test/tmp/
434 | /test/version_tmp/
435 | /tmp/
436 |
437 | # Used by dotenv library to load environment variables.
438 | # .env
439 |
440 | # Ignore Byebug command history file.
441 | .byebug_history
442 |
443 | ## Specific to RubyMotion:
444 | .dat*
445 | .repl_history
446 | /build/
447 | *.bridgesupport
448 | build-iPhoneOS/
449 | build-iPhoneSimulator/
450 |
451 | ## Specific to RubyMotion (use of CocoaPods):
452 | #
453 | # We recommend against adding the Pods directory to your .gitignore. However
454 | # you should judge for yourself, the pros and cons are mentioned at:
455 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
456 | #
457 | # vendor/Pods/
458 |
459 | ## Documentation cache and generated files:
460 | /.yardoc/
461 | /_yardoc/
462 | #/doc/
463 | #/rdoc/
464 |
465 | ## Environment normalization:
466 | /.bundle/
467 | /vendor/bundle
468 | /lib/bundler/man/
469 |
470 | # for a library or gem
471 | .gnupg
472 | .gnupg_pre_2.1
473 | .ipython
474 | .irb_history
475 | .jupyter
476 | .keras
477 | .luarocks
478 | # intended to run in multiple environments; otherwise, check them in:
479 | # Gemfile.lock
480 | # .ruby-version
481 | # .ruby-gemset
482 |
483 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
484 | .mongorc.js, you might want to ignore these files since the code is
485 | .rvmrc
486 |
487 | #
488 | # Elixr
489 | #
490 | /_build
491 | /cover
492 | #/deps
493 | #/doc
494 | /.fetch
495 | erl_crash.dump
496 | *.ez
497 | *.beam
498 | /config/*.secret.exs
499 | .elixir_ls/
500 |
501 | #
502 | # CMake
503 | #
504 | CMakeLists.txt.user
505 | CMakeCache.txt
506 | CMakeFiles
507 | CMakeScripts
508 | #Testing
509 | #Makefile
510 | cmake_install.cmake
511 | install_manifest.txt
512 | compile_commands.json
513 | CTestTestfile.cmake
514 | _deps
515 |
516 | #
517 | # C
518 | #
519 | # Prerequisites
520 | *.d
521 |
522 | # Object files
523 | *.o
524 | *.ko
525 | *.obj
526 | *.elf
527 |
528 | # Linker output
529 | *.ilk
530 | *.map
531 | *.exp
532 |
533 | # Precompiled Headers
534 | *.gch
535 | *.pch
536 |
537 | # Libraries
538 | *.lib
539 | *.a
540 | *.la
541 | *.lo
542 |
543 | # Shared objects (inc. Windows DLLs)
544 | *.dll
545 | *.so
546 | *.so.*
547 | *.dylib
548 |
549 | # Executables
550 | *.out
551 | *.i*86
552 | *.x86_64
553 |
554 | # Debug files
555 | *.dSYM/
556 | *.su
557 | *.idb
558 | *.pdb
559 |
560 | # Kernel Module Compile Results
561 | *.mod*
562 | *.cmd
563 | .tmp_versions/
564 | modules.order
565 | Module.symvers
566 | Mkfile.old
567 | dkms.conf
568 |
569 | #
570 | # C++
571 | #
572 | # Prerequisites
573 | *.d
574 |
575 | # Compiled Object files
576 | *.slo
577 | *.lo
578 | *.o
579 | *.obj
580 |
581 | # Precompiled Headers
582 | *.gch
583 | *.pch
584 |
585 | # Compiled Dynamic libraries
586 | *.so
587 | *.dylib
588 | *.dll
589 |
590 | # Fortran module files
591 | *.mod
592 | *.smod
593 |
594 | # Compiled Static libraries
595 | *.lai
596 | *.la
597 | *.a
598 | *.lib
599 |
600 | # Executables
601 | *.out
602 |
603 | #
604 | # home folder files
605 | #
606 | # ignore files in folder foo
607 | settings/.cache/*
608 | # but keep the folder
609 | settings/home/*
610 | !settings/.cache/.keep
611 | !settings/home/.zshrc
612 | !settings/home/.zshenv
613 | settings/home/Library/Caches
614 | settings/home/.pnpm-store
615 | # dont remove these next one unless you want passwords to be public
616 | # these are redundant, but kept as a fail-safe
617 | settings/home/Library/Keychains
618 | settings/home/.gnupg
619 | settings/home/.gnupg_pre_2.1
620 | settings/home/.npmrc
621 | settings/home/.vsce
622 | settings/home/.gitconfig
623 | settings/home/.mongorc.js
624 | settings/home/.ungitrc
625 | settings/home/.vuerc
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | **/*
2 | !main/**
3 | !dist/**
4 | !src/**
5 | !source/**
6 | !*.js
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "extensionHost",
9 | "request": "launch",
10 | "name": "Launch Extension",
11 | "runtimeExecutable": "${execPath}",
12 | "args": [
13 | "--extensionDevelopmentPath=${workspaceFolder}"
14 | ],
15 | "outFiles": [
16 | "${workspaceFolder}/out/**/*.js"
17 | ],
18 | },
19 | ]
20 | }
--------------------------------------------------------------------------------
/.vscodeignore:
--------------------------------------------------------------------------------
1 | **/*
2 | !main/
3 | !icon.*
4 | !package.json
5 | !README.md
6 | !LICENSE.md
7 | !LICENSE
8 | !LICENSE.txt
9 | !dist/**
10 | !src/**
11 | !source/**
12 | !*.js
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright (c) 2016 Dave Geddes (geddski)
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 |
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 YOUR_NAME
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/commands/pip:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # summary
4 | # this only exists so that pip for-sure corrisponds to the python command
5 |
6 | python -m pip --disable-pip-version-check "$@"
--------------------------------------------------------------------------------
/commands/project/clean:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # summary
4 | # this just removes all of the can-be deleted files
5 | # can be useful for fixing corrupted setups
6 |
7 | # if you want to add something
8 | # edit the settings/during_clean/
9 | # (add your own file to that folder like 001_clean_mything.sh)
10 |
11 | # source all the file in settings/during_clean/ in alphabetical order
12 | . "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/fornix/trigger" "$FORNIX_FOLDER/settings/during_clean"
--------------------------------------------------------------------------------
/commands/project/commands:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | echo "commands:"
3 | # this loop is so stupidly complicated because of many inherent-to-shell reasons, for example: https://stackoverflow.com/questions/13726764/while-loop-subshell-dilemma-in-bash
4 | for_each_item_in="$FORNIX_COMMANDS_FOLDER"; [ -z "$__NESTED_WHILE_COUNTER" ] && __NESTED_WHILE_COUNTER=0;__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER + 1))"; trap 'rm -rf "$__temp_var__temp_folder"' EXIT; __temp_var__temp_folder="$(mktemp -d)"; mkfifo "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER"; (find "$for_each_item_in" -maxdepth 1 ! -path "$for_each_item_in" -print0 2>/dev/null | sort -z > "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER" &); while read -d $'\0' each
5 | do
6 | # only skip the tools directory because it has wayyyy too much stuff in it
7 | if [ -d "$each" ] && [ "$(basename "$each")" != "tools" ]
8 | then
9 | echo " $(basename "$each")"
10 | tree "$each" -C --dirsfirst -A -F --noreport | sed 's/^/ /' | sed -E 's/(\*|@)$/ /' | sed -E 's/->.+/ /' | sed "1d"
11 | fi
12 | done < "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER";__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER - 1))"
13 | echo
14 | node -e 'try { Object.keys(require(process.env.FORNIX_FOLDER+"/package.json").scripts).forEach(each=>console.log(` npm run ${each}`))}catch(e){}'
15 | echo
16 | echo "examples:"
17 | echo " project clean"
18 | echo " project commands"
19 | echo " npm run test"
20 |
21 |
--------------------------------------------------------------------------------
/commands/project/publish:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | vsce publish --pat "$1" && echo "published on VSCE"
4 | ovsx publish -p "$2" && echo "published on OVSX"
--------------------------------------------------------------------------------
/commands/project/purge:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # summary
4 | # this is a nuclear cleaning option
5 | # - if its not part of the git repo
6 | # - and it will take a long time (>1min) to get the data back
7 | # => this command should get rid of it
8 | # useful when you're trying to reset a project back to 0 when debugging
9 |
10 | # if you want to add something
11 | # edit the settings/during_purge/
12 | # (add your own file to that folder like 001_clean_mything.sh)
13 |
14 | # get user confirmation
15 | read -p "Are you sure? (y/n)" -n 1 -r
16 | echo # (optional) move to a new line
17 | if [[ ! $REPLY =~ ^[Yy]$ ]]
18 | then
19 | echo "canceling"
20 | exit 0
21 | fi
22 |
23 | # clean all the small things first
24 | "$FORNIX_COMMANDS_FOLDER/project/clean"
25 |
26 | # source all the file in settings/during_purge/ in alphabetical order
27 | . "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/fornix/trigger" "$FORNIX_FOLDER/settings/during_purge"
--------------------------------------------------------------------------------
/commands/shell:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env nix-shell
2 | #! nix-shell -i bash -p bash_5 -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/ce6aa13369b667ac2542593170993504932eb836.tar.gz
3 |
4 | # the comments above^ are special
5 | # they tell the system to process this using nix-shell
6 | # specifically using the exact version of bash to use
7 |
8 | # summary
9 | # with no arguments, this simply starts an interactive shell
10 | # with an argument
11 | # it starts the shell
12 | # runs the arguments as if they were a command+arguments
13 | # then exits the shell
14 |
15 | #
16 | # find the fornix_core
17 | #
18 | if [ -z "$FORNIX_FOLDER" ]
19 | then
20 | path_to_fornix_core=""
21 | file_name="settings/fornix_core"
22 | folder_to_look_in="$PWD"
23 | while :
24 | do
25 | # check if file exists
26 | if [ -f "$folder_to_look_in/$file_name" ]
27 | then
28 | path_to_fornix_core="$folder_to_look_in/$file_name"
29 | break
30 | else
31 | if [ "$folder_to_look_in" = "/" ]
32 | then
33 | break
34 | else
35 | folder_to_look_in="$(dirname "$folder_to_look_in")"
36 | fi
37 | fi
38 | done
39 | if [ -z "$path_to_fornix_core" ]
40 | then
41 | #
42 | # what to do if file never found
43 | #
44 | echo "Im a script running with a pwd of:$PWD"
45 | echo "Im looking for settings/fornix_core in a parent folder"
46 | echo "Im exiting now because I wasnt able to find it"
47 | echo "thats all the information I have"
48 | exit
49 | fi
50 | export FORNIX_NEXT_RUN_DONT_DO_MANUAL_START="true"
51 | . "$path_to_fornix_core"
52 | fi
53 | if [ "$FORNIX_DEBUG" = "true" ]; then
54 | echo "starting: $FORNIX_COMMANDS_FOLDER"shell
55 | fi
56 |
57 | # if no arguments (just starting the shell) give the welcome message
58 | export FORNIX_ARGS="$@"
59 |
60 | #
61 | # find and run all the startup scripts in alphabetical order
62 | #
63 |
64 | # source all the file in settings/during_clean/ in alphabetical order
65 | . "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/fornix/trigger" "$FORNIX_FOLDER/settings/during_start_prep"
66 |
67 | # create a dummy home folder to prevent any problems when starting up
68 | mkdir -p "$FORNIX_HOME/.cache/"
69 | # connect the nix cache to prevent duplicates
70 | rm -rf "$FORNIX_HOME/.cache/nix" 2>/dev/null
71 | rm -f "$FORNIX_HOME/.cache/nix" 2>/dev/null
72 | if [ -d "$HOME/.cache/nix/" ]
73 | then
74 | ln -s "$HOME/.cache/nix/" "$FORNIX_HOME/.cache/nix"
75 | fi
76 |
77 | # if there are arguments, treat it as a run command
78 | if [ "$FORNIX_DEBUG" = "true" ]; then
79 | echo "switching from Bash to Zsh"
80 | echo "changing HOME to temp folder for nix-shell"
81 | fi
82 | export TMPDIR="/tmp" # fixes some build problems (workaround for a bug in Nix)
83 | __temp_var__nix_shell_file="$FORNIX_FOLDER/settings/extensions/nix/shell.nix"
84 | if [[ -n "$FORNIX_ARGS" ]]
85 | then
86 | # FIXME: I think the single quotes need to be escaped from the arguments (need to iterate over them, escape each one with single quotes)
87 | # run single command
88 | HOME="$FORNIX_HOME" nix-shell --pure --show-trace --run "zsh -c '$FORNIX_ARGS'" "$__temp_var__nix_shell_file" -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/a7ecde854aee5c4c7cd6177f54a99d2c1ff28a31.tar.gz --keep __FORNIX_NIX_SETTINGS_PATH --keep __FORNIX_NIX_MAIN_CODE_PATH --keep __FORNIX_NIX_PACKAGES_FILE_PATH --keep __FORNIX_NIX_PATH_EXPORT_FILE --keep __FORNIX_NIX_COMMANDS --keep FORNIX_FOLDER
89 | else
90 | HOME="$FORNIX_HOME" nix-shell --pure --show-trace --command "zsh" "$__temp_var__nix_shell_file" -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/a7ecde854aee5c4c7cd6177f54a99d2c1ff28a31.tar.gz --keep __FORNIX_NIX_SETTINGS_PATH --keep __FORNIX_NIX_MAIN_CODE_PATH --keep __FORNIX_NIX_PACKAGES_FILE_PATH --keep __FORNIX_NIX_PATH_EXPORT_FILE --keep __FORNIX_NIX_COMMANDS --keep FORNIX_FOLDER
91 | fi
92 | if [ "$FORNIX_DEBUG" = "true" ]; then
93 | echo "exited the nix-shell environment"
94 | echo "(Tools/Commands mentioned in 'settings/extensions/nix/nix.toml' are no longer available/installed)"
95 | echo ""
96 | echo "switched from Zsh back to Bash"
97 | echo "finished: $FORNIX_COMMANDS_FOLDER"shell
98 | fi
99 | unset __temp_var__nix_shell_file
100 | unset __temp_var__cache_folder
--------------------------------------------------------------------------------
/commands/start:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #
4 | # summary
5 | #
6 | # make sure nix exists
7 | # find fornix
8 | # with no arguments, this simply starts the shell
9 | # with an argument, it refreshes the project connections, then runs `$commands_folder/project/$the_arguments`
10 |
11 | # if nix doesnt exist
12 | if [ -z "$(command -v "nix-shell")" ]
13 | then
14 | echo runinng installer_helper
15 | #
16 | # find the settings/extensions/nix/installer_helper
17 | #
18 | path_to_installer_helper=""
19 | file_name="settings/extensions/nix/installer_helper"
20 | folder_to_look_in="$PWD"
21 | while :
22 | do
23 | # check if file exists
24 | if [ -f "$folder_to_look_in/$file_name" ]
25 | then
26 | path_to_installer_helper="$folder_to_look_in/$file_name"
27 | break
28 | else
29 | if [ "$folder_to_look_in" = "/" ]
30 | then
31 | break
32 | else
33 | folder_to_look_in="$(dirname "$folder_to_look_in")"
34 | fi
35 | fi
36 | done
37 | # couldn't find it
38 | if [ -z "$path_to_installer_helper" ]
39 | then
40 | #
41 | # what to do if file never found
42 | #
43 | echo "I'm a script running with a pwd of:$PWD"
44 | echo "I'm looking for $file_name in a parent folder"
45 | echo "I'm exiting now because I wasnt able to find it"
46 | echo "thats all the information I have"
47 | exit
48 | #
49 | # found it
50 | #
51 | else
52 | # if wasnt able to install, then exit
53 | export install_repo="false" # we only need nix
54 | if ! . "$path_to_installer_helper"; then
55 | # the installer will have the instructions/error messages
56 | exit
57 | fi
58 | unset install_repo
59 | fi
60 | fi
61 |
62 | #
63 | # find the fornix_core
64 | #
65 | path_to_fornix_core=""
66 | file_name="settings/fornix_core"
67 | folder_to_look_in="$PWD"
68 | while :
69 | do
70 | # check if file exists
71 | if [ -f "$folder_to_look_in/$file_name" ]
72 | then
73 | path_to_fornix_core="$folder_to_look_in/$file_name"
74 | break
75 | else
76 | if [ "$folder_to_look_in" = "/" ]
77 | then
78 | break
79 | else
80 | folder_to_look_in="$(dirname "$folder_to_look_in")"
81 | fi
82 | fi
83 | done
84 | if [ -z "$path_to_fornix_core" ]
85 | then
86 | #
87 | # what to do if file never found
88 | #
89 | echo "Im a script running with a pwd of:$PWD"
90 | echo "Im looking for settings/fornix_core in a parent folder"
91 | echo "Im exiting now because I wasnt able to find it"
92 | echo "thats all the information I have"
93 | exit
94 | fi
95 | export FORNIX_NEXT_RUN_DONT_DO_MANUAL_START="true"
96 | . "$path_to_fornix_core"
97 |
98 | if [ "$FORNIX_DEBUG" = "true" ]; then
99 | echo "starting: $FORNIX_COMMANDS_FOLDER"start
100 | fi
101 |
102 | #
103 | # fix the windows WSL mkfifo problem
104 | #
105 | if [ -d "/mnt/c" ]
106 | then
107 | # create some helpers
108 | move_out_of_the_way () {
109 | if [[ -e "$1" ]]
110 | then
111 | # if something is in the way, move it out of the way
112 | # (recursively)
113 | if [[ -e "$1.old" ]]
114 | then
115 | move_out_of_the_way "$1.old"
116 | fi
117 |
118 | # now that anything that would be in the way has been moved
119 | mv "$1" "$1.old"
120 | fi
121 | }
122 | prev_command_successful () {
123 | return $?
124 | }
125 |
126 | #
127 | # check for mounting with metadata
128 | #
129 |
130 | # if project is inside the windows C drive
131 | if [[ "$FORNIX_FOLDER" == "/mnt/c"* ]]; then
132 | echo '__________________________________________________________________________________'
133 | echo '| |'
134 | echo '| Howdy! |'
135 | echo '| |'
136 | echo '| Looks like your project is saved in the windows file system |'
137 | echo '| (instead of the Linux/WSL file system) |'
138 | echo '| |'
139 | echo '| This is a bit of a problem since the file systems of |'
140 | echo '| Linux/Mac/Android/ChromeBook/OpenBSD/etc have many features |'
141 | echo '| that the windows file system does not have. |'
142 | echo '| |'
143 | echo '| Would it be okay if I move this project? |'
144 | echo '| I`ll create a shortcut to it so you can still find it. |'
145 | echo '| https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/ |'
146 | echo '| |'
147 | echo '----------------------------------------------------------------------------------'
148 | echo
149 | question="[y/n]: ";answer=''
150 | while true; do
151 | echo "$question"; read response
152 | case "$response" in
153 | [Yy]* ) answer='yes'; break;;
154 | [Nn]* ) answer='no'; break;;
155 | * ) echo "Please answer yes or no.";;
156 | esac
157 | done
158 | if [ "$answer" = 'no' ]; then
159 | echo '
160 |
161 | okay, in that case just re-run this command whenever
162 | you have moved the project to the linux file system
163 |
164 | if you`re confused about what that^ means
165 | take a look at the "fornix_framework.md" file inside
166 | of the "documentation" folder (inside of this project folder)
167 | '
168 | exit
169 | else
170 | #
171 | # where to move project
172 | #
173 | new_project_location="$HOME/repos/$(basename "$FORNIX_FOLDER")"
174 | while true; do
175 | question="Is it okay if I move the project to '$new_project_location'? [y/n]";answer=''
176 | while true; do
177 | echo "$question"; read response
178 | case "$response" in
179 | [Yy]* ) answer='yes'; break;;
180 | [Nn]* ) answer='no'; break;;
181 | * ) echo "Please answer yes or no.";;
182 | esac
183 | done
184 | if [ "$answer" = 'no' ]; then
185 | echo ""
186 | echo "Where would you like to put it?"
187 | echo "(press enter when done typing the path):"
188 | echo ""
189 | read new_project_location
190 | else
191 | break
192 | fi
193 | done
194 |
195 | #
196 | # move the project
197 | #
198 |
199 | # if something is in the way, move it out of the way
200 | if [ -e "$new_project_location" ]
201 | then
202 | move_out_of_the_way "$new_project_location"
203 | fi
204 |
205 | # make sure the parent folder exists
206 | mkdir -p "$(dirname "$new_project_location")"
207 |
208 | # move the project itself
209 | prev_command_successful && mv "$FORNIX_FOLDER" "$new_project_location"
210 |
211 | # create a shortcut to the project
212 | prev_command_successful && ln -s "$new_project_location" "$FORNIX_FOLDER"
213 |
214 | # cd and start the project
215 | prev_command_successful && cd "$new_project_location" && "$new_project_location/commands/start"
216 | # note: commands/start is needed in the above command so the FORNIX_FOLDER and other checks/setup can be redone
217 | # so just exit right after because this script has become just a wrapper at this point
218 | exit $?
219 | fi
220 | fi
221 |
222 | # check if metadata enabled already
223 | if ! mount -l | grep 'C: on /mnt/c' | grep 'metadata' &>/dev/null
224 | then
225 | echo '__________________________________________________________________________________'
226 | echo '| |'
227 | echo '| Howdy! |'
228 | echo '| |'
229 | echo '| Looks like there`s a metadata hiccup/problem. It seems you`re using WSL |'
230 | echo '| Sadly, for some reason, WSL doesn`t (by default) support many features of the |'
231 | echo '| linux file system. And For some reason, adding that support requires |'
232 | echo '| re-mounting the C drive (within WSL) with metadata enabled. |'
233 | echo '| |'
234 | echo '| I`ll run the command automatically, but if you don`t want to put |'
235 | echo '| your password in, cancel this (CTRL+C) and run the following yourself: |'
236 | echo '| |'
237 | echo ' cd ; sudo umount /mnt/c && sudo mount -t drvfs C: /mnt/c -o metadata; cd - '
238 | echo '| |'
239 | echo '| Then re-run this script |'
240 | echo '| You can read more about this problem here if you like: |'
241 | echo '| https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/ |'
242 | echo '| |'
243 | echo '----------------------------------------------------------------------------------'
244 | echo
245 | echo "Continue?"; read _
246 | pwd_before="$PWD"
247 | # this means we need to unmount and remount with metadata enabled
248 | cd && sudo umount /mnt/c && sudo mount -t drvfs C: /mnt/c -o metadata
249 | cd "$pwd_before"
250 | fi
251 | fi
252 |
253 | # just start the shell with no arguments (arguments might be supported in the future)
254 | "$FORNIX_COMMANDS_FOLDER/shell"
255 | if [ "$FORNIX_DEBUG" = "true" ]; then
256 | echo "finished: $FORNIX_COMMANDS_FOLDER"start
257 | fi
--------------------------------------------------------------------------------
/commands/subrepo:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env -S deno run --allow-all
2 | import { FileSystem } from "https://deno.land/x/quickr@0.3.20/main/file_system.js"
3 | import { run, Stderr, Stdout } from "https://deno.land/x/quickr@0.3.20/main/run.js"
4 |
5 | // go to project root
6 | FileSystem.cwd = await FileSystem.walkUpUntil(".git/")
7 |
8 | await run`git add -A`
9 | await run`git commit -m -`
10 | const { exitCode } = await run("git", "subrepo", ...Deno.args)
11 | Deno.exit(exitCode)
--------------------------------------------------------------------------------
/commands/tools/file_system:
--------------------------------------------------------------------------------
1 | ../../settings/extensions/#standard/commands/tools/file_system/
--------------------------------------------------------------------------------
/commands/tools/fornix:
--------------------------------------------------------------------------------
1 | ../../settings/extensions/#standard/commands/tools/fornix/
--------------------------------------------------------------------------------
/commands/tools/git:
--------------------------------------------------------------------------------
1 | ../../settings/extensions/git/commands/
--------------------------------------------------------------------------------
/commands/tools/nix:
--------------------------------------------------------------------------------
1 | ../../settings/extensions/nix/commands/
--------------------------------------------------------------------------------
/commands/tools/nodejs:
--------------------------------------------------------------------------------
1 | ../../settings/extensions/nodejs/commands/
--------------------------------------------------------------------------------
/commands/tools/python:
--------------------------------------------------------------------------------
1 | ../../settings/extensions/python/commands/
--------------------------------------------------------------------------------
/commands/tools/string:
--------------------------------------------------------------------------------
1 | ../../settings/extensions/#standard/commands/tools/string/
--------------------------------------------------------------------------------
/documentation/fornix_framework.md:
--------------------------------------------------------------------------------
1 | # Quick Start
2 |
3 |
4 | ### How do I start the project?
5 |
6 | Open a terminal/console app
7 | Type/Run `cd file_path/to/this/project` [ press enter ]
8 | Run `commands/start`
9 |
10 | ### How do I stop the project?
11 |
12 | Run `exit`
13 |
14 | ### How do I add a command? (custom/project command)
15 |
16 | For simple commands
17 | 1. Copy the `commands/project/clean` file
18 | 2. Remove all the lines except for the `#!/usr/bin/env bash` (the line at the top)
19 | 3. Rename the file to something like `commands/project/hello_world`
20 | 4. Add some bash code, ex: `echo "hello world"`
21 | 5. Start (or exit and restart) the project environment `commands/start`
22 | 6. Run `project hello_world`, and volia you're running your custom command!
23 |
24 | Tip1: If you move your file from `commands/project/hello_world` to just `commands/hello_world` then inside the terminal you can simply run `hello_world`
25 |
26 | Tip2: Most of the commands use bash, but they don't have to! For example, if the project uses python, you can write a python script and put `#!/usr/bin/env python` at the top
27 |
28 | ### How do I add a tool? (like git or python)
29 |
30 | - First search for the name of your tool on [here](https://search.nixos.org/packages)
31 | - For example, searching `python`, you should see results like `pythonFull`, `python39`, `python37`, etc
32 | - Sometimes you will see a name with a dot, like `unixtools.ps` or `python39Packages.opencv4`
33 | - Open the `settings/requirements/system_tools.toml` file in the project
34 | - go to the very bottom, add some newlines
35 | - if we wanted to add `python39` we would put:
36 | - `[[packages]]`
`load = [ "python39",]`
37 | - if the name has a dot in it (ex: `python39Packages.opencv4`) we would do:
38 | - `[[packages]]`
`load = [ "unixtools", "ps", ]`
39 | - Then start (or exit and restart) your environment! (`commands/start`)
40 | - Now the exact version of that tool will be available (ex: `python --version` should print out python 3.9)
41 |
42 | # Main Features
43 |
44 | #### What if I need a really specific version?
45 |
46 | - If you need a very specific version, like python 3.7.0rc1
47 | - 1. Still start [here](https://search.nixos.org/packages)
48 | - 2. But now you want to look for the "casual" package name
49 | - 3. Now go to this other (community-maintained) [website](https://lazamar.co.uk/nix-versions/)
50 | - 4. On that other site, search using that "casual" package name, and you should see something like this.
51 | - 5. Find your version (ex: `3.7.0rc1`) then click the blue revision number next to it. You should see something like this:
52 | - 6. Now, open up your `settings/requirements/nix.toml`
53 | - Scroll to the bottom and add some newlines
54 | - Then, for this example of python 3.7.0rc1, we would add
55 | - `[[packages]]`
56 | - `load = [ "python37Full", ]`
57 | - `from = "92a047a6c4d46a222e9c323ea85882d0a7a13af8"`
58 |
59 | Note: actually all of the packages secretly have a `from = ` attribute! They simply default to using the `defaultFrom =` one inside of the `settings/extensions/nix/settings.toml` file.
60 |
61 |
62 | ### How can I auto-setup ENV variables?
63 |
64 | Note: You can actually setup way more than just env variables, you can start virtual environments, check that modules have been installed, make sure certain folders exist, add your own functions/aliases you can even `cd` into folders (and the environment will start in that folder). The sky is the limit. And by sky I mean zsh.
65 |
66 | TLDR: add a bash script to `settings/during_start`
67 |
68 | Full instructions:
69 | 1. Take a look at `settings/during_start`
70 | 2. Copy one of the existing files, like `090_000_run_project_commands.sh`
71 | 3. "Pick a number"
72 | - Note: The number at the front of the file `090_000_` indicates the order-of-execution. Small numbers go first, big numbers go last.
73 | - For example, if your script needs/wants to use project commands, then make sure the number is bigger than `082_000_add_commands_to_path.sh`
74 | - Whatever number you pick, make sure it is unique
75 | - Note: If you have a huge project and run out of digits, extend all numbers. For example `082_000_` would become `082_000_000_`. (This will be automated in future versions of Fornix)
76 | 4. Write some zsh (e.g. basically bash) code
77 | - Don't use `.` as a path. Instead use `$FORNIX_FOLDER` which will be the root path of your project
78 | - ENV var example: `export PYTHON_PATH="$FORNIX_FOLDER/main:$PYTHON_PATH"`
79 | - Note: the `$HOME` variable will not be your home folder! it will be the `$FORNIX_HOME` (which is inside the project).
80 | - Why???
81 | - Fornix was designed to solve the "Well... it works on my machine" `¯\_(ツ)_/¯` problem. Many tools (like git, and npm, and python) secretly use, create, and change all kinds of stuff in your home folder. And your home folder is almost certainly not the same as your friend's home folder, meaning "Well... it works on my machine"-problems happen all the time. By making tools think your home is inside the project, we can make them behave consistently, regardless of what you put in your personal home folder.
82 | - "But I neeeeed my real $HOME var!"
83 | - Not to worry! Take a look at "How do I add external stuff?". This is where the `settings/during_start_prep/` folder comes into play. Your actual home variable will become easier to access in future versions of Fornix.
84 |
85 | ### What should I NOT change?
86 |
87 | Don't rename:
88 | - `settings`
89 | - `settings/fornix_core`
90 | - `settings/extensions/`
91 | - `settings/extensions/#standard`
92 |
93 | Note:
94 | - Everything was designed to be as customizable as possible, but due to bash/shell limitations, those are the absolute minimum number of names that need to be untouched for fornix to work at all.
95 | - The commands folder can be changed by changing the `FORNIX_COMMANDS_FOLDER` var inside of `settings/fornix_core`
96 | - The project's HOME env var can be changed by changing the `FORNIX_HOME` var inside of `settings/fornix_core`
97 | - Many folders (like `settings/.cache`) will be auto-generated if deleted. However you're welcome to find the file auto-generates the folder and change it to be some other folder.
98 |
99 | ### How do I get rid of that startup message?
100 |
101 | TLDR: change `settings/during_start_prep/010_000_setting_up_env_message.sh`
102 |
103 | Full instructions:
104 | - Most items in `settings/during_start`, like `094_000_jeffs_git_shortcuts.sh` are *designed* for you to edit/delete/enhance them
105 | - NOTE: files with double underscores like: `001_000__setup_zsh__.sh` mean the file is *critical*. You can still edit it, but just know that straight-up deleting it will probably cause major parts of the system to break.
106 | - Tip: Instead of editing files in `settings/during_start` or `during_start_prep/` for every project, fork/duplicate [Fornix](https://github.com/jeff-hykin/fornix), add all your startup customizations, then use that as a template for multiple projects!
107 |
108 |
109 | ### How do I add external stuff? (Like sudo or open-in-browser)
110 |
111 | TLDR: add a file to `settings/during_start_prep/`, look at existing files as examples
112 |
113 | GOTCHA's
114 | - ENV vars created in `settings/during_start_prep/` scripts will NOT show up in your project environment (this will likely change in a future version of Fornix)
115 | - These scripts use bash (defaulting to `GNU bash, version 4.4.23`) not zsh
116 | - The only tools that are available are what the user already happens to have installed on their computer and in their PATH var (e.g. the tools/commands (like `grep`, `unzip`, `python`) in `nix.toml` are NOT available/setup)
117 |
118 | NOTES:
119 | - If you have an external tool, like `vim` setup with your based custom configs, you can inject it tool into the project environment using this tool: `"$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/fornix/inject_into_path" "your_command_name"`
120 | - It will wrap that command, and give it access to your *real* home folder so that it can use your config files
121 | - Yes, the command name is really verbose, it'll probably be shortened in a future version of Fornix
122 | - These scripts are guarenteed to have access to these ENV vars
123 | - `$FORNIX_FOLDER` (<- absolute path to the root of your project)
124 | - `$FORNIX_HOME` (<- what the HOME var will be replaced with)
125 | - `$FORNIX_COMMANDS_FOLDER` (<- absolute path to the commands folder)
126 | - `$FORNIX_DEBUG` (<- will be `"true"` if someone is debugging startup)
127 |
128 | ### How does start up actually work? (Life Cycle)
129 |
130 | - Open up `settings/fornix_core`, and change `export FORNIX_DEBUG="false"` to `export FORNIX_DEBUG="true"`
131 | - Run `commands/start` and it'll show you every file that is executed!
132 |
133 |
134 | ### Future documentation is on the way for:
135 |
136 | - #### How do I add git hooks?
137 | - #### What is manual start?
138 | - #### How do I create a Fornix Extension?
139 |
--------------------------------------------------------------------------------
/documentation/images/cd_tutorial.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/documentation/images/cd_tutorial.gif
--------------------------------------------------------------------------------
/documentation/images/package_from_example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/documentation/images/package_from_example.png
--------------------------------------------------------------------------------
/documentation/images/package_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/documentation/images/package_name.png
--------------------------------------------------------------------------------
/documentation/images/package_versions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/documentation/images/package_versions.png
--------------------------------------------------------------------------------
/documentation/setup.md:
--------------------------------------------------------------------------------
1 | # Setup The Project Environment
2 |
3 | ### If you're an Experienced/Senior Dev
4 |
5 | - (Don't git clone)
6 | - Run this: `setup_or_copy=setup branch=master eval "$(curl -fsSL git.io/JE2Zm || wget -qO- git.io/JE2Zm)"`
7 | - If you're on Windows, run it inside WSL (Ubuntu 20.04 preferably)
8 | - If you're a responsible human being and therefore don't want run a sketchy internet script, props to you 👍. Take a look at the "What is that `eval` command doing?" section at the bottom and you'll be able to run the commands yourself.
9 |
10 | ### If the above instructions didn't make sense
11 |
12 | - Mac/Linux users
13 | - open up your terminal/console app
14 | - use `cd` to get to the folder where you want this project ([tutorial on how to use cd here](https://github.com/jeff-hykin/fornix/blob/b6fd3313beda4f80b7051211cb790a4f34da590a/documentation/images/cd_tutorial.gif))
15 | - (If you get errors on the next step -> keep reading)
16 | - Type this inside your terminal/console
`eval "$(curl -fsSL git.io/JE2Zm || wget -qO- git.io/JE2Zm)"`
[press enter]
17 | - Possible errors:
18 | - On MacOS, if your hard drive is encrypted on BigSur, you might need to [follow these steps](https://stackoverflow.com/questions/67115985/error-installing-nix-on-macos-catalina-and-big-sur-on-filevault-encrypted-boot-v#comment120393385_67115986)
19 | - On Linux, if you're running a *really* barebones system that somehow doesn't have either `curl` or `wget`, install curl or wget and rerun the previous step
20 | - Windows users
21 | - Get [WSL](https://youtu.be/av0UQy6g2FA?t=91) (Windows Subsystem for Linux) or [WSL2](https://www.omgubuntu.co.uk/how-to-install-wsl2-on-windows-10)
22 | - If you're not familiar with WSL, I'd recommend [watching a quick thing on it like this one](https://youtu.be/av0UQy6g2FA?t=91)
23 | - Ubuntu 20.04 for WSL is preferred (same as in that linked video), but Ubuntu 22.04 or similar should work.
24 | - [WSL2](https://www.omgubuntu.co.uk/how-to-install-wsl2-on-windows-10) (just released August 2020) is needed if you want to use your GPU.
25 | - Once WSL is installed (and you have a terminal logged into WSL) follow the Mac/Linux instructions.
26 | - (tip: when accessing WSL, you probably want to use the VS Code terminal, or the [open source windows terminal](https://github.com/microsoft/terminal) instead of CMD)
27 |
28 | After you've finished working and close the terminal, you can always return to project environment by doing
29 | - `cd WHEREVER_YOU_PUT_THE_PROJECT`
30 | - `commands/start`
31 |
32 |
51 |
52 | ### What is that `eval` command doing?
53 |
54 | 1. Installing nix [manual install instructions here](https://nixos.org/download.html)
55 | 2. Installing `git` (using nix) if you don't already have git
56 | 3. It clones the repository
57 | 4. It `cd`'s inside of the repo
58 | 5. Then it runs `commands/start` to enter the project environment
59 |
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/icon.png
--------------------------------------------------------------------------------
/info.yaml:
--------------------------------------------------------------------------------
1 | (using_atk_version): 1.1.0
2 | (project):
3 | name: macro-commander
4 | description: Keybindings to commandline scripts, along with any VS Code command
5 |
6 | (commands):
7 | build: "true" # no build process
8 | publish: !language/ruby |
9 | require 'atk_toolbox'
10 |
11 | system "_ build"
12 | previous_process_finished_successfully = $?.success?
13 | if previous_process_finished_successfully
14 | system "project sync"
15 | if -"npm version patch"
16 | puts "Publishing"
17 | system "vsce publish"
18 | puts "Finished Publishing"
19 | end
20 | end
21 | (setup): echo 'setup command unset'
22 |
23 | (paths):
24 | project_root: ./
--------------------------------------------------------------------------------
/main/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/main/.keep
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "macro-commander",
3 | "displayName": "macro-commander (Command Runner)",
4 | "description": "Keybindings to commandline scripts, along with any VS Code command",
5 | "icon": "icon.png",
6 | "version": "1.6.0",
7 | "publisher": "jeff-hykin",
8 | "repository": {
9 | "type": "git",
10 | "url": "git+https://github.com/jeff-hykin/macro-commander.git"
11 | },
12 | "engines": {
13 | "vscode": "^1.5.0"
14 | },
15 | "keywords": [
16 | "macro",
17 | "command",
18 | "commands",
19 | "automate",
20 | "actions",
21 | "keybinding",
22 | "run"
23 | ],
24 | "categories": [
25 | "Other"
26 | ],
27 | "activationEvents": [
28 | "onStartupFinished"
29 | ],
30 | "main": "./main/main.js",
31 | "contributes": {
32 | "configuration": {
33 | "type": "object",
34 | "title": "Macros configuration",
35 | "properties": {
36 | "macros": {}
37 | }
38 | },
39 | "commands": [
40 | {
41 | "command": "macro.run",
42 | "title": "Macros: Run A Macro"
43 | },
44 | {
45 | "command": "macro.list-builtin-commands",
46 | "title": "Macros: List all the commands that can be used in macros"
47 | },
48 | {
49 | "command": "macro.js-to-json",
50 | "title": "Macros: JS to JSON"
51 | },
52 | {
53 | "command": "macro.json-to-js",
54 | "title": "Macros: JSON to JS"
55 | },
56 | {
57 | "command": "macro.this.is.a.real.dummy.command",
58 | "title": "Macros: A demo command for macro commander"
59 | }
60 | ]
61 | },
62 | "scripts": {
63 | "postinstall": "node ./node_modules/vscode/bin/install"
64 | },
65 | "devDependencies": {
66 | "@vscode/vsce": "^2.15.0",
67 | "ovsx": "^0.7.1"
68 | },
69 | "bugs": {
70 | "url": "https://github.com/jeff-hykin/macro-commander/issues"
71 | },
72 | "homepage": "https://github.com/jeff-hykin/macro-commander#readme",
73 | "author": "",
74 | "license": "ISC",
75 | "dependencies": {}
76 | }
--------------------------------------------------------------------------------
/poetry.lock:
--------------------------------------------------------------------------------
1 | package = []
2 |
3 | [metadata]
4 | lock-version = "1.1"
5 | python-versions = ">=3.7,<3.10"
6 | content-hash = "9bb64c4e388b0212ca6b8957dad730f771ae51e0d85efdda14e1fb74502c012e"
7 |
8 | [metadata.files]
9 |
--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------
1 | [tool.poetry]
2 | name = "fornix"
3 | version = "0.1.0"
4 | description = ""
5 | authors = [""]
6 |
7 | [tool.poetry.dependencies]
8 | python = ">=3.7,<3.10"
9 |
10 | [tool.poetry.dev-dependencies]
11 |
12 | [build-system]
13 | requires = ["poetry-core>=1.0.0"]
14 | build-backend = "poetry.core.masonry.api"
15 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/requirements.txt
--------------------------------------------------------------------------------
/settings/.cache/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/settings/.cache/.keep
--------------------------------------------------------------------------------
/settings/during_clean/450_nix.sh:
--------------------------------------------------------------------------------
1 | ../extensions/nix/during_clean.sh
--------------------------------------------------------------------------------
/settings/during_clean/500_git.sh:
--------------------------------------------------------------------------------
1 | ../extensions/git/during_clean.sh
--------------------------------------------------------------------------------
/settings/during_clean/600_cache_folder.sh:
--------------------------------------------------------------------------------
1 | # the usual things
2 | __temp_var_cache_folder="$FORNIX_FOLDER/settings/.cache"
3 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$__temp_var_cache_folder"
4 | for item in $(find "$FORNIX_FOLDER" ! -path . -iregex '.*\.cleanable(\..*)?')
5 | do
6 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$item"
7 | done
8 | # restore the keep file
9 | mkdir -p "$__temp_var_cache_folder" && touch "$__temp_var_cache_folder/.keep"
--------------------------------------------------------------------------------
/settings/during_clean/801_python.sh:
--------------------------------------------------------------------------------
1 | ../extensions/python/during_clean.sh
--------------------------------------------------------------------------------
/settings/during_clean/804_nodejs.sh:
--------------------------------------------------------------------------------
1 | ../extensions/nodejs/during_clean.sh
--------------------------------------------------------------------------------
/settings/during_manual_start/022_000_setup_pythonpath.sh:
--------------------------------------------------------------------------------
1 | ../extensions/python/commands/add_project_to_pythonpath
--------------------------------------------------------------------------------
/settings/during_manual_start/024_000_python_ignores.sh:
--------------------------------------------------------------------------------
1 | ../extensions/python/commands/refresh_ignores
--------------------------------------------------------------------------------
/settings/during_manual_start/026_000_check_node_modules.sh:
--------------------------------------------------------------------------------
1 | # check if file exists
2 | if [[ -f "$FORNIX_COMMANDS_FOLDER/tools/nodejs/check_node_modules" ]]
3 | then
4 | "$FORNIX_COMMANDS_FOLDER/tools/nodejs/check_node_modules"
5 | fi
--------------------------------------------------------------------------------
/settings/during_manual_start/081_000__ensure_all_commands_executable__.sh:
--------------------------------------------------------------------------------
1 | ../extensions/#standard/commands/tools/fornix/ensure_all_commands_executable
--------------------------------------------------------------------------------
/settings/during_manual_start/083_000_add_node_bin.sh:
--------------------------------------------------------------------------------
1 | # connect the bin folder
2 | export PATH="$PATH:$FORNIX_FOLDER/node_modules/.bin"
--------------------------------------------------------------------------------
/settings/during_purge/580_mac_library_caches.sh:
--------------------------------------------------------------------------------
1 | ../extensions/os_mac/during_purge.sh
--------------------------------------------------------------------------------
/settings/during_purge/802_remove_venv.sh:
--------------------------------------------------------------------------------
1 | ../extensions/python/during_purge.sh
--------------------------------------------------------------------------------
/settings/during_purge/805_remove_node_modules.sh:
--------------------------------------------------------------------------------
1 | ../extensions/nodejs/during_purge.sh
--------------------------------------------------------------------------------
/settings/during_start/000_009__add_path_injections__.sh:
--------------------------------------------------------------------------------
1 | # make this the lowest priority (will be overridden by commands)
2 | PATH="$PATH:$FORNIX_FOLDER/settings/.cache/path_injection"
--------------------------------------------------------------------------------
/settings/during_start/001_000__setup_zsh__.sh:
--------------------------------------------------------------------------------
1 | #
2 | # import paths from nix
3 | #
4 | zsh_syntax_highlighting__path="$("$__FORNIX_NIX_COMMANDS/package_path_for" zsh-syntax-highlighting)"
5 | zsh_auto_suggest__path="$("$__FORNIX_NIX_COMMANDS/package_path_for" zsh-autosuggestions)"
6 | spaceship_prompt__path="$("$__FORNIX_NIX_COMMANDS/package_path_for" spaceship-prompt)"
7 | oh_my_zsh__path="$("$__FORNIX_NIX_COMMANDS/package_path_for" oh-my-zsh)"
8 | zsh__path="$("$__FORNIX_NIX_COMMANDS/package_path_for" zsh)"
9 |
10 | #
11 | # set fpath for zsh
12 | #
13 | local_zsh="$FORNIX_FOLDER/settings/.cache/zsh.do_not_sync/site-functions/"
14 | mkdir -p "$local_zsh"
15 |
16 | export fpath=("$local_zsh")
17 | export fpath=("$oh_my_zsh__path"/share/oh-my-zsh/functions $fpath)
18 | export fpath=("$oh_my_zsh__path"/share/oh-my-zsh/completions $fpath)
19 | export fpath=("$zsh__path"/share/zsh/site-functions $fpath)
20 | export fpath=("$zsh__path"/share/zsh/*/functions $fpath)
21 |
22 | # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
23 | ZSH_THEME="robbyrussell" # default
24 |
25 | #
26 | # add spaceship-prompt theme
27 | #
28 | ln -fs "$spaceship_prompt__path/lib/spaceship-prompt/spaceship.zsh" "$local_zsh"prompt_spaceship_setup
29 |
30 | export ZSH="$oh_my_zsh__path/share/oh-my-zsh"
31 | . "$ZSH/oh-my-zsh.sh"
32 |
33 | #
34 | # enable syntax highlighing
35 | #
36 | export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR="$zsh_syntax_highlighting__path/share/zsh-syntax-highlighting/highlighters"
37 | . "$ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR/../zsh-syntax-highlighting.zsh"
38 |
39 | #
40 | # enable auto suggestions
41 | #
42 | . "$zsh_auto_suggest__path/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
43 |
44 | SPACESHIP_CHAR_SYMBOL="∫ " # ☣ ⁂ ⌘ ∴ ∮ ֎ Ͽ ♫ ⛬ ⚿ ♦ ♢ ⛶ ✾ ❒ ⟩ ⟡ ⟜ ⟦ ⦊ ⦒ ⪢ ⪾ ∫ ∬ ∭
45 |
46 | # Set Spaceship ZSH as a prompt
47 | autoload -U promptinit; promptinit
48 | prompt spaceship
49 |
50 | # enable auto complete
51 | autoload -Uz compinit
52 | compinit
53 |
54 | autoload bashcompinit
55 | bashcompinit
56 |
57 | unalias -m '*' # remove all default aliases
--------------------------------------------------------------------------------
/settings/during_start/001_010__setup_nix_path__.sh:
--------------------------------------------------------------------------------
1 | #
2 | # import paths from nix
3 | #
4 | export NIX_PATH="$HOME/.nix-defexpr/channels"
--------------------------------------------------------------------------------
/settings/during_start/001_010_enable_globbing.sh:
--------------------------------------------------------------------------------
1 | #
2 | # for zsh
3 | #
4 | setopt extended_glob &>/dev/null
5 |
6 | #
7 | # for bash
8 | #
9 | # allow ** to search directories
10 | shopt -s globstar &>/dev/null
11 | # globbing can see hidden files
12 | shopt -s dotglob &>/dev/null
--------------------------------------------------------------------------------
/settings/during_start/004_000_add_system_bin.sh:
--------------------------------------------------------------------------------
1 | # make this the lowest priority (will be overridden by commands)
2 | PATH="$PATH:/usr/bin"
3 | export PATH="$PATH/$HOME/.local/bin"
--------------------------------------------------------------------------------
/settings/during_start/005_000__setup_ld_path__.sh:
--------------------------------------------------------------------------------
1 | # add the path to the c lib, which prevents the libstdc++.so.6 errors
2 | export LD_LIBRARY_PATH="$("$__FORNIX_NIX_COMMANDS/lib_path_for" "cc"):$LD_LIBRARY_PATH"
3 | # add these for opencv/numpy
4 | export LD_LIBRARY_PATH="$("$__FORNIX_NIX_COMMANDS/lib_path_for" libglvnd):$LD_LIBRARY_PATH"
5 | export LD_LIBRARY_PATH="$("$__FORNIX_NIX_COMMANDS/lib_path_for" glib):$LD_LIBRARY_PATH"
6 |
--------------------------------------------------------------------------------
/settings/during_start/010_000__ssl_fix__.sh:
--------------------------------------------------------------------------------
1 | ../extensions/nix/during_start.sh
--------------------------------------------------------------------------------
/settings/during_start/019_000_setup_python_venv.sh:
--------------------------------------------------------------------------------
1 | ../extensions/python/commands/setup_venv
--------------------------------------------------------------------------------
/settings/during_start/021_000_ensure_pip_modules.sh:
--------------------------------------------------------------------------------
1 | ../extensions/python/commands/ensure_pip_modules
--------------------------------------------------------------------------------
/settings/during_start/022_000_setup_pythonpath.sh:
--------------------------------------------------------------------------------
1 | ../extensions/python/commands/add_project_to_pythonpath
--------------------------------------------------------------------------------
/settings/during_start/024_000_python_ignores.sh:
--------------------------------------------------------------------------------
1 | ../extensions/python/commands/refresh_ignores
--------------------------------------------------------------------------------
/settings/during_start/02600_check_node_modules.sh:
--------------------------------------------------------------------------------
1 | # check if file exists
2 | if [[ -f "$FORNIX_COMMANDS_FOLDER/tools/nodejs/check_node_modules" ]]
3 | then
4 | "$FORNIX_COMMANDS_FOLDER/tools/nodejs/check_node_modules"
5 | fi
--------------------------------------------------------------------------------
/settings/during_start/026_000_check_node_modules.sh:
--------------------------------------------------------------------------------
1 | # check if file exists
2 | if [[ -f "$FORNIX_COMMANDS_FOLDER/tools/nodejs/check_node_modules" ]]
3 | then
4 | "$FORNIX_COMMANDS_FOLDER/tools/nodejs/check_node_modules"
5 | fi
--------------------------------------------------------------------------------
/settings/during_start/081_000__ensure_all_commands_executable__.sh:
--------------------------------------------------------------------------------
1 | ../extensions/#standard/commands/tools/fornix/ensure_all_commands_executable
--------------------------------------------------------------------------------
/settings/during_start/082_000_add_commands_to_path.sh:
--------------------------------------------------------------------------------
1 | # add commands to path
2 | PATH="$FORNIX_COMMANDS_FOLDER:$PATH"
3 |
4 | # if theres a help command
5 | if [[ -f "$FORNIX_COMMANDS_FOLDER/help" ]]; then
6 | # override the default bash "help"
7 | alias help="$FORNIX_COMMANDS_FOLDER/help"
8 | fi
--------------------------------------------------------------------------------
/settings/during_start/08300_add_node_bin.sh:
--------------------------------------------------------------------------------
1 | # connect the bin folder
2 | export PATH="$PATH:$FORNIX_FOLDER/node_modules/.bin"
--------------------------------------------------------------------------------
/settings/during_start/083_000_add_node_bin.sh:
--------------------------------------------------------------------------------
1 | # connect the bin folder
2 | export PATH="$PATH:$FORNIX_FOLDER/node_modules/.bin"
--------------------------------------------------------------------------------
/settings/during_start/083_100_npm_init.sh:
--------------------------------------------------------------------------------
1 | npm init -y
--------------------------------------------------------------------------------
/settings/during_start/090_000_run_project_commands.sh:
--------------------------------------------------------------------------------
1 | # check if file exists
2 | if [ -f "$FORNIX_COMMANDS_FOLDER/project/commands" ]
3 | then
4 | echo ""
5 | echo ""
6 | "$FORNIX_COMMANDS_FOLDER/project/commands"
7 | fi
--------------------------------------------------------------------------------
/settings/during_start/091_000_commands_function.sh:
--------------------------------------------------------------------------------
1 | # create the "commands" command if it doesnt exist
2 | commands () {
3 | # todo: ask if they want to see project commands or all commands
4 | question="are you sure you want to show all commands? [y/n]";answer=''
5 | while true; do
6 | echo "$question"; read response
7 | case "$response" in
8 | [Yy]* ) answer='yes'; break;;
9 | [Nn]* ) answer='no'; break;;
10 | * ) echo "Please answer yes or no.";;
11 | esac
12 | done
13 |
14 | if [[ "$answer" = 'yes' ]]; then
15 | # if tput exists
16 | if [ -n "$(command -v "tput")" ]
17 | then
18 | export COLOR_BLUE="$(tput setaf 4)"
19 | export COLOR_RED="$(tput setaf 1)"
20 | export COLOR_RESET="$(tput sgr0)"
21 | fi
22 |
23 |
24 | [ -n "$COLOR_BLUE" ] && echo "$COLOR_BLUE"
25 | echo "#"
26 | echo "# built-ins"
27 | echo "#"
28 | [ -n "$COLOR_BLUE" ] && echo "$COLOR_RESET"
29 | compgen -b | sed 's/^/ /' # will list all the built-ins you could run.
30 |
31 |
32 |
33 | [ -n "$COLOR_BLUE" ] && echo "$COLOR_BLUE"
34 | echo "#"
35 | echo "# keywords"
36 | echo "#"
37 | [ -n "$COLOR_BLUE" ] && echo "$COLOR_RESET"
38 | compgen -k | sed 's/^/ /' # will list all the keywords you could run.
39 |
40 |
41 |
42 | [ -n "$COLOR_BLUE" ] && echo "$COLOR_BLUE"
43 | echo "#"
44 | echo "# functions"
45 | echo "#"
46 | [ -n "$COLOR_BLUE" ] && echo "$COLOR_RESET"
47 | compgen -A function | sed 's/^/ /'
48 |
49 |
50 |
51 | [ -n "$COLOR_BLUE" ] && echo "$COLOR_BLUE"
52 | echo "#"
53 | echo "# aliases"
54 | echo "#"
55 | [ -n "$COLOR_BLUE" ] && echo "$COLOR_RESET"
56 | compgen -a | sed 's/^/ /' # will list all the aliases you could run.
57 |
58 |
59 |
60 | [ -n "$COLOR_BLUE" ] && echo "$COLOR_BLUE"
61 | echo "#"
62 | echo "# executables"
63 | echo "#"
64 | [ -n "$COLOR_BLUE" ] && echo "$COLOR_RESET"
65 | compgen -c | sed 's/^/ /'
66 |
67 | else
68 | echo "okay"
69 | fi
70 | }
71 |
--------------------------------------------------------------------------------
/settings/during_start/092_000_doit_function.sh:
--------------------------------------------------------------------------------
1 | doit () {
2 | # sudo but preserve path and other env vars
3 | sudo -E env "PATH=$PATH" "$@"
4 | }
--------------------------------------------------------------------------------
/settings/during_start/092_000_resume_function.sh:
--------------------------------------------------------------------------------
1 | # quick command for resuming paused processes
2 | # (paused using ctrl+z)
3 | resume () {
4 | if [[ -z "$1" ]]
5 | then
6 | which_process="%1"
7 | else
8 | which_process="$1"
9 | fi
10 | kill -s CONT "$which_process"
11 | fg "$which_process"
12 | }
13 |
--------------------------------------------------------------------------------
/settings/during_start/095_000_customize_tree_function.sh:
--------------------------------------------------------------------------------
1 | function tree {
2 | "$("$__FORNIX_NIX_COMMANDS/package_path_for" tree)/bin/tree" -C --dirsfirst -A -F --noreport "$@"
3 | }
--------------------------------------------------------------------------------
/settings/during_start/099_050_finish_spaceship_setup_.sh:
--------------------------------------------------------------------------------
1 | SPACESHIP_VENV_SYMBOL="🐍$(python -V 2>&1 | sed -E 's/Python//g' )"
2 | SPACESHIP_VENV_PREFIX=""
3 | SPACESHIP_VENV_GENERIC_NAMES="."
4 | SPACESHIP_VENV_COLOR="green"
5 | SPACESHIP_NODE_COLOR="yellow"
--------------------------------------------------------------------------------
/settings/during_start_prep/010_000_setting_up_env_message.sh:
--------------------------------------------------------------------------------
1 | # if no arguments (just starting up the shell)
2 | if [ -z "$FORNIX_ARGS" ]
3 | then
4 | echo "=============================="
5 | echo " Setting up your Environment!"
6 | echo "=============================="
7 | fi
--------------------------------------------------------------------------------
/settings/during_start_prep/032_000_link_pnpm_store.sh:
--------------------------------------------------------------------------------
1 | ../extensions/nodejs/during_start_prep.sh
--------------------------------------------------------------------------------
/settings/during_start_prep/049_000_link_keychain.sh:
--------------------------------------------------------------------------------
1 | ../extensions/os_mac/during_start_prep.sh
--------------------------------------------------------------------------------
/settings/during_start_prep/051_000_copy_git_config.sh:
--------------------------------------------------------------------------------
1 | ../extensions/git/during_start_prep.sh
--------------------------------------------------------------------------------
/settings/during_start_prep/052_000_copy_npmrc.sh:
--------------------------------------------------------------------------------
1 | # copy in .npmrc before changing home var
2 | cp "$HOME/.npmrc" "$FORNIX_HOME/.npmrc" 2>/dev/null
3 |
4 | # make sure the user has this in their .npmrc
5 | # (it could contain passwords/keys)
6 | "$FORNIX_FOLDER/settings/extensions/git/commands/ignore" "$FORNIX_HOME/.npmrc"
7 |
--------------------------------------------------------------------------------
/settings/during_start_prep/053_000_copy_vsce.sh:
--------------------------------------------------------------------------------
1 | # copy in .vsce before changing home var
2 | cp "$HOME/.vsce" "$FORNIX_HOME/.vsce" 2>/dev/null
3 |
4 | # make sure the user has this in their .vsce
5 | # (it could contain passwords/keys)
6 | "$FORNIX_FOLDER/settings/extensions/git/commands/ignore" "$FORNIX_HOME/.vsce"
7 |
--------------------------------------------------------------------------------
/settings/during_start_prep/060_010_link_deno_store.sh:
--------------------------------------------------------------------------------
1 | # connect the deno cache to prevent wasted duplicates
2 |
3 | if ! [ "$HOME" = "$FORNIX_HOME" ]
4 | then
5 | __temp_var__real_home_cache_dir=""
6 | __temp_var__project_home_cache_dir=""
7 |
8 | #
9 | # MacOS
10 | #
11 | if [ "$(uname)" = "Darwin" ]
12 | then
13 | __temp_var__real_home_cache_dir="$HOME/Library/Caches"
14 | __temp_var__project_home_cache_dir="$FORNIX_HOME/Library/Caches"
15 | #
16 | # Linux
17 | #
18 | else
19 | __temp_var__real_home_cache_dir="$HOME/.cache"
20 | __temp_var__project_home_cache_dir="$FORNIX_HOME/.cache"
21 | fi
22 |
23 | # folder we want to connect
24 | __temp_var__what_to_connect="deno/deps"
25 | __temp_var__main="$__temp_var__real_home_cache_dir/$__temp_var__what_to_connect"
26 | __temp_var__project="$__temp_var__project_home_cache_dir/$__temp_var__what_to_connect"
27 |
28 | # make the real home folder if it doesn't exist
29 | if ! [ -d "$__temp_var__main" ]
30 | then
31 | # remove if corrupted
32 | rm -f "$__temp_var__main" 2>/dev/null
33 | # make sure its a folder
34 | mkdir -p "$__temp_var__main"
35 | fi
36 |
37 | # remove whatever project one might be in the way
38 | rm -rf "$__temp_var__project" 2>/dev/null
39 | # ensure parent folders exist (*could fail if part of the path is a file)
40 | mkdir -p "$(dirname "$__temp_var__project")"
41 | # create link
42 | ln -sf "$__temp_var__main" "$__temp_var__project"
43 |
44 | # clean up
45 | unset __temp_var__project
46 | unset __temp_var__main
47 | unset __temp_var__project_home_cache_dir
48 | unset __temp_var__real_home_cache_dir
49 | unset __temp_var__what_to_connect
50 | fi
--------------------------------------------------------------------------------
/settings/during_start_prep/060_010_link_nix_channel.sh:
--------------------------------------------------------------------------------
1 | if ! [ "$HOME" = "$FORNIX_HOME" ]
2 | then
3 | #
4 | # MacOS
5 | #
6 | if [ "$(uname)" = "Darwin" ]
7 | then
8 | __temp_var__main="$HOME/.nix-defexpr/channels"
9 | __temp_var__project="$FORNIX_HOME/.nix-defexpr/channels"
10 | #
11 | # Linux
12 | #
13 | else
14 | __temp_var__main="$HOME/.nix-defexpr/channels"
15 | __temp_var__project="$FORNIX_HOME/.nix-defexpr/channels"
16 | fi
17 |
18 | # remove whatever project one might be in the way
19 | rm -f "$__temp_var__project" 2>/dev/null
20 | # ensure parent folders exist (*could fail if part of the path is a file)
21 | mkdir -p "$(dirname "$__temp_var__project")"
22 | # create link
23 | ln -sf "$__temp_var__main" "$__temp_var__project"
24 |
25 | # clean up
26 | unset __temp_var__project
27 | unset __temp_var__main
28 | fi
--------------------------------------------------------------------------------
/settings/during_start_prep/060_010_link_tealdeer.sh:
--------------------------------------------------------------------------------
1 | # connect the tealdeer cache to prevent wasted duplicates
2 |
3 | if ! [ "$HOME" = "$FORNIX_HOME" ]
4 | then
5 | #
6 | # MacOS
7 | #
8 | if [ "$(uname)" = "Darwin" ]
9 | then
10 | __temp_var__main="$HOME/Library/Caches/tealdeer"
11 | __temp_var__project="$FORNIX_HOME/Library/Caches/tealdeer"
12 | #
13 | # Linux
14 | #
15 | else
16 | __temp_var__main="$HOME/.cache/tldr"
17 | __temp_var__project="$FORNIX_HOME/.cache/tldr"
18 | fi
19 |
20 | # make the real home folder if it doesn't exist
21 | if ! [ -d "$__temp_var__main" ]
22 | then
23 | # remove if corrupted
24 | rm -f "$__temp_var__main" 2>/dev/null
25 | # make sure its a folder
26 | mkdir -p "$__temp_var__main"
27 | fi
28 |
29 | # remove whatever project one might be in the way
30 | rm -rf "$__temp_var__project" 2>/dev/null
31 | # ensure parent folders exist (*could fail if part of the path is a file)
32 | mkdir -p "$(dirname "$__temp_var__project")"
33 | # create link
34 | ln -sf "$__temp_var__main" "$__temp_var__project"
35 |
36 | # clean up
37 | unset __temp_var__project
38 | unset __temp_var__main
39 | fi
--------------------------------------------------------------------------------
/settings/during_start_prep/089_000__sudo_injection__.sh:
--------------------------------------------------------------------------------
1 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/fornix/inject_into_path" "sudo"
--------------------------------------------------------------------------------
/settings/during_start_prep/091_000__logger_injection__.sh:
--------------------------------------------------------------------------------
1 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/fornix/inject_into_path" "logger"
--------------------------------------------------------------------------------
/settings/during_start_prep/095_000_vim_injection.sh:
--------------------------------------------------------------------------------
1 | which vim &>/dev/null && "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/fornix/inject_into_path" "vim"
--------------------------------------------------------------------------------
/settings/during_start_prep/096_000_vscode_injection.sh:
--------------------------------------------------------------------------------
1 | which code &>/dev/null && "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/fornix/inject_into_path" "code"
--------------------------------------------------------------------------------
/settings/during_start_prep/097_000_atom_injection.sh:
--------------------------------------------------------------------------------
1 | which atom &>/dev/null && "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/fornix/inject_into_path" "atom"
--------------------------------------------------------------------------------
/settings/extensions/#standard/#establish_extension.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # default to allowing unfree
4 | export NIXPKGS_ALLOW_UNFREE=1
5 | relatively_link="$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/relative_link"
6 |
7 | #
8 | # create basics
9 | #
10 | mkdir -p "$FORNIX_FOLDER/settings/.cache/"
11 | mkdir -p "$FORNIX_FOLDER/settings/during_purge/"
12 | mkdir -p "$FORNIX_FOLDER/settings/during_clean/"
13 |
14 | #
15 | # connect during_start/during_manual_start
16 | #
17 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands/tools/fornix/ensure_all_commands_executable" "$FORNIX_FOLDER/settings/during_start/081_000__ensure_all_commands_executable__.sh"
18 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands/tools/fornix/ensure_all_commands_executable" "$FORNIX_FOLDER/settings/during_manual_start/081_000__ensure_all_commands_executable__.sh"
19 |
20 | #
21 | # connect commands
22 | #
23 | # ensure commands folder exists
24 | if ! [ -d "$FORNIX_COMMANDS_FOLDER" ]
25 | then
26 | # remove a potenial file
27 | rm -f "$FORNIX_COMMANDS_FOLDER"
28 | # make the folder
29 | mkdir -p "$FORNIX_COMMANDS_FOLDER"
30 | fi
31 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands/tools/fornix" "$FORNIX_COMMANDS_FOLDER/tools/fornix"
32 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands/tools/string" "$FORNIX_COMMANDS_FOLDER/tools/string"
33 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands/tools/file_system" "$FORNIX_COMMANDS_FOLDER/tools/file_system"
34 |
35 | #
36 | # flush broken symlinks (for when extensions are changed/removed)
37 | #
38 | for_each_item_in="$FORNIX_COMMANDS_FOLDER"; [ -z "$__NESTED_WHILE_COUNTER" ] && __NESTED_WHILE_COUNTER=0;__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER + 1))"; trap 'rm -rf "$__temp_var__temp_folder"' EXIT; __temp_var__temp_folder="$(mktemp -d)"; mkfifo "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER"; (find "$for_each_item_in" -xtype l -print0 2>/dev/null | sort -z > "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER" &); while read -d $'\0' each
39 | do
40 | rm -f "$each" 2>/dev/null
41 | done < "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER";__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER - 1))"
42 |
43 | for_each_item_in="$FORNIX_FOLDER/during_start"; [ -z "$__NESTED_WHILE_COUNTER" ] && __NESTED_WHILE_COUNTER=0;__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER + 1))"; trap 'rm -rf "$__temp_var__temp_folder"' EXIT; __temp_var__temp_folder="$(mktemp -d)"; mkfifo "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER"; (find "$for_each_item_in" -xtype l -print0 2>/dev/null | sort -z > "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER" &); while read -d $'\0' each
44 | do
45 | rm -f "$each" 2>/dev/null
46 | done < "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER";__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER - 1))"
47 |
48 | for_each_item_in="$FORNIX_FOLDER/during_start_prep"; [ -z "$__NESTED_WHILE_COUNTER" ] && __NESTED_WHILE_COUNTER=0;__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER + 1))"; trap 'rm -rf "$__temp_var__temp_folder"' EXIT; __temp_var__temp_folder="$(mktemp -d)"; mkfifo "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER"; (find "$for_each_item_in" -xtype l -print0 2>/dev/null | sort -z > "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER" &); while read -d $'\0' each
49 | do
50 | rm -f "$each" 2>/dev/null
51 | done < "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER";__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER - 1))"
52 |
53 | for_each_item_in="$FORNIX_FOLDER/during_manual_start"; [ -z "$__NESTED_WHILE_COUNTER" ] && __NESTED_WHILE_COUNTER=0;__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER + 1))"; trap 'rm -rf "$__temp_var__temp_folder"' EXIT; __temp_var__temp_folder="$(mktemp -d)"; mkfifo "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER"; (find "$for_each_item_in" -xtype l -print0 2>/dev/null | sort -z > "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER" &); while read -d $'\0' each
54 | do
55 | rm -f "$each" 2>/dev/null
56 | done < "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER";__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER - 1))"
57 |
58 | for_each_item_in="$FORNIX_FOLDER/during_clean"; [ -z "$__NESTED_WHILE_COUNTER" ] && __NESTED_WHILE_COUNTER=0;__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER + 1))"; trap 'rm -rf "$__temp_var__temp_folder"' EXIT; __temp_var__temp_folder="$(mktemp -d)"; mkfifo "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER"; (find "$for_each_item_in" -xtype l -print0 2>/dev/null | sort -z > "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER" &); while read -d $'\0' each
59 | do
60 | rm -f "$each" 2>/dev/null
61 | done < "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER";__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER - 1))"
62 |
63 | for_each_item_in="$FORNIX_FOLDER/during_purge"; [ -z "$__NESTED_WHILE_COUNTER" ] && __NESTED_WHILE_COUNTER=0;__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER + 1))"; trap 'rm -rf "$__temp_var__temp_folder"' EXIT; __temp_var__temp_folder="$(mktemp -d)"; mkfifo "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER"; (find "$for_each_item_in" -xtype l -print0 2>/dev/null | sort -z > "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER" &); while read -d $'\0' each
64 | do
65 | rm -f "$each" 2>/dev/null
66 | done < "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER";__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER - 1))"
67 |
68 | for_each_item_in="$FORNIX_FOLDER/requirements"; [ -z "$__NESTED_WHILE_COUNTER" ] && __NESTED_WHILE_COUNTER=0;__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER + 1))"; trap 'rm -rf "$__temp_var__temp_folder"' EXIT; __temp_var__temp_folder="$(mktemp -d)"; mkfifo "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER"; (find "$for_each_item_in" -xtype l -print0 2>/dev/null | sort -z > "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER" &); while read -d $'\0' each
69 | do
70 | rm -f "$each" 2>/dev/null
71 | done < "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER";__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER - 1))"
72 |
73 | unset relatively_link
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/file_system/add_execute_permission:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env -S deno run --allow-all
2 | const { run, Timeout, Env, Cwd, Stdin, Stdout, Stderr, Out, Overwrite, AppendTo, zipInto, mergeInto, returnAsString, } = await import(`https://deno.land/x/quickr@0.3.20/main/run.js`)
3 | const { FileSystem } = await import(`https://deno.land/x/quickr@0.3.20/main/file_system.js`)
4 |
5 | //
6 | // args
7 | //
8 | let [ fileOrFolderPath ] = Deno.args
9 |
10 | //
11 | // run
12 | //
13 | await FileSystem.addPermissions({
14 | path: fileOrFolderPath,
15 | recursively: true,
16 | permissions: {
17 | owner: {
18 | canExecute: true,
19 | },
20 | }
21 | })
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/file_system/copy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | thing_that_exists="$1"
3 | thing_that_doesnt="$2"
4 |
5 | if ! [ -e "$thing_that_exists" ]
6 | then
7 | echo "tried to copy '$thing_that_exists' but it doesn't seem to exist" 1>&2
8 | else
9 | if [ -d "$thing_that_exists" ]
10 | then
11 | # clear the way
12 | rm -f "$thing_that_doesnt" 2>/dev/null
13 | rm -rf "$thing_that_doesnt" 2>/dev/null
14 | # copy the folder
15 | cp -r "$thing_that_exists" "$thing_that_doesnt"
16 | else
17 | # clear the way
18 | rm -f "$thing_that_doesnt" 2>/dev/null
19 | rm -rf "$thing_that_doesnt" 2>/dev/null
20 | # copy the file
21 | cp "$thing_that_exists" "$thing_that_doesnt"
22 | fi
23 | fi
24 |
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/file_system/relative_link:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | existing_filepath="$1"
3 | target_filepath="$2"
4 |
5 | #
6 | # ensure FORNIX_FOLDER exists
7 | #
8 | if [ -z "$FORNIX_FOLDER" ]
9 | then
10 | #
11 | # find fornix_core
12 | #
13 | path_to_file=""
14 | file_name="settings/fornix_core"
15 | folder_to_look_in="$PWD"
16 | while :
17 | do
18 | # check if file exists
19 | if [ -f "$folder_to_look_in/$file_name" ]
20 | then
21 | path_to_file="$folder_to_look_in/$file_name"
22 | break
23 | else
24 | if [ "$folder_to_look_in" = "/" ]
25 | then
26 | break
27 | else
28 | folder_to_look_in="$(dirname "$folder_to_look_in")"
29 | fi
30 | fi
31 | done
32 | if [ -z "$path_to_file" ]
33 | then
34 | #
35 | # what to do if file never found
36 | #
37 | echo "Im a script running with a pwd of:$PWD"
38 | echo "Im looking for settings/fornix_core in a parent folder"
39 | echo "Im exiting now because I wasnt able to find it"
40 | echo "thats all the information I have"
41 | exit
42 | fi
43 | export FORNIX_NEXT_RUN_ONLY_DO_BASIC_INIT="true"
44 | # run the basic init of fornix to get the FORNIX_FOLDER/FORNIX_COMMANDS_FOLDER/FORNIX_HOME etc
45 | . "$path_to_file"
46 | fi
47 |
48 |
49 | #
50 | # make existing_filepath absolute
51 | #
52 | case "$existing_filepath" in
53 | # if absolute
54 | /*) : ;;
55 | # if relative
56 | *) existing_filepath="$FORNIX_FOLDER/$existing_filepath" ;;
57 | esac
58 |
59 | #
60 | # make target_filepath absolute
61 | #
62 | case "$target_filepath" in
63 | # if absolute
64 | /*) : ;;
65 | # if relative
66 | *) target_filepath="$FORNIX_FOLDER/$target_filepath" ;;
67 | esac
68 |
69 | # remove existing things in the way
70 | rm -f "$target_filepath" 2>/dev/null
71 | rm -rf "$target_filepath" 2>/dev/null
72 | # make sure parent folder exists
73 | mkdir -p "$(dirname "$target_filepath")"
74 | __temp_var__relative_part="$(realpath "$(dirname "$existing_filepath")" --relative-to="$(dirname "$target_filepath")" --canonicalize-missing)"
75 | __temp_var__relative_path="$__temp_var__relative_part/$(basename "$existing_filepath")"
76 | # link using the relative path
77 | if [ -d "$existing_filepath" ]
78 | then
79 | ln -s "$__temp_var__relative_path/" "$target_filepath"
80 | else
81 | ln -s "$__temp_var__relative_path" "$target_filepath"
82 | fi
83 | unset __temp_var__relative_path
84 | unset __temp_var__relative_part
85 | unset existing_filepath
86 | unset target_filepath
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/file_system/remove:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | function escape_sed_regex() {
3 | sed 's/[][\.|$(){}?+*^]/\\&/g' <<< "$*" | sed 's|/|\\/|g'
4 | }
5 |
6 | if [ -f "$1" ]
7 | then
8 | rm -fv "$1" | sed -e 's/^removed (directory )?'"'$(escape_sed_regex "$FORNIX_FOLDER")"'/removed ./'
9 | else
10 | rm -rfv "$1" | sed 's/^removed (directory )?'"'$(escape_sed_regex "$FORNIX_FOLDER")"'/removed ./'
11 | fi
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/file_system/storage:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | if [[ "$1" = "." ]]
3 | then
4 | du -sh "./"*
5 | GLOBIGNORE=".:.." du -sh "./."*
6 | else
7 | if [[ -d "$1" ]]
8 | then
9 | du -sh "$1"
10 | elif [[ -f "$1" ]]
11 | then
12 | ls -lh "$1"
13 | else
14 | echo "total remaining storage:"
15 | df -h /
16 | fi
17 | fi
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/fornix/basic_init_example:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #
4 | # ensure FORNIX_FOLDER exists
5 | #
6 | if [ -z "$FORNIX_FOLDER" ]
7 | then
8 | #
9 | # find fornix_core
10 | #
11 | path_to_file=""
12 | file_name="settings/fornix_core"
13 | folder_to_look_in="$PWD"
14 | while :
15 | do
16 | # check if file exists
17 | if [ -f "$folder_to_look_in/$file_name" ]
18 | then
19 | path_to_file="$folder_to_look_in/$file_name"
20 | break
21 | else
22 | if [ "$folder_to_look_in" = "/" ]
23 | then
24 | break
25 | else
26 | folder_to_look_in="$(dirname "$folder_to_look_in")"
27 | fi
28 | fi
29 | done
30 | if [ -z "$path_to_file" ]
31 | then
32 | #
33 | # what to do if file never found
34 | #
35 | echo "Im a script running with a pwd of:$PWD"
36 | echo "Im looking for settings/fornix_core in a parent folder"
37 | echo "Im exiting now because I wasnt able to find it"
38 | echo "thats all the information I have"
39 | exit
40 | fi
41 | export FORNIX_NEXT_RUN_ONLY_DO_BASIC_INIT="true"
42 | # run the basic init of fornix to get the FORNIX_FOLDER/FORNIX_COMMANDS_FOLDER/FORNIX_HOME etc
43 | . "$path_to_file"
44 | fi
45 |
46 | #
47 | #
48 | # [ actual program code here ]
49 | #
50 | #
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/fornix/create_wrapped_command:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #
4 | # find fornix if needed
5 | #
6 | if ! [ -d "$FORNIX_FOLDER" ]
7 | then
8 | path_to_file=""
9 | file_name="settings/fornix_core"
10 | folder_to_look_in="$PWD"
11 | while :
12 | do
13 | # check if file exists
14 | if [ -f "$folder_to_look_in/$file_name" ]
15 | then
16 | path_to_file="$folder_to_look_in/$file_name"
17 | break
18 | else
19 | if [ "$folder_to_look_in" = "/" ]
20 | then
21 | break
22 | else
23 | folder_to_look_in="$(dirname "$folder_to_look_in")"
24 | fi
25 | fi
26 | done
27 | if [ -z "$path_to_file" ]
28 | then
29 | #
30 | # what to do if file never found
31 | #
32 | echo "Im a script (create_manual_command)"
33 | echo "with a pwd of:$PWD"
34 | echo "Im looking for settings/fornix_core in a parent folder"
35 | echo "Im exiting now because I wasnt able to find it"
36 | echo "thats all the information I have"
37 | exit
38 | fi
39 | export FORNIX_FOLDER="$(dirname "$(dirname "$path_to_file")")"
40 | fi
41 |
42 | #
43 | # ensure folder exists
44 | #
45 | mkdir -p "$FORNIX_FOLDER/wrapped_commands"
46 |
47 | #
48 | # start creating the command
49 | #
50 | name_of_executable="$1"
51 | escaped_name_of_executable="$(printf '%s' "'$(printf '%s' "$name_of_executable" | sed 's/'"'"'/'"'"'"'"'"'"'"'"'/g')'")"
52 | read -r -d '' __temp_var__part1 <<'HEREDOC_NAME'
53 |
54 | #
55 | # if fornix isnt defined, then find it
56 | #
57 | if [ -z "$FORNIX_FOLDER" ]
58 | then
59 | path_to_file=""
60 | file_name="settings/fornix_core"
61 | folder_to_look_in="$PWD"
62 | while :
63 | do
64 | # check if file exists
65 | if [ -f "$folder_to_look_in/$file_name" ]
66 | then
67 | path_to_file="$folder_to_look_in/$file_name"
68 | break
69 | else
70 | if [ "$folder_to_look_in" = "/" ]
71 | then
72 | break
73 | else
74 | folder_to_look_in="$(dirname "$folder_to_look_in")"
75 | fi
76 | fi
77 | done
78 | if [ -z "$path_to_file" ]
79 | then
80 | #
81 | # what to do if file never found
82 | #
83 | echo "Im a script running with a pwd of:$PWD"
84 | echo "Im looking for settings/fornix_core in a parent folder"
85 | echo "Im exiting now because I wasnt able to find it"
86 | echo "thats all the information I have"
87 | exit
88 | fi
89 | export FORNIX_NEXT_RUN_ONLY_DO_BASIC_INIT="true"
90 | . "$path_to_file"
91 | fi
92 |
93 |
94 | #
95 | # escape all arguments
96 | #
97 | args=""
98 | # for each argument (in a argument-might-have-spaces friendly way)
99 | for arg in "$@"; do
100 | # this escapes single quotes
101 | escaped_argument="$(printf '%s' "'$(printf '%s' "$arg" | sed 's/'"'"'/'"'"'"'"'"'"'"'"'/g')'")"
102 | args="$args $escaped_argument"
103 | done
104 |
105 | HEREDOC_NAME
106 |
107 | __temp_var__part2="
108 | name_of_executable=$escaped_name_of_executable
109 | "
110 |
111 | read -r -d '' __temp_var__part3 <<'HEREDOC_NAME'
112 |
113 | # might seem like this is being escaped twice, sadly its not
114 | escaped_name_of_executable="$(printf '%s' "'$(printf '%s' "$name_of_executable" | sed 's/'"'"'/'"'"'"'"'"'"'"'"'/g')'")"
115 | args="$escaped_name_of_executable $args"
116 | # wrap all the args inside another arg (double escaping single quotes... yeah its gonna be 200% illegible)
117 | zsh_arg="$(printf '%s' "'$(printf '%s' "$args" | sed 's/'"'"'/'"'"'"'"'"'"'"'"'/g')'")"
118 |
119 | #
120 | # run the command, inside nix-shell, inside zsh
121 | #
122 | HOME="$FORNIX_HOME" nix-shell --pure --run "zsh -c $zsh_arg" "$FORNIX_FOLDER/settings/requirements/shell.nix"
123 | HEREDOC_NAME
124 |
125 | #
126 | # create the command
127 | #
128 | mkdir -p "$FORNIX_FOLDER/wrapped_commands"
129 | echo "#!/usr/bin/env bash
130 | $__temp_var__part1
131 | $__temp_var__part2
132 | $__temp_var__part3
133 | " > "$FORNIX_FOLDER/wrapped_commands/$name_of_executable"
134 | # make it executable
135 | chmod ugo+x "$FORNIX_FOLDER/wrapped_commands/$name_of_executable" &>/dev/null || sudo chmod ugo+x "$FORNIX_FOLDER/wrapped_commands/$name_of_executable"
136 |
137 | echo "command created: ./wrapped_commands/$name_of_executable"
138 | echo "make sure to run the following at least once per session:"
139 | __fornix_folder_escaped="$(printf '%s' "'$(printf '%s' "$FORNIX_FOLDER" | sed 's/'"'"'/'"'"'"'"'"'"'"'"'/')'")"
140 | echo " export PATH=$__fornix_folder_escaped\"/wrapped_commands:\$PATH\""
141 |
142 | unset __temp_var__part1
143 | unset __temp_var__part2
144 | unset __temp_var__part3
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/fornix/ensure_all_commands_executable:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #
4 | # ensure FORNIX_FOLDER exists
5 | #
6 | if [ -z "$FORNIX_FOLDER" ]
7 | then
8 | #
9 | # find fornix_core
10 | #
11 | path_to_file=""
12 | file_name="settings/fornix_core"
13 | folder_to_look_in="$PWD"
14 | while :
15 | do
16 | # check if file exists
17 | if [ -f "$folder_to_look_in/$file_name" ]
18 | then
19 | path_to_file="$folder_to_look_in/$file_name"
20 | break
21 | else
22 | if [ "$folder_to_look_in" = "/" ]
23 | then
24 | break
25 | else
26 | folder_to_look_in="$(dirname "$folder_to_look_in")"
27 | fi
28 | fi
29 | done
30 | if [ -z "$path_to_file" ]
31 | then
32 | #
33 | # what to do if file never found
34 | #
35 | echo "Im a script running with a pwd of:$PWD"
36 | echo "Im looking for settings/fornix_core in a parent folder"
37 | echo "Im exiting now because I wasnt able to find it"
38 | echo "thats all the information I have"
39 | exit
40 | fi
41 | export FORNIX_NEXT_RUN_ONLY_DO_BASIC_INIT="true"
42 | # run the basic init of fornix to get the FORNIX_FOLDER/FORNIX_COMMANDS_FOLDER/FORNIX_HOME etc
43 | . "$path_to_file"
44 | fi
45 |
46 | #
47 | #
48 | # actual program
49 | #
50 | #
51 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/add_execute_permission" "$FORNIX_COMMANDS_FOLDER"
52 |
53 | #
54 | # create aliases for all of the folders to allow recursive execution
55 | #
56 | # yes its ugly, welcome to bash programming
57 | # this loop is so stupidly complicated because of many inherent-to-shell reasons, for example: https://stackoverflow.com/questions/13726764/while-loop-subshell-dilemma-in-bash
58 | for_each_item_in="$FORNIX_COMMANDS_FOLDER"
59 | [ -z "$__NESTED_WHILE_COUNTER" ] && __NESTED_WHILE_COUNTER=0;__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER + 1))"; trap 'rm -rf "$__temp_var__temp_folder"' EXIT; __temp_var__temp_folder="$(mktemp -d)"; mkfifo "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER"; (find "$for_each_item_in" -maxdepth 1 ! -path . -print0 2>/dev/null | sort -z > "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER" &); while read -d $'\0' each
60 | do
61 | # if its a folder
62 | if [[ -d "$each" ]]
63 | then
64 | name="$(basename "$each")"
65 | eval '
66 | '"$name"' () {
67 | # enable globbing
68 | setopt extended_glob &>/dev/null
69 | shopt -s globstar &>/dev/null
70 | shopt -s dotglob &>/dev/null
71 | local search_path='"'""$("$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/string/escape_shell_argument" "$each")"'/'"'"'
72 | local argument_combination="$search_path/$1"
73 | while [[ -n "$@" ]]
74 | do
75 | shift 1
76 | for each in "$search_path/"**/*
77 | do
78 | if [[ "$argument_combination" = "$each" ]]
79 | then
80 | # if its a folder, then we need to go deeper
81 | if [[ -d "$each" ]]
82 | then
83 | search_path="$each"
84 | argument_combination="$argument_combination/$1"
85 |
86 | # if there is no next argument
87 | if [[ -z "$1" ]]
88 | then
89 | printf "\nThat is a sub folder, not a command\nValid sub-commands are\n" 1>&2
90 | ls -1FL --group-directories-first --color "$each" | sed '"'"'s/^/ /'"'"' | sed -E '"'"'s/(\*|@)$/ /'"'"' 1>&2
91 | return 1 # error, no command
92 | fi
93 |
94 | break
95 | # if its a file, run it with the remaining arguments
96 | elif [[ -f "$each" ]]
97 | then
98 | "$each" "$@"
99 | # make exit status identical to executed program
100 | return $?
101 | fi
102 | fi
103 | done
104 | done
105 | # if an option was given
106 | if ! [ -z "$each" ]
107 | then
108 | echo "$each"
109 | printf "\nI could not find that sub-command\n" 1>&2
110 | fi
111 | printf "Valid next-arguments would be:\n" 1>&2
112 | ls -1FL --group-directories-first --color "$search_path" | sed '"'"'s/^/ /'"'"' | sed -E '"'"'s/(\*|@)$/ /'"'"' 1>&2
113 | return 1 # error, no command
114 | }
115 | __autocomplete_for__'"$name"' () {
116 | local commands_path='"'""$("$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/string/escape_shell_argument" "$FORNIX_COMMANDS_FOLDER")""'"'
117 | # TODO: make this space friendly
118 | # TODO: make this do partial-word complete
119 | function join_by { local d=${1-} f=${2-}; if shift 2; then printf %s "$f" "${@/#/$d}"; fi; }
120 | local item_path="$(join_by "/" $words)"
121 | if [ -d "$commands_path/$item_path" ]
122 | then
123 | compadd $(ls "$commands_path/$item_path")
124 | elif [ -d "$(dirname "$commands_path/$item_path")" ]
125 | then
126 | # check if file exists (finished completion)
127 | if ! [ -f "$commands_path/$item_path" ]
128 | then
129 | # TODO: add a better check for sub-matches "java" [tab] when "java" and "javascript" exist
130 | compadd $(ls "$(dirname "$commands_path/$item_path")")
131 | fi
132 | fi
133 | # echo "$(dirname "$commands_path/$item_path")"
134 | }
135 | compdef __autocomplete_for__'"$name"' '"$name"'
136 | ' > /dev/null
137 | fi
138 | done < "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER";__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER - 1))"
139 |
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/fornix/inject_into_path:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | function inject_into_path {
3 | # if it is an absolute path use it directly
4 | if [[ -f "$1" ]]
5 | then
6 | local system_path="$1"
7 | # if it is the name of a command, then find the path
8 | else
9 | local system_path="$(which "$1" 2>/dev/null)"
10 | fi
11 | # make sure its a file
12 | if [[ -f "$system_path" ]]; then
13 | mkdir -p "$FORNIX_FOLDER/settings/.cache/path_injection"
14 | # put it in the injections, and use the real home variable
15 | local new_executable="$FORNIX_FOLDER/settings/.cache/path_injection/$(basename "$system_path")"
16 | local current_home="$("$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/string/escape_shell_argument" "$HOME")"
17 | local current_path="$("$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/string/escape_shell_argument" "$PATH")"
18 | local escaped_system_path="$("$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/string/escape_shell_argument" "$system_path")"
19 | echo "#!/usr/bin/env bash
20 | HOME=$current_home PATH=$current_path $escaped_system_path "'"$@"' > "$new_executable"
21 | # make sure we can execute it
22 | chmod u+wrx "$new_executable"
23 | else
24 | echo "no system '$1' avalible for path injection (some stuff might break)"
25 | fi
26 | }
27 | inject_into_path "$@"
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/fornix/merge_all_templates:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | gc python && gm master && gp && \
3 | gc python_package && gm python && gp && \
4 | gc python_notebook && gm python && gp && \
5 | gc node && gm python && gp && \
6 | gc quik_github_pages && gm node && gp && \
7 | gc npm_package && gm node && gp && \
8 | gc vs_code_extension && gm npm_package && gp && \
9 | gc deno_package && gm master && gp && \
10 | gc pnpm && gm node && gp && \
11 | gc electron && gm node && gp && \
12 | gc prolog && gm master && gp && \
13 | gc ruby && gm master && gp && \
14 | gc rust && gm master && gp && \
15 | gc rust_druid && gm rust && gp && \
16 | gc rust_tauri && gm rust && gp && \
17 | gc textmate && gm npm_package && gp && \
18 | gc textmate && gm ruby && gp && \
19 | gc crystal && gm master && gp && \
20 | gc master
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/fornix/trigger:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # get the folder argument
4 | which_folder="$1"
5 | shift 1
6 |
7 | # eat up all the args before -- for forward compatibility
8 | # for each argument (in a argument-might-have-spaces friendly way)
9 | for arg in "$@"; do
10 | shift 1
11 | if [ "$arg" = "--" ]
12 | then
13 | break
14 | fi
15 | done
16 |
17 | #
18 | # find and run all the startup scripts in alphabetical order
19 | #
20 | # this loop is so stupidly complicated because of many inherent-to-shell reasons, for example: https://stackoverflow.com/questions/13726764/while-loop-subshell-dilemma-in-bash
21 | if [ "$FORNIX_DEBUG" = "true" ]; then
22 | echo "triggering: $(basename "$which_folder")"
23 | fi
24 | mkdir -p "$which_folder"
25 | for_each_item_in="$which_folder"
26 | [ -z "$__NESTED_WHILE_COUNTER" ] && __NESTED_WHILE_COUNTER=0;__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER + 1))"; trap 'rm -rf "$__temp_var__temp_folder"' EXIT; __temp_var__temp_folder="$(mktemp -d)"; mkfifo "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER"; (find -L "$for_each_item_in" ! -path . -print0 2>/dev/null | sort -z > "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER" &); while read -d $'\0' each
27 | do
28 | # check if file exists
29 | if [ -f "$each" ]
30 | then
31 | if [ "$FORNIX_DEBUG" = "true" ]
32 | then
33 | echo " loading: $each"
34 | fi
35 | . "$each" "$@"
36 | fi
37 | done < "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER";__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER - 1))"
38 | if [ "$FORNIX_DEBUG" = "true" ]; then
39 | echo "finished triggering: $(basename "$which_folder")"
40 | fi
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/string/escape_grep_regex:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | sed 's/[][\.|$(){}?+*^]/\\&/g' <<< "$*"
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/string/escape_shell_argument:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | printf '%s' "'$(printf '%s' "$1" | sed 's/'"'"'/'"'"'"'"'"'"'"'"'/g')'"
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/string/indent:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | __temp_var__indent="$2"
4 | if [ "$#" = "1" ]
5 | then
6 | __temp_var__indent=" {1,4}"
7 | fi
8 |
9 | printf '%s' "$1" sed 's/^/'"$__temp_var__indent"'/g'
10 | unset __temp_var__indent
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/string/remove_doublequotes:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | printf '%s' "$1" | sed -E 's/^"|"$//g'
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/string/remove_spaces_from_names:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | remove_spaces_from_names () {
4 | folder="$1"
5 | if [ -z "$folder" ]
6 | then
7 | echo "Please give a folder/file path" 1>&2
8 | fi
9 |
10 | replacement="$2"
11 | if [ -z "$replacement" ]
12 | then
13 | replacement="_"
14 | fi
15 |
16 | if ! [ -e "$folder" ]
17 | then
18 | echo "please give remove_spaces_from_names a valid file/folder path" 1>&2
19 | echo "'$folder' is neither" 1>&2
20 | else
21 | # do the top-level first
22 | each="$folder"
23 | each_without_spaces="$(echo "$each" | sed 's/ /'"$replacement"'/g')"
24 | # if it has spaces
25 | if ! [ "$each_without_spaces" = "$each" ]
26 | then
27 | # rename it
28 | mv "$each" "$each_without_spaces"
29 | fi
30 |
31 | # do inner next (recursively)
32 | if [ -d "$folder" ]
33 | then
34 | # this loop is so stupidly complicated because of many inherent-to-shell reasons, for example: https://stackoverflow.com/questions/13726764/while-loop-subshell-dilemma-in-bash
35 | for_each_item_in="$folder"; [ -z "$__NESTED_WHILE_COUNTER" ] && __NESTED_WHILE_COUNTER=0;__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER + 1))"; trap 'rm -rf "$__temp_var__temp_folder"' EXIT; __temp_var__temp_folder="$(mktemp -d)"; mkfifo "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER"; (find "$for_each_item_in" -maxdepth 1 ! -path "$for_each_item_in" -print0 2>/dev/null | sort -z > "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER" &); while read -d $'\0' each
36 | do
37 | remove_spaces_from_names "$each" "$replacement"
38 | done < "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER";__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER - 1))"
39 | fi
40 | fi
41 | }
42 | remove_spaces_from_names "$1" "$2"
--------------------------------------------------------------------------------
/settings/extensions/#standard/commands/tools/string/unindent:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | __temp_var__indent="$2"
4 | if [ "$#" = "1" ]
5 | then
6 | __temp_var__indent=" {1,4}"
7 | fi
8 |
9 | printf '%s' "$1" sed 's/^'"$__temp_var__indent"'//g'
10 | unset __temp_var__indent
--------------------------------------------------------------------------------
/settings/extensions/git/#establish_extension.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # this is a helper
4 | relatively_link="$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/relative_link"
5 |
6 | #
7 | # connect during_clean
8 | #
9 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/during_clean.sh" "$FORNIX_FOLDER/settings/during_clean/500_git.sh"
10 |
11 | #
12 | # connect during_start_prep
13 | #
14 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/during_start_prep.sh" "$FORNIX_FOLDER/settings/during_start_prep/051_000_copy_git_config.sh"
15 |
16 | #
17 | # connect commands
18 | #
19 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands" "$FORNIX_COMMANDS_FOLDER/tools/git"
20 |
21 | #
22 | # config
23 | #
24 | # if the project config exists
25 | rm -f "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/config"
26 | if [[ -f "$FORNIX_FOLDER/.git/config" ]]
27 | then
28 | mkdir -p "$__THIS_FORNIX_EXTENSION_FOLDERPATH__"
29 | ln -s "../../../.git/config" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/config"
30 | fi
31 |
32 | # always pay attention to case
33 | git config core.ignorecase false
34 |
35 | # if there's no pull setting, then add it to the project
36 | git config pull.rebase &>/dev/null || git config pull.ff &>/dev/null || git config --add pull.rebase false &>/dev/null
37 |
38 | #
39 | # ignore
40 | #
41 | mkdir -p "$FORNIX_FOLDER/.git/info/"
42 | # check if file exists
43 | if [[ -f "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/exclude.ignore" ]]
44 | then
45 | rm -f "$FORNIX_FOLDER/.git/info/exclude"
46 | ln "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/exclude.ignore" "$FORNIX_FOLDER/.git/info/exclude"
47 | fi
48 |
49 | #
50 | # hooks
51 | #
52 | __temp_var_githooks_folder="$__THIS_FORNIX_EXTENSION_FOLDERPATH__/hooks"
53 | # if the folder exists
54 | if [[ -d "$__temp_var_githooks_folder" ]]
55 | then
56 | # iterate over the files
57 | for dir in $(find "$__temp_var_githooks_folder" -maxdepth 1)
58 | do
59 | git_file="$FORNIX_FOLDER/.git/hooks/$(basename "$dir")"
60 | # ensure all the git hook files exist
61 | mkdir -p "$(dirname "$git_file")"
62 | touch "$git_file"
63 | # make sure each calls the hooks # FIXME: some single quotes in $dir probably need to be escaped here
64 | cat "$git_file" | grep "#START: fornix hooks" &>/dev/null || echo "
65 | #START: fornix hooks (don't delete unless you understand)
66 | if [ -n "'"$FORNIX_FOLDER"'" ]
67 | then
68 | absolute_path () {
69 | "'
70 | echo "$(builtin cd "$(dirname "$1")"; pwd)/$(basename "$1")"
71 | '"
72 | }
73 | for hook in "'$'"(find "'"$FORNIX_FOLDER"'"'/settings/extensions/git/hooks/$(basename "$dir")/' -maxdepth 1)
74 | do
75 | # check if file exists
76 | if [ -f "'"$hook"'" ]
77 | then
78 | hook="'"$(absolute_path "$hook")"'"
79 | chmod ugo+x "'"'"\$hook"'"'" &>/dev/null || sudo chmod ugo+x "'"'"\$hook"'"'"
80 | "'"'"\$hook"'"'" || echo "'"'"problem running: \$hook"'"'"
81 | fi
82 | done
83 | fi
84 | #END: fornix hooks (don't delete unless you understand)
85 | " >> "$git_file"
86 | # ensure its executable
87 | chmod ugo+x "$git_file" &>/dev/null || sudo chmod ugo+x "$git_file"
88 | done
89 | fi
90 |
91 | # #
92 | # # setup object sharing across repos
93 | # #
94 | # if [ -d "$FORNIX_FOLDER/.git/objects" ]
95 | # then
96 | # #
97 | # # add self to git_alternate_object_directories
98 | # #
99 | # if [ "$HOME" != "$FORNIX_HOME" ]
100 | # then
101 | # # ensure the location exists
102 | # mkdir -p "$HOME/.cache/git_alternate_object_directories"
103 | # file_name="$(md5sum <<< "$FORNIX_FOLDER/.git/objects" | sed 's/ //g' | sed 's/-//g' )"
104 | # # create or overwrite the objects
105 | # printf '%s' "$FORNIX_FOLDER/.git/objects" > "$HOME/.cache/git_alternate_object_directories/$file_name"
106 | # rm -f "$FORNIX_HOME/.cache/git_alternate_object_directories" 2>/dev/null
107 | # rm -rf "$FORNIX_HOME/.cache/git_alternate_object_directories" 2>/dev/null
108 | # mkdir -p "$FORNIX_HOME/.cache/"
109 | # ln -s "$HOME/.cache/git_alternate_object_directories/" "$FORNIX_HOME/.cache/git_alternate_object_directories"
110 | # fi
111 |
112 | # #
113 | # # create the GIT_ALTERNATE_OBJECT_DIRECTORIES var if needed
114 | # #
115 | # if [ -z "$GIT_ALTERNATE_OBJECT_DIRECTORIES" ]
116 | # then
117 | # if [ -d "$FORNIX_HOME/.cache/git_alternate_object_directories" ]
118 | # then
119 | # # this loop is so stupidly complicated because of many inherent-to-shell reasons, for example: https://stackoverflow.com/questions/13726764/while-loop-subshell-dilemma-in-bash
120 | # for_each_item_in="$FORNIX_HOME/.cache/git_alternate_object_directories"; [ -z "$__NESTED_WHILE_COUNTER" ] && __NESTED_WHILE_COUNTER=0;__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER + 1))"; trap 'rm -rf "$__temp_var__temp_folder"' EXIT; __temp_var__temp_folder="$(mktemp -d)"; mkfifo "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER"; (cd "$for_each_item_in" && find "." -maxdepth 1 ! -path "." -print0 2>/dev/null | sort -z > "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER" &); while read -d $'\0' each
121 | # do
122 | # each="$for_each_item_in/$each"
123 | # each_dir="$(cat "$each")"
124 | # # delete any invalid entries (happens when repos get moved or deleted)
125 | # if ! [ -d "$each_dir" ]
126 | # then
127 | # rm -f "$each" 2>/dev/null
128 | # else
129 | # if [ -z "$GIT_ALTERNATE_OBJECT_DIRECTORIES" ]
130 | # then
131 | # GIT_ALTERNATE_OBJECT_DIRECTORIES="$each_dir"
132 | # else
133 | # GIT_ALTERNATE_OBJECT_DIRECTORIES="$GIT_ALTERNATE_OBJECT_DIRECTORIES:$each_dir"
134 | # fi
135 | # fi
136 | # done < "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER";__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER - 1))"
137 | # fi
138 | # fi
139 | # # export it
140 | # export GIT_ALTERNATE_OBJECT_DIRECTORIES="$GIT_ALTERNATE_OBJECT_DIRECTORIES"
141 | # fi
142 |
143 | unset relatively_link
--------------------------------------------------------------------------------
/settings/extensions/git/commands/ignore:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | function escape_grep_regex() {
3 | sed 's/[][\.|$(){}?+*^]/\\&/g' <<< "$*"
4 | }
5 |
6 | function add_to_gitignore {
7 | if [[ -z "$FORNIX_FOLDER" ]]
8 | then
9 | path_to_file=""
10 | file_name="settings/fornix_core"
11 | folder_to_look_in="$PWD"
12 | while :
13 | do
14 | # check if file exists
15 | if [ -f "$folder_to_look_in/$file_name" ]
16 | then
17 | path_to_file="$folder_to_look_in/$file_name"
18 | break
19 | else
20 | if [ "$folder_to_look_in" = "/" ]
21 | then
22 | break
23 | else
24 | folder_to_look_in="$(dirname "$folder_to_look_in")"
25 | fi
26 | fi
27 | done
28 | if [ -z "$path_to_file" ]
29 | then
30 | #
31 | # what to do if file never found
32 | #
33 | echo "Im a script running with a pwd of:$PWD"
34 | echo "Im looking for settings/fornix_core in a parent folder"
35 | echo "Im exiting now because I wasnt able to find it"
36 | echo "thats all the information I have"
37 | exit
38 | fi
39 | FORNIX_FOLDER="$(realpath "$path_to_file/../..")"
40 | fi
41 | local ignore_file="$FORNIX_FOLDER/.gitignore"
42 | # check if file exists
43 | if ! [[ -f ".gitignore" ]]
44 | then
45 | if [[ -d ".git" ]]
46 | then
47 | # fallback to the exclude file
48 | ignore_file="$FORNIX_FOLDER/.git/info/exclude"
49 | fi
50 | fi
51 | mkdir -p "$(dirname "$ignore_file")"
52 | touch "$ignore_file"
53 |
54 | local argument_was_added="false"
55 | local added_at_least_one_thing="true"
56 | for arg in "$@"
57 | do
58 | local path_to_ignore="$(realpath "$arg" --relative-to="$FORNIX_FOLDER" --canonicalize-missing --no-symlinks)"
59 | local escaped_name="$(escape_grep_regex "$path_to_ignore")"
60 | # if it wasn't in the ignore already
61 | grep -E -- "$escaped_name$" "$ignore_file" &>/dev/null || {
62 | # if this is the first one that wasn't in the git ignore
63 | if [[ "$argument_was_added" = "false" ]]
64 | then
65 | argument_was_added="true"
66 | printf "\n# these lines were auto-added and may be very important (passwords/auth etc)\n" >> "$ignore_file"
67 | printf "# comment it out if you know what you're doing and dont want it to be ignored\n" >> "$ignore_file"
68 | printf "# [start auto-ignore]\n" >> "$ignore_file"
69 | fi
70 | argument_was_added="true"
71 | printf "$path_to_ignore\n" >> "$ignore_file"
72 | }
73 |
74 | done
75 | # if an argument was added, add a concluding comment
76 | if [[ "$argument_was_added" = "true" ]]
77 | then
78 | printf "# [end auto-ignore]\n" >> "$ignore_file"
79 | fi
80 | }
81 | add_to_gitignore "$@"
--------------------------------------------------------------------------------
/settings/extensions/git/commands/mixin:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env -S deno run --allow-all
2 | const { run, Timeout, Env, Cwd, Stdin, Stdout, Stderr, Out, Overwrite, AppendTo, zipInto, mergeInto, returnAsString, } = await import(`https://deno.land/x/quickr@0.3.20/main/run.js`)
3 | const { FileSystem } = await import(`https://deno.land/x/quickr@0.3.20/main/file_system.js`)
4 | const { Console } = await import(`https://deno.land/x/quickr@0.3.20/main/console.js`)
5 |
6 | //
7 | // args
8 | //
9 | let [ url, branch, commit ] = Deno.args
10 |
11 | //
12 | // interactive
13 | //
14 | if (!url) {
15 | url = Console.askFor.line("What is the url to the mixin?")
16 | }
17 |
18 | if (!branch) {
19 | brach = Console.askFor.line("What is the branch you want to mixin? (default=master)")
20 | if (!branch) {
21 | branch = "master"
22 | }
23 | }
24 |
25 | //
26 | //
27 | // actual logic
28 | //
29 | //
30 | async function mixin(url, branch, commit, specialBranchName="@__mixin__") {
31 | const { run, Timeout, Env, Cwd, Stdin, Stdout, Stderr, Out, Overwrite, AppendTo, zipInto, mergeInto, returnAsString, } = await import(`https://deno.land/x/quickr@0.3.20/main/run.js`)
32 | const { FileSystem } = await import(`https://deno.land/x/quickr@0.3.20/main/file_system.js`)
33 | const { Console } = await import(`https://deno.land/x/quickr@0.3.20/main/console.js`)
34 |
35 | // remove any leftover ones (caused by git merge conflicts)
36 | await run("git", "remote", "remove", specialBranchName, Out(null)) // git remote remove __mixin__ &>/dev/null
37 | await run("git", "remote", "add", specialBranchName, url) // git remote add __mixin__ "$url"
38 | await run("git", "fetch", specialBranchName, url) // git fetch __mixin__ "$branch"
39 |
40 | // if there was a commit
41 | if (commit) {
42 | // only merge the one commit
43 | await run("git", "cherry-pick", commit) // git cherry-pick "$commit"
44 | // otherwise merge everything
45 | } else {
46 | await run("git", "pull", "--allow-unrelated-histories", specialBranchName, branch)
47 | }
48 |
49 | // update submodules (probably not the best behavior for super-large repos with optional submodules)
50 | await run("git", "submodule", "update", "--init", "--recursive")
51 | // clean up afterwords
52 | await run("git", "remote", "remove", specialBranchName, Out(null)) // git remote remove __mixin__ &>/dev/null
53 | }
54 |
55 | //
56 | // run it
57 | //
58 | mixin(url, branch, commit)
--------------------------------------------------------------------------------
/settings/extensions/git/config:
--------------------------------------------------------------------------------
1 | ../../../.git/config
--------------------------------------------------------------------------------
/settings/extensions/git/during_cleaning.sh:
--------------------------------------------------------------------------------
1 | # remove git's hooks
2 | if [[ -d "$FORNIX_FOLDER/.git/hooks" ]]
3 | then
4 | for file in $(find "$FORNIX_FOLDER/.git/hooks")
5 | do
6 | # check if file exists
7 | if [ -f "$file" ]
8 | then
9 | rm -fv "$file"
10 | fi
11 | done
12 | fi
--------------------------------------------------------------------------------
/settings/extensions/git/during_start_prep.sh:
--------------------------------------------------------------------------------
1 | # copy in gitconfig before changing home var
2 | # check if file exists
3 | if [ -f "$HOME/.gitconfig" ]
4 | then
5 | cp "$HOME/.gitconfig" "$FORNIX_HOME/.gitconfig" 2>/dev/null
6 | fi
7 |
8 | # make sure the user has this in their gitignore
9 | # (the config could contain passwords/keys)
10 | "$FORNIX_FOLDER/settings/extensions/git/commands/ignore" "$FORNIX_HOME/.gitconfig"
--------------------------------------------------------------------------------
/settings/extensions/git/hooks/fsmonitor-watchman/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/settings/extensions/git/hooks/fsmonitor-watchman/.keep
--------------------------------------------------------------------------------
/settings/extensions/git/hooks/post-merge/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/settings/extensions/git/hooks/post-merge/.keep
--------------------------------------------------------------------------------
/settings/extensions/git/hooks/post-merge/901_check_pip_modules:
--------------------------------------------------------------------------------
1 | ../../../python/commands/ensure_pip_modules
--------------------------------------------------------------------------------
/settings/extensions/git/hooks/post-update/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/settings/extensions/git/hooks/post-update/.keep
--------------------------------------------------------------------------------
/settings/extensions/git/hooks/post-update/901_check_pip_modules:
--------------------------------------------------------------------------------
1 | ../../../python/commands/ensure_pip_modules
--------------------------------------------------------------------------------
/settings/extensions/git/hooks/pre-applypatch/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/settings/extensions/git/hooks/pre-applypatch/.keep
--------------------------------------------------------------------------------
/settings/extensions/git/hooks/pre-commit/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/settings/extensions/git/hooks/pre-commit/.keep
--------------------------------------------------------------------------------
/settings/extensions/git/hooks/pre-commit/002_prevent_large_files.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # this was copy-pasted from: https://gist.github.com/benmccallum/28e4f216d9d72f5965133e6c43aaff6e
4 |
5 | # This is a pre-commit hook that ensures attempts to commit files that are
6 | # larger than $limit to your _local_ repo fail, with a helpful error message.
7 |
8 | # Maximum file size limit in bytes
9 | limit=$(( 50 * 2**20 )) # 50MB
10 | limitInMB=$(( $limit / 2**20 ))
11 |
12 | # Move to the repo root so git files paths make sense
13 | repo_root=$( git rev-parse --show-toplevel )
14 | cd $repo_root
15 |
16 | empty_tree=$( git hash-object -t tree /dev/null )
17 |
18 | if git rev-parse --verify HEAD > /dev/null 2>&1
19 | then
20 | against=HEAD
21 | else
22 | against="$empty_tree"
23 | fi
24 |
25 | # Set split so that for loop below can handle spaces in file names by splitting on line breaks
26 | IFS='
27 | '
28 |
29 | echo "Checking staged file sizes"
30 | shouldFail=false
31 | # `--diff-filter=d` -> skip deletions
32 | for file in $( git diff-index --cached --diff-filter=d --name-only "$against" ); do
33 | # Skip for directories (git submodules)
34 | if [[ -f "$file" ]]; then
35 | file_size=$( ls -lan $file | awk '{ print $5 }' )
36 | if [ "$file_size" -gt "$limit" ]; then
37 | echo File $file is $(( $file_size / 2**20 )) MB, which is larger than our configured limit of $limitInMB MB
38 | shouldFail=true
39 | fi
40 | fi
41 | done
42 |
43 | if $shouldFail
44 | then
45 | echo If you really need to commit this file, you can push with the --no-verify switch, but the file should definitely, definitely be under $limitInMB MB!!!
46 | echo Commit aborted
47 | exit 1;
48 | fi
--------------------------------------------------------------------------------
/settings/extensions/git/hooks/pre-merge-commit/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/settings/extensions/git/hooks/pre-merge-commit/.keep
--------------------------------------------------------------------------------
/settings/extensions/git/hooks/pre-push/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/settings/extensions/git/hooks/pre-push/.keep
--------------------------------------------------------------------------------
/settings/extensions/git/hooks/pre-receive/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/settings/extensions/git/hooks/pre-receive/.keep
--------------------------------------------------------------------------------
/settings/extensions/git/hooks/prepare-commit-msg/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/settings/extensions/git/hooks/prepare-commit-msg/.keep
--------------------------------------------------------------------------------
/settings/extensions/git/hooks/update/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff-hykin/macro-commander/400ea1e7bf04fffe97f4a7f3fa87870c9872742c/settings/extensions/git/hooks/update/.keep
--------------------------------------------------------------------------------
/settings/extensions/nix/#establish_extension.sh:
--------------------------------------------------------------------------------
1 | export __FORNIX_NIX_SETTINGS_PATH="$FORNIX_FOLDER/settings/extensions/nix/settings.toml"
2 | export __FORNIX_NIX_MAIN_CODE_PATH="$FORNIX_FOLDER/settings/extensions/nix/parse_dependencies.nix"
3 | export __FORNIX_NIX_PACKAGES_FILE_PATH="$FORNIX_FOLDER/settings/requirements/system_tools.toml"
4 | export __FORNIX_NIX_PATH_EXPORT_FILE="$FORNIX_FOLDER/settings/.cache/dependency_paths.do_not_sync.json"
5 | export __FORNIX_NIX_COMMANDS="$FORNIX_FOLDER/settings/extensions/nix/commands"
6 |
7 | # this is a helper
8 | relatively_link="$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/relative_link"
9 |
10 | #
11 | # connect shell.nix
12 | #
13 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/shell.nix" "$FORNIX_FOLDER/settings/requirements/advanced_system_tools.nix"
14 |
15 | #
16 | # connect nix.toml
17 | #
18 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/nix.toml" "$FORNIX_FOLDER/settings/requirements/system_tools.toml"
19 |
20 | #
21 | # connect commands
22 | #
23 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands" "$FORNIX_COMMANDS_FOLDER/tools/nix"
24 |
25 | #
26 | # connect during_clean
27 | #
28 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/during_clean.sh" "$FORNIX_FOLDER/settings/during_clean/450_nix.sh"
29 |
30 | #
31 | # connect during_start
32 | #
33 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/during_start.sh" "$FORNIX_FOLDER/settings/during_start/010_000__ssl_fix__.sh"
34 |
35 | unset relatively_link
--------------------------------------------------------------------------------
/settings/extensions/nix/commands/fix_ssl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # how to create up-to-date cert on MacOS
4 | # if [ "$(uname)" = "Darwin" ]
5 | # then
6 | # # check if file exists
7 | # if ! [ -f "/etc/ssl/certs/ca-certificates.crt" ]
8 | # then
9 | # #
10 | # # create an up-to-date cert with keychain
11 | # #
12 | # sudo mkdir -p /etc/ssl/certs/
13 | # sudo rm -f /etc/ssl/certs/ca-certificates.crt
14 | # sudo security export -t certs -f pemseq -k /System/Library/Keychains/SystemRootCertificates.keychain -o /etc/ssl/certs/ca-certificates.crt
15 | # # force/ensure correct permissions on folders/files
16 | # sudo chown root /etc /etc/ssl /etc/ssl/certs/ /etc/ssl/certs/ca-certificates.crt
17 | # sudo chmod u=rwx,g=rx,o=rx /etc
18 | # sudo chmod u=rwx,g=rx,o=rx /etc/ssl
19 | # sudo chmod u=rwx,g=rx,o=rx /etc/ssl/certs/
20 | # sudo chmod u=rw,g=r,o=r /etc/ssl/certs/ca-certificates.crt
21 | # fi
22 | # fi
23 |
24 | # if file exists, use it
25 | __temp_var__certs_file="$FORNIX_FOLDER/settings/extensions/nix/cacert.pem"
26 | if [ -f "$__temp_var__certs_file" ]
27 | then
28 | export SSL_CERT_FILE="$__temp_var__certs_file"
29 | export NIX_SSL_CERT_FILE="$SSL_CERT_FILE"
30 | # for some reason git needs its own var
31 | export GIT_SSL_CAINFO="$SSL_CERT_FILE"
32 | export CURL_CA_BUNDLE="$SSL_CERT_FILE"
33 |
34 | wgetrc_path="$FORNIX_HOME/.wgetrc"
35 | # ensure file exists
36 | if ! [ -f "$wgetrc_path" ]
37 | then
38 | rm -rf "$wgetrc_path" 2>/dev/null
39 | touch "$wgetrc_path"
40 | fi
41 | # check if already included
42 | if ! { cat "$wgetrc_path" | grep -F "$SSL_CERT_FILE" 1>/dev/null 2>/dev/null }
43 | then
44 | # TODO: this probably wont work with spaces in the path (breaks if any parent folder of the project has space in the name)
45 | echo "
46 | ca_certificate = $SSL_CERT_FILE" >> "$wgetrc_path"
47 | fi
48 | fi
49 | unset __temp_var__certs_file
50 |
51 |
52 | #
53 | # link cert into nix
54 | #
55 | nix_certificates_file="/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt" # not sure if different for single-user install
56 | # check if file exists
57 | if ! [ -f "$nix_certificates_file" ]
58 | then
59 | echo "Creating nix certificate file: $nix_certificates_file"
60 | sudo mkdir -p "$(dirname "$nix_certificates_file")"
61 | # link into nix profile
62 | sudo ln -s "$NIX_SSL_CERT_FILE" "$nix_certificates_file"
63 | fi
--------------------------------------------------------------------------------
/settings/extensions/nix/commands/force_patch_so_files:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env -S deno run --allow-all
2 | const { FileSystem } = await import(`https://deno.land/x/quickr@0.6.3/main/file_system.js`)
3 | const { OperatingSystem } = await import(`https://deno.land/x/quickr@0.6.3/main/operating_system.js`)
4 | const { Console } = await import(`https://deno.land/x/quickr@0.6.3/main/console.js`)
5 | const { run, throwIfFails, zipInto, mergeInto, returnAsString, Timeout, Env, Cwd, Stdin, Stdout, Stderr, Out, Overwrite, AppendTo, checkCommands } = await import("https://deno.land/x/quickr@0.6.3/main/run.js")
6 |
7 | function paths() {
8 | const spliter = OperatingSystem.commonChecks.isWindows ? ";" : ":"
9 | return Deno.env.get("PATH").split(spliter)
10 | }
11 |
12 | if (!OperatingSystem.commonChecks.isWindows) {
13 | // TODO: need to have it copy the target, patch the copy, and then link to the copy
14 | // especially because some of the targets that need to be changed are in nix/store
15 |
16 |
17 | async function directInfo(sharedObjectPath) {
18 | let result = (await run`readelf -d ${sharedObjectPath} ${Stdout(returnAsString)}`).replace(/\n$/,"")
19 | // IMPERFECTION: a malicious/crafted file path could probably cause this to fail
20 | const chunks = result.match(/(^|\n) 0x[0-9a-f]{16} \((.|\s)*?(?=(\n 0x|$))/g)
21 | if (!chunks) {
22 | console.debug(`FAILED for path: ${JSON.stringify(sharedObjectPath)}\ncommand result was:`,result)
23 | return { needed:[]}
24 | }
25 | let rpath = ""
26 | let runpath = ""
27 | const needed = []
28 | const other = {}
29 | for (const each of chunks) {
30 | const match = each.match(/(?:^|\n) 0x([0-9a-f]{16}) \((.+?)\)\s+(.+): \[((?:.|\s)+)\]/)
31 | if (match) {
32 | const [ _, address, kind, otherName, path ] = match
33 | if (kind == "NEEDED") {
34 | needed.push(path)
35 | } else if (kind == "RPATH") {
36 | rpath = path
37 | } else if (kind == "RUNPATH") {
38 | runpath = path
39 | }
40 | }
41 | }
42 |
43 | return {
44 | rpath,
45 | runpath,
46 | needed,
47 | }
48 | }
49 |
50 | async function forceRpath(sharedObjectPath, newFolder, ldPath) {
51 | const { rpath, runpath } = await directInfo(sharedObjectPath)
52 | const sources = ([newFolder, rpath, ldPath, runpath]).filter(each=>each)
53 | const newRPath = sources.join(":")
54 |
55 | // delete runpath
56 | var {success} = await run`chrpath -d ${sharedObjectPath}`
57 | if (success) {
58 | // set rpath
59 | var { success } = await run`patchelf --force-rpath --set-rpath ${newRPath} ${sharedObjectPath}`
60 | }
61 | return success
62 | }
63 |
64 | async function getDirectDynamicLinks(sharedObjectPath, ldPath) {
65 | let { rpath, runpath, needed } = await directInfo(sharedObjectPath)
66 | if (runpath) {
67 | rpath = ""
68 | }
69 | if (ldPath) {
70 | runpath = ldPath + runpath
71 | }
72 | const sourcesString = [rpath, runpath].filter(each=>each).join(":")
73 | // IMPERFECTION: doesn't account for escaping $ORIGIN (not sure how escaping works)
74 | const sources = sourcesString.replace(/\$ORIGIN/, FileSystem.makeAbsolutePath(FileSystem.parentPath(sharedObjectPath))).split(":")
75 | const mapping = {}
76 | for (let each of needed) {
77 | mapping[each] = null
78 | }
79 | for (const eachPath of sources) {
80 | for (const eachName of needed) {
81 | if (!mapping[eachName]) {
82 | if ((await FileSystem.info(eachName)).exists) {
83 | // IMPERFECTION: probably needs particular permissions to count
84 | mapping[eachName] = eachPath
85 | }
86 | }
87 | }
88 | }
89 | return mapping
90 | }
91 |
92 | async function hardDynamicLink({ sharedObjectPath, item, newFolder, offLimits }) {
93 | offLimits = [...(offLimits || new Set(([...offLimits]).map(each=>FileSystem.makeAbsolutePath(each))))]
94 | const fullPath = FileSystem.makeAbsolutePath(sharedObjectPath)
95 | if (offLimits.some(each=>fullPath.startsWith(each))) {
96 | return
97 | }
98 | const mapping = await getDirectDynamicLinks(sharedObjectPath)
99 | for (const [name, path] of Object.entries(mapping)) {
100 | if (!path && name == item) {
101 | console.log(` patching: ${JSON.stringify(name)} for ${JSON.stringify(sharedObjectPath)}`)
102 | await forceRpath(sharedObjectPath, newFolder)
103 | } else if (path) {
104 | // recursively check all children
105 | await hardDynamicLink({ sharedObjectPath: path, item, newFolder, offLimits })
106 | }
107 | }
108 | }
109 | var handleBrokenDynamicLinks = async function({ folder, mapping, offLimits }) {
110 | mapping = mapping||{}
111 | const promises = []
112 | const badKeys = new Set()
113 | for (const eachItem of await FileSystem.listFileItemsIn(folder, { recursively: true })) {
114 | // find all the shared object files
115 | if (eachItem.basename.match(/\.so\b/)) {
116 | console.debug(` checking:`, eachItem.path)
117 | const eachMapping = await getDirectDynamicLinks(eachItem.path)
118 | for (const [linkName, linkedPath] of Object.entries(eachMapping)) {
119 | if (!linkedPath) {
120 | if (mapping[linkName]) {
121 | promises.push(hardDynamicLink({
122 | sharedObjectPath: eachItem.path,
123 | item: linkName,
124 | newFolder: mapping[linkName],
125 | offLimits
126 | }))
127 | } else {
128 | console.log(` missing: ${linkName}`)
129 | badKeys.add(linkName)
130 | }
131 | }
132 | }
133 | }
134 | }
135 | await Promise.all(promises)
136 | return [...badKeys]
137 | }
138 |
139 | if (OperatingSystem.commonChecks.isMac) {
140 | console.warn(`This system does not yet support .dylib files (only .so files)`)
141 | if (!await Console.askFor.yesNo("do you want to continue anyways?")) {
142 | Deno.exit(1)
143 | }
144 | }
145 |
146 | const { missing } = await checkCommands([ "chrpath", "patchelf", "readelf" ])
147 | if (missing.length > 0) {
148 | throw Error(`
149 | Sorry looks like you're trying to clean up some shared object files, but I
150 | need access to the following commands:
151 | ${missing}
152 |
153 | I don't see them, but here's where I looked:
154 | ${paths().join(" \n")}
155 | `)
156 |
157 | // for MacOS
158 | // brew install chrpath
159 | // nixi patchelf
160 | // nixi binutils
161 | // dyld_info -dependents "file"
162 |
163 | }
164 | } else {
165 | throw Error(`sorry this function isn't available on your system yet`)
166 | }
167 |
168 |
169 |
170 | //
171 | //
172 | // handle the CLI
173 | //
174 | //
175 |
176 | let mapping = {}
177 | let offLimits = []
178 | try { mapping = JSON.parse(Deno.args[1]) } catch (error) {}
179 | try { offLimits = JSON.parse(Deno.args[2]) } catch (error) {}
180 | const brokenDynamicLinks = await handleBrokenDynamicLinks({
181 | folder: Deno.args[0],
182 | mapping,
183 | offLimits
184 | })
185 | if (!brokenDynamicLinks) {
186 | console.log(`No broken links found`)
187 | } else {
188 | console.debug(`discovered brokenDynamicLinks to:`, brokenDynamicLinks)
189 | }
--------------------------------------------------------------------------------
/settings/extensions/nix/commands/lib_path_for:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # example usage:
3 | # $ tools nix package_path_for 'glib'
4 | # >>> /nix/store/dcb3cyba5wl6qimv6vwdpbi0kg0g1nlb-glib-2.68.2/lib
5 |
6 | output=""
7 | # check if file exists
8 | if [ -f "$__FORNIX_NIX_PATH_EXPORT_FILE" ]
9 | then
10 | # the sed part just removes the quotes
11 | output="$(cat "$__FORNIX_NIX_PATH_EXPORT_FILE" | jq ".libPathFor.\"$1\"" | sed -E 's/^"|"$//g')"
12 | fi
13 |
14 | if [ -z "$output" ]
15 | then
16 | echo "" 1>&2
17 | echo "there was an issue when calling:" 1>&2
18 | echo " nix package_path_for $1" 1>&2
19 | echo "it is possible that package doesnt exist inside of this file: $__FORNIX_NIX_PATH_EXPORT_FILE" 1>&2
20 | echo "(which is autogenerated based on system_tools.toml)" 1>&2
21 | echo "" 1>&2
22 | else
23 | printf '%s' "$output"
24 | fi
--------------------------------------------------------------------------------
/settings/extensions/nix/commands/long_eval:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # example usage:
3 | # $ tools nix long_eval 'a = 10; b = 11; return = a + b;'
4 | # >>> 21
5 |
6 | nix-instantiate --eval -E '(rec { '"$1"' }).return'
--------------------------------------------------------------------------------
/settings/extensions/nix/commands/package_path_for:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # example usage:
3 | # $ tools nix package_path_for 'glib'
4 | # >>> /nix/store/dcb3cyba5wl6qimv6vwdpbi0kg0g1nlb-glib-2.68.2/lib
5 |
6 | output=""
7 | # check if file exists
8 | if [ -f "$__FORNIX_NIX_PATH_EXPORT_FILE" ]
9 | then
10 | # the sed part just removes the quotes
11 | output="$(cat "$__FORNIX_NIX_PATH_EXPORT_FILE" | jq ".packagePathFor.\"$1\"" | sed -E 's/^"|"$//g')"
12 | fi
13 |
14 | if [ -z "$output" ]
15 | then
16 | echo "" 1>&2
17 | echo "there was an issue when calling:" 1>&2
18 | echo " nix package_path_for $1" 1>&2
19 | echo "it is possible that package doesnt exist inside of this file: $__FORNIX_NIX_PATH_EXPORT_FILE" 1>&2
20 | echo "(which is autogenerated based on system_tools.toml)" 1>&2
21 | echo "" 1>&2
22 | else
23 | printf '%s' "$output"
24 | fi
--------------------------------------------------------------------------------
/settings/extensions/nix/commands/raw_find:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | find -L /run /nix -iname "$@" 2>/dev/null
--------------------------------------------------------------------------------
/settings/extensions/nix/during_clean.sh:
--------------------------------------------------------------------------------
1 |
2 | # detach the system link (behaves like unlink)
3 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_FOLDER/home/.cache/nix"
--------------------------------------------------------------------------------
/settings/extensions/nix/during_start.sh:
--------------------------------------------------------------------------------
1 | # fix_ssl
2 | . "$FORNIX_FOLDER/settings/extensions/nix/commands/fix_ssl"
--------------------------------------------------------------------------------
/settings/extensions/nix/nix.toml:
--------------------------------------------------------------------------------
1 | #
2 | # how to add packages?
3 | #
4 | # you can search for them here: https://search.nixos.org/packages
5 | #
6 | # if you find a package like: nixpkg.python38Packages.setuptools
7 | # then add a section like this:
8 | # [[packages]]
9 | # load = [ "python38Packages", "setuptools",]
10 | #
11 | # if you need a specific version
12 | # search for the package (e.g. "setuptools") on here: https://lazamar.co.uk/nix-versions/
13 | # each version will have a long hash like "3f50332bc4913a56ad216ca01f5d0bd24277a6b2"
14 | # (which is a commit on the nixpkg repo)
15 | # once you copy the hash, you can add the package below like
16 | #
17 | # [[packages]]
18 | # load = [ "python38Packages", "setuptools",]
19 | # from = "3f50332bc4913a56ad216ca01f5d0bd24277a6b2"
20 |
21 | #
22 | # Complex packages
23 | #
24 | # things such as platform-specific packages,
25 | # loading from a git repository,
26 | # or if you find an online solution that involves native build inputs
27 | # you can use the following advanced format
28 | #
29 | # [[packages]]
30 | # load = [ "nixGLNvidia",]
31 | # onlyIf = [ [ "stdenv", "isLinux",],] # for MacOS use: onlyIf = [ [ "stdenv", "isDarwin",],]
32 | # # see https://discourse.nixos.org/t/opencv-with-cuda-in-nix-shell/7358/5
33 | # from = { fetchGit = { url = "https://github.com/guibou/nixGL", rev = "7d6bc1b21316bab6cf4a6520c2639a11c25a220e" }, }
34 | #
35 | # in general when looking at online forms, look at the shell.nix file
36 | # specifically look at the `# create a shell` and `main.packages.mkShell` part
37 | # and know that seeing `pkgs` online translates to `main.packages` inside the shell.nix file
38 |
39 |
40 | # [[ you can add tools for your project right here or at the bottom ]]
41 |
42 | #
43 | # Node.js
44 | #
45 | # uncomment one of groups to pick your version
46 | [[packages]]
47 | # version 16.2.0
48 | # load = [ "nodejs",]
49 | # from = "141439f6f11537ee349a58aaf97a5a5fc072365c"
50 |
51 | # version 15.14.0
52 | # load = [ "nodejs-15_x",]
53 | # from = "c92ca95afb5043bc6faa0d526460584eccff2277"
54 |
55 | # version 14.17.1
56 | load = [ "nodejs",]
57 | from = "860b56be91fb874d48e23a950815969a7b832fbc"
58 |
59 | # version 12.22.1
60 | # load = [ "nodejs-12_x",]
61 | # from = "860b56be91fb874d48e23a950815969a7b832fbc"
62 |
63 | # version 10.24.0
64 | # load = [ "nodejs-10_x",]
65 | # from = "a765beccb52f30a30fee313fbae483693ffe200d"
66 |
67 | [[packages]]
68 | load = [ "nodePackages", "pnpm", ]
69 | from = "860b56be91fb874d48e23a950815969a7b832fbc"
70 |
71 |
72 | #
73 | # Python (because node-gyp depends on python)
74 | #
75 | [[packages]]
76 | load = [ "python38",]
77 |
78 | [[packages]]
79 | load = [ "python38Packages", "setuptools",]
80 |
81 | [[packages]]
82 | load = [ "python38Packages", "pip",]
83 |
84 | [[packages]]
85 | load = [ "python38Packages", "virtualenv",]
86 |
87 | [[packages]]
88 | load = [ "python38Packages", "wheel",]
89 |
90 | [[packages]]
91 | load = [ "cmake",]
92 |
93 | [[packages]]
94 | load = [ "pkg-config",]
95 |
96 | [[packages]]
97 | load = [ "libffi",]
98 |
99 |
100 | #
101 | # for .so errors on linux with opencv+ffmpeg
102 | #
103 |
104 | [[packages]]
105 | onlyIf = [ [ "stdenv", "isLinux",],]
106 | load = [ "glib",]
107 | asNativeBuildInput = true
108 | from = "528d35bec0cb976a06cc0e8487c6e5136400b16b"
109 |
110 | [[packages]]
111 | onlyIf = [ [ "stdenv", "isLinux",],]
112 | load = [ "libglvnd",]
113 | asNativeBuildInput = true
114 | from = "559cf76fa3642106d9f23c9e845baf4d354be682"
115 |
116 | #
117 | #
118 | #
119 | # Need-to-build-from-source tools
120 | #
121 | #
122 | #
123 | # Note: most projects need these,
124 | # and if you need them for one project nix has a shared-memory across projects
125 | # comment these out in a situation such as deploying a project to a minimal server
126 |
127 | #
128 | # Linux
129 | #
130 | [[packages]]
131 | load = [ "pkgconfig",]
132 | asNativeBuildInput = true
133 | onlyIf = [ [ "stdenv", "isLinux",],]
134 |
135 | [[packages]]
136 | load = [ "libconfig",]
137 | asNativeBuildInput = true
138 | onlyIf = [ [ "stdenv", "isLinux",],]
139 |
140 | [[packages]]
141 | load = [ "cmake",]
142 | asNativeBuildInput = true
143 | onlyIf = [ [ "stdenv", "isLinux",],]
144 |
145 | [[packages]]
146 | load = [ "stdenv", "cc",]
147 | onlyIf = [ [ "stdenv", "isLinux",],]
148 |
149 | #
150 | # Mac
151 | #
152 | [[packages]]
153 | load = [ "xcbuild",]
154 | asNativeBuildInput = true
155 | onlyIf = [ [ "stdenv", "isDarwin",],]
156 |
157 | [[packages]]
158 | load = [ "xcodebuild",]
159 | asNativeBuildInput = true
160 | onlyIf = [ [ "stdenv", "isDarwin",],]
161 |
162 | [[packages]]
163 | load = [ "darwin", "libobjc", ]
164 | asNativeBuildInput = true
165 | onlyIf = [ [ "stdenv", "isDarwin",],]
166 |
167 | [[packages]]
168 | load = [ "darwin", "apple_sdk", "frameworks", "CoreServices" ]
169 | asNativeBuildInput = true
170 | onlyIf = [ [ "stdenv", "isDarwin",],]
171 |
172 | [[packages]]
173 | load = [ "darwin", "apple_sdk", "frameworks", "CoreFoundation" ]
174 | asNativeBuildInput = true
175 | onlyIf = [ [ "stdenv", "isDarwin",],]
176 |
177 | [[packages]]
178 | load = [ "darwin", "apple_sdk", "frameworks", "Foundation" ]
179 | asNativeBuildInput = true
180 | onlyIf = [ [ "stdenv", "isDarwin",],]
181 |
182 | [[packages]]
183 | load = [ "darwin", "apple_sdk", "frameworks", "AVKit" ]
184 | asNativeBuildInput = true
185 | onlyIf = [ [ "stdenv", "isDarwin",],]
186 |
187 | [[packages]]
188 | load = [ "darwin", "apple_sdk", "frameworks", "AVFoundation" ]
189 | asNativeBuildInput = true
190 | onlyIf = [ [ "stdenv", "isDarwin",],]
191 |
192 | [[packages]]
193 | load = [ "darwin", "apple_sdk", "frameworks", "AppKit" ]
194 | asNativeBuildInput = true
195 | onlyIf = [ [ "stdenv", "isDarwin",],]
196 |
197 | [[packages]]
198 | load = [ "darwin", "apple_sdk", "frameworks", "WebKit" ]
199 | asNativeBuildInput = true
200 | onlyIf = [ [ "stdenv", "isDarwin",],]
201 |
202 | [[packages]]
203 | load = [ "darwin", "apple_sdk", "frameworks", "Accounts" ]
204 | asNativeBuildInput = true
205 | onlyIf = [ [ "stdenv", "isDarwin",],]
206 |
207 | [[packages]]
208 | load = [ "darwin", "apple_sdk", "frameworks", "Security" ]
209 | asNativeBuildInput = true
210 | onlyIf = [ [ "stdenv", "isDarwin",],]
211 |
212 | #
213 | # both often need
214 | #
215 | [[packages]]
216 | load = [ "gcc",]
217 |
218 | [[packages]]
219 | load = [ "libkrb5",]
220 |
221 | #
222 | #
223 | # common dependencies
224 | #
225 | #
226 |
227 | [[packages]]
228 | load = [ "ncurses5",]
229 |
230 | [[packages]]
231 | load = [ "openssh",]
232 |
233 | #
234 | #
235 | # fancy command line tools
236 | #
237 | #
238 | [[packages]]
239 | load = [ "fd",]
240 |
241 | [[packages]]
242 | load = [ "sd",]
243 |
244 | [[packages]]
245 | load = [ "dua",]
246 |
247 | [[packages]]
248 | load = [ "tealdeer",]
249 |
250 | [[packages]]
251 | load = [ "bottom",]
252 |
253 | [[packages]]
254 | load = [ "exa",]
255 |
256 | [[packages]]
257 | load = [ "zsh",]
258 |
259 | [[packages]]
260 | load = [ "zsh-syntax-highlighting",]
261 |
262 | [[packages]]
263 | load = [ "oh-my-zsh",]
264 |
265 | [[packages]]
266 | load = [ "zsh-autosuggestions",]
267 |
268 | [[packages]]
269 | load = [ "spaceship-prompt",]
270 |
271 | [[packages]]
272 | load = [ "nnn",]
273 |
274 | [[packages]]
275 | load = [ "jq",]
276 |
277 | [[packages]]
278 | load = [ "git-subrepo",]
279 |
280 | #
281 | #
282 | # Basic Commandline tools
283 | #
284 | #
285 |
286 | [[packages]]
287 | load = [ "man",]
288 |
289 | [[packages]]
290 | load = [ "coreutils",]
291 |
292 | [[packages]]
293 | load = [ "ripgrep",]
294 |
295 | [[packages]]
296 | load = [ "which",]
297 |
298 | [[packages]]
299 | load = [ "git",]
300 |
301 | [[packages]]
302 | load = [ "colorls",]
303 |
304 | [[packages]]
305 | load = [ "tree",]
306 |
307 | [[packages]]
308 | load = [ "less",]
309 |
310 | [[packages]]
311 | load = [ "nano",]
312 |
313 | [[packages]]
314 | load = [ "unzip",]
315 |
316 | [[packages]]
317 | load = [ "zip",]
318 |
319 | [[packages]]
320 | load = [ "findutils",]
321 |
322 | [[packages]]
323 | load = [ "wget",]
324 |
325 | [[packages]]
326 | load = [ "curl",]
327 |
328 | [[packages]]
329 | load = [ "unixtools", "arp",]
330 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
331 |
332 | [[packages]]
333 | load = [ "unixtools", "ifconfig",]
334 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
335 |
336 | [[packages]]
337 | load = [ "unixtools", "netstat",]
338 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
339 |
340 | [[packages]]
341 | load = [ "unixtools", "ping",]
342 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
343 |
344 | [[packages]]
345 | load = [ "unixtools", "route",]
346 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
347 |
348 | [[packages]]
349 | load = [ "unixtools", "col",]
350 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
351 |
352 | [[packages]]
353 | load = [ "unixtools", "column",]
354 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
355 |
356 | [[packages]]
357 | load = [ "unixtools", "fdisk",]
358 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
359 |
360 | [[packages]]
361 | load = [ "unixtools", "fsck",]
362 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
363 |
364 | [[packages]]
365 | load = [ "unixtools", "getconf",]
366 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
367 |
368 | [[packages]]
369 | load = [ "unixtools", "getent",]
370 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
371 |
372 | [[packages]]
373 | load = [ "unixtools", "getopt",]
374 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
375 |
376 | [[packages]]
377 | load = [ "unixtools", "hexdump",]
378 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
379 |
380 | [[packages]]
381 | load = [ "unixtools", "hostname",]
382 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
383 |
384 | [[packages]]
385 | load = [ "unixtools", "killall",]
386 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
387 |
388 | [[packages]]
389 | load = [ "unixtools", "locale",]
390 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
391 |
392 | [[packages]]
393 | load = [ "unixtools", "more",]
394 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
395 |
396 | [[packages]]
397 | load = [ "unixtools", "mount",]
398 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
399 |
400 | [[packages]]
401 | load = [ "unixtools", "ps",]
402 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
403 |
404 | [[packages]]
405 | load = [ "unixtools", "quota",]
406 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
407 |
408 | [[packages]]
409 | load = [ "unixtools", "script",]
410 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
411 |
412 | [[packages]]
413 | load = [ "unixtools", "sysctl",]
414 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
415 |
416 | [[packages]]
417 | load = [ "unixtools", "top",]
418 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
419 |
420 | [[packages]]
421 | load = [ "unixtools", "umount",]
422 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
423 |
424 | [[packages]]
425 | load = [ "unixtools", "whereis",]
426 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
427 |
428 | [[packages]]
429 | load = [ "unixtools", "write",]
430 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
431 |
432 | [[packages]]
433 | load = [ "unixtools", "xxd",]
434 | from = "c00039f697caa02208a01e7712bfe11c484cceca"
435 |
436 | #
437 | # core
438 | #
439 | [[packages]]
440 | load = [ "deno",]
441 | from = "ce6aa13369b667ac2542593170993504932eb836"
442 |
443 | [[packages]]
444 | load = [ "nix",]
--------------------------------------------------------------------------------
/settings/extensions/nix/parse_dependencies.nix:
--------------------------------------------------------------------------------
1 | #
2 | # summary
3 | # this file exports a function that does a few basic things
4 | # 1. parses the nix.toml file and return nix package objects
5 | # 2. exports some basic information about the package dependencies to a json file
6 | # 3. returns a "main" object that has all the basic builtin or builtin-like functionality
7 | (rec {
8 | #
9 | # create a standard library for convienience
10 | #
11 | frozenStd = (builtins.import
12 | (builtins.fetchTarball
13 | ({url="https://github.com/NixOS/nixpkgs/archive/a7ecde854aee5c4c7cd6177f54a99d2c1ff28a31.tar.gz";})
14 | )
15 | ({})
16 | );
17 | main = (frozenStd.lib.mergeAttrs
18 | (frozenStd.lib.mergeAttrs
19 | (frozenStd.buildPackages) # <- for fetchFromGitHub, installShellFiles, getAttrFromPath, etc
20 | (frozenStd.lib.mergeAttrs
21 | ({ stdenv = frozenStd.stdenv; })
22 | (frozenStd.lib) # <- for mergeAttrs, optionals, getAttrFromPath, etc
23 | )
24 | )
25 | (builtins) # <- for import, fetchTarball, etc
26 | );
27 | pathToThisFile = (builtins.getEnv
28 | "__FORNIX_NIX_MAIN_CODE_PATH"
29 | );
30 | #
31 | # pull info from the config files
32 | #
33 | nixSettings = (main.fromTOML
34 | (main.readFile
35 | ./settings.toml
36 | )
37 | );
38 | #
39 | # load the nix.toml cause were going to extract basically everything from there
40 | #
41 | packageToml = (main.fromTOML
42 | (main.readFile
43 | ./nix.toml
44 | )
45 | );
46 | #
47 | # load the store with all the packages, and load it with the config
48 | #
49 | defaultFrom = (main.fetchTarball
50 | ({url="https://github.com/NixOS/nixpkgs/archive/${nixSettings.defaultFrom}.tar.gz";})
51 | );
52 | mainPackages = (main.import
53 | (defaultFrom)
54 | ({ config = nixSettings.config;})
55 | );
56 | packagesForThisMachine = (main.filter
57 | (eachPackage:
58 | (main.all
59 | # if all are true
60 | (x: x)
61 | (main.optionals
62 | # if package depends on something
63 | (main.hasAttr "onlyIf" eachPackage)
64 | # basically convert something like ["stdev", "isLinux"] to main.stdenv.isLinux
65 | (main.map
66 | (eachCondition:
67 | (main.getAttrFromPath
68 | (eachCondition)
69 | (main)
70 | )
71 | )
72 | (eachPackage.onlyIf)
73 | )
74 | )
75 | )
76 | )
77 | (packageToml.packages)
78 | );
79 | #
80 | # reorganize the list of packages from:
81 | # [ { load: "blah", from:"blah-hash" }, ... ]
82 | # into a list like:
83 | # [ { name: "blah", commitHash:"blah-hash", source: (*an object*) }, ... ]
84 | #
85 | tomlPackagesWithSources = (main.map
86 | (each:
87 | ({
88 | name = (main.concatMapStringsSep
89 | (".")
90 | (each: each)
91 | (each.load)
92 | );
93 | commitHash = each.from;
94 | asNativeBuildInput = (
95 | (main.hasAttr
96 | ("asNativeBuildInput")
97 | (each)
98 | )
99 | &&
100 | each.asNativeBuildInput
101 | );
102 | value =
103 | # if it says where (e.g. from)
104 | if
105 | (main.hasAttr
106 | ("from")
107 | (each)
108 | )
109 | # then load it from that place
110 | then
111 | (rec {
112 | package = (main.getAttrFromPath
113 | (each.load)
114 | (main.import
115 | # if its a string, assume its a nixpkg commit hash
116 | (
117 | if
118 | (main.isString
119 | (each.from)
120 | )
121 | then
122 | (main.fetchTarball
123 | ({url="https://github.com/NixOS/nixpkgs/archive/${each.from}.tar.gz";})
124 | )
125 | # otherwise assume its the details for a github repo
126 | else
127 | (main.fetchGit
128 | (each.from.fetchGit)
129 | )
130 | )
131 | (
132 | if
133 | (
134 | (main.isString
135 | (each.from)
136 | )
137 | ||
138 | (!main.hasAttr
139 | ("options")
140 | (each.from)
141 | )
142 | )
143 | then
144 | ({})
145 | # otherwise assume its the details for a github repo
146 | else
147 | (each.from.options)
148 | )
149 | )
150 | );
151 | return = (
152 | if
153 | (main.hasAttr
154 | ("override")
155 | (each)
156 | )
157 | then
158 | (package.override
159 | (each.override)
160 | )
161 | else
162 | package
163 | );
164 | }.return)
165 | # otherwise just default to getting it from mainPackages
166 | else
167 | (main.getAttrFromPath
168 | (each.load)
169 | (mainPackages)
170 | )
171 | ;
172 | })
173 | )
174 | (packagesForThisMachine)
175 | );
176 | listedDepedencyPackages = (main.listToAttrs
177 | (tomlPackagesWithSources)
178 | );
179 | packages = (main.mergeAttrs
180 | mainPackages
181 | listedDepedencyPackages
182 | );
183 | tomlAndBuiltinPackagesWithSources = (tomlPackagesWithSources ++
184 | [
185 | {
186 | name = "glib";
187 | value = packages.glib;
188 | }
189 | {
190 | name = "cc";
191 | value = main.stdenv.cc.cc;
192 | }
193 | ]
194 | );
195 | buildInputs = (main.map
196 | (each: each.value)
197 | (main.filter
198 | (each: !each.asNativeBuildInput)
199 | (tomlPackagesWithSources)
200 | )
201 | );
202 | nativeBuildInputs = (main.map
203 | (each: each.value)
204 | (main.filter
205 | (each: each.asNativeBuildInput)
206 | (tomlPackagesWithSources)
207 | )
208 | );
209 | depedencyPackages = (main.listToAttrs
210 | (tomlAndBuiltinPackagesWithSources)
211 | );
212 | packagePathsAsJson = (main.toJSON
213 | ({
214 | packagePathFor = depedencyPackages;
215 | libPathFor = (main.listToAttrs
216 | (main.map
217 | (each:
218 | ({
219 | name = each.name;
220 | value = "${main.makeLibraryPath [ each.value ]}";
221 | })
222 | )
223 | (tomlAndBuiltinPackagesWithSources)
224 | )
225 | );
226 | })
227 | );
228 | return = (main.mergeAttrs
229 | (main)
230 | ({
231 | nixPath = "${defaultFrom}";
232 | packages = packages;
233 | importMixin = (
234 | fileName : (builtins.import
235 | (builtins.toPath
236 | "${pathToThisFile}/../mixins/${fileName}"
237 | )
238 | ({
239 | main = return;
240 | })
241 | )
242 | );
243 | mergeMixins = (
244 | mixins : (
245 | # this combines them into one big map ({}), which is done for any env vars they set
246 | (main.foldl'
247 | (curr: next: curr // next)
248 | {}
249 | mixins
250 | )
251 |
252 | //
253 |
254 | # here's how all the normal attributes are merged
255 | {
256 | buildInputs = (main.concatLists
257 | (main.map
258 | (
259 | each: ( { buildInputs=[]; } // each ).buildInputs
260 | )
261 | mixins
262 | )
263 | );
264 | nativeBuildInputs = (main.concatLists
265 | (main.map
266 | (
267 | each: ( { nativeBuildInputs=[]; } // each ).nativeBuildInputs
268 | )
269 | mixins
270 | )
271 | );
272 | shellHook = (main.concatStringsSep "\n"
273 | (main.map
274 | (
275 | each: ( { shellHook=""; } // each ).shellHook
276 | )
277 | mixins
278 | )
279 | );
280 | }
281 | )
282 | );
283 | project = {
284 | buildInputs = buildInputs;
285 | nativeBuildInputs = nativeBuildInputs;
286 | shellHook = ''
287 | #
288 | # find the fornix_core
289 | #
290 | path_to_fornix_core=""
291 | file_name="settings/fornix_core"
292 | folder_to_look_in="$PWD"
293 | while :
294 | do
295 | # check if file exists
296 | if [ -f "$folder_to_look_in/$file_name" ]
297 | then
298 | path_to_fornix_core="$folder_to_look_in/$file_name"
299 | break
300 | else
301 | if [ "$folder_to_look_in" = "/" ]
302 | then
303 | break
304 | else
305 | folder_to_look_in="$(dirname "$folder_to_look_in")"
306 | fi
307 | fi
308 | done
309 | if [ -z "$path_to_fornix_core" ]
310 | then
311 | #
312 | # what to do if file never found
313 | #
314 | echo "Im part of parse_dependencies.nix, a script running with a pwd of:$PWD"
315 | echo "Im looking for settings/fornix_core in a parent folder"
316 | echo "Im exiting now because I wasnt able to find it"
317 | echo "thats all the information I have"
318 | exit
319 | fi
320 | export FORNIX_NEXT_RUN_DONT_DO_MANUAL_START="true"
321 | . "$path_to_fornix_core"
322 |
323 | if [ "$FORNIX_DEBUG" = "true" ]; then
324 | echo "starting: 'shellHook' inside the 'settings/extensions/nix/parse_dependencies.nix' file"
325 | fi
326 |
327 | # ensure that the folder exists
328 | mkdir -p "$(dirname "$__FORNIX_NIX_PATH_EXPORT_FILE")"
329 | echo ${main.escapeShellArg (packagePathsAsJson)} > "$__FORNIX_NIX_PATH_EXPORT_FILE"
330 |
331 | if [ -n "$FORNIX_HOME" ]
332 | then
333 | # we don't want to give nix or other apps our home folder
334 | if ! [ "$HOME" = "$FORNIX_HOME" ]
335 | then
336 | if [ "$FORNIX_DEBUG" = "true" ]; then
337 | echo "replacing: HOME with FORNIX_HOME"
338 | fi
339 | mkdir -p "$FORNIX_HOME/.cache/"
340 | ln -s "$HOME/.cache/nix/" "$FORNIX_HOME/.cache/" &>/dev/null
341 |
342 | # so make the home folder the same as the project folder
343 | export HOME="$FORNIX_HOME"
344 | # make it explicit which nixpkgs we're using
345 | export NIX_PATH="nixpkgs=${defaultFrom}:."
346 | fi
347 | fi
348 | '';
349 | };
350 |
351 | })
352 | );
353 | }).return
--------------------------------------------------------------------------------
/settings/extensions/nix/settings.toml:
--------------------------------------------------------------------------------
1 | defaultFrom = "ce6aa13369b667ac2542593170993504932eb836" # this is a commit hash on the nixpkgs repo on github for the stable version 22.05 (May 2022)
2 |
3 | [config]
4 | allowUnfree = true
5 | permittedInsecurePackages = [ "openssl-1.0.2u",]
--------------------------------------------------------------------------------
/settings/extensions/nix/shell.nix:
--------------------------------------------------------------------------------
1 | #
2 | # how to add packages?
3 | #
4 | # you can search for them here: https://search.nixos.org/packages
5 | # to find them in the commandline use:
6 | # nix-env -qP --available PACKAGE_NAME_HERE | cat
7 | # ex:
8 | # nix-env -qP --available opencv
9 | #
10 | # NOTE: some things (like setuptools) just don't show up in the
11 | # search results for some reason, and you just have to guess and check 🙃
12 |
13 | # Lets setup some definitions
14 | let
15 | #
16 | # load most things from the nix.toml
17 | #
18 | main = (builtins.import
19 | (builtins.getEnv
20 | ("__FORNIX_NIX_MAIN_CODE_PATH")
21 | )
22 | );
23 | snowball = import (builtins.fetchurl "https://raw.githubusercontent.com/jeff-hykin/snowball/29a4cb39d8db70f9b6d13f52b3a37a03aae48819/snowball.nix");
24 |
25 | # just a helper
26 | emptyOptions = ({
27 | buildInputs = [];
28 | nativeBuildInputs = [];
29 | shellHook = "";
30 | });
31 |
32 | #
33 | # Linux Only
34 | #
35 | linuxOnly = if main.stdenv.isLinux then ({
36 | buildInputs = [];
37 | nativeBuildInputs = [];
38 | shellHook = ''
39 | if [[ "$OSTYPE" == "linux-gnu" ]]
40 | then
41 | true # add important (LD_LIBRARY_PATH, PATH, etc) nix-Linux code here
42 | export EXTRA_CCFLAGS="$EXTRA_CCFLAGS:-I/usr/include"
43 | fi
44 | '';
45 | # for python with CUDA
46 | # 1. install cuda drivers on the main machine then
47 | # 2. include the following inside the shellCode if statement above
48 | # export CUDA_PATH="${main.packages.cudatoolkit}"
49 | # export EXTRA_LDFLAGS="-L/lib -L${main.packages.linuxPackages.nvidia_x11}/lib"
50 | # export EXTRA_CCFLAGS="-I/usr/include"
51 | # export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${main.packages.linuxPackages.nvidia_x11}/lib:${main.packages.ncurses5}/lib:/run/opengl-driver/lib"
52 | # export LD_LIBRARY_PATH="$(${main.packages.nixGLNvidia}/bin/nixGLNvidia printenv LD_LIBRARY_PATH):$LD_LIBRARY_PATH"
53 | # export LD_LIBRARY_PATH="${main.makeLibraryPath [ main.packages.glib ] }:$LD_LIBRARY_PATH"
54 | # 3. then add the following to the nix.toml file
55 | # #
56 | # # Nvidia
57 | # #
58 | # [[packages]]
59 | # load = [ "nixGLNvidia",]
60 | # onlyIf = [ [ "stdenv", "isLinux",],]
61 | # # see https://discourse.nixos.org/t/opencv-with-cuda-in-nix-shell/7358/5
62 | # from = { fetchGit = { url = "https://github.com/guibou/nixGL", rev = "7d6bc1b21316bab6cf4a6520c2639a11c25a220e" }, }
63 | #
64 | # [[packages]]
65 | # load = [ "pkgconfig",]
66 | # asNativeBuildInput = true
67 | # onlyIf = [ [ "stdenv", "isLinux",],]
68 | #
69 | # [[packages]]
70 | # load = [ "cudatoolkit",]
71 | # onlyIf = [ [ "stdenv", "isLinux",],]
72 | #
73 | # [[packages]]
74 | # load = [ "libconfig",]
75 | # asNativeBuildInput = true
76 | # onlyIf = [ [ "stdenv", "isLinux",],]
77 | #
78 | # [[packages]]
79 | # load = [ "cmake",]
80 | # asNativeBuildInput = true
81 | # onlyIf = [ [ "stdenv", "isLinux",],]
82 | #
83 | # [[packages]]
84 | # load = [ "libGLU",]
85 | # onlyIf = [ [ "stdenv", "isLinux",],]
86 | #
87 | # [[packages]]
88 | # load = [ "linuxPackages", "nvidia_x11",]
89 | # onlyIf = [ [ "stdenv", "isLinux",],]
90 | #
91 | # [[packages]]
92 | # load = [ "stdenv", "cc",]
93 | # onlyIf = [ [ "stdenv", "isLinux",],]
94 | #
95 | # 4. if you want opencv with cuda add the following to the nix.toml
96 | # #
97 | # # opencv
98 | # #
99 | # [[packages]]
100 | # onlyIf = [ [ "stdenv", "isLinux",],]
101 | # load = [ "opencv4",]
102 | # override = { enableGtk3 = true, enableFfmpeg = true, enableCuda = true, enableUnfree = true, }
103 | # # see https://discourse.nixos.org/t/opencv-with-cuda-in-nix-shell/7358/5
104 | # from = { fetchGit = { url = "https://github.com/NixOS/nixpkgs/", rev = "a332da8588aeea4feb9359d23f58d95520899e3c" }, options = { config = { allowUnfree = true } }, }
105 | }) else emptyOptions;
106 |
107 | #
108 | # Mac Only
109 | #
110 | macOnly = if main.stdenv.isDarwin then ({
111 | buildInputs = [];
112 | nativeBuildInputs = [];
113 | shellHook = ''
114 | if [[ "$OSTYPE" = "darwin"* ]]
115 | then
116 | true # add important nix-MacOS code here
117 | export EXTRA_CCFLAGS="$EXTRA_CCFLAGS:-I/usr/include:${main.packages.darwin.apple_sdk.frameworks.CoreServices}/Library/Frameworks/CoreServices.framework/Headers/"
118 | fi
119 | '';
120 | }) else emptyOptions;
121 |
122 | # using the above definitions
123 | in
124 | #
125 | # create a shell
126 | #
127 | (main.packages.mkShell
128 | (main.mergeMixins
129 | [
130 | main.project
131 | linuxOnly
132 | macOnly
133 | # an "inline" mixin (this is what each mixin looks like)
134 | ({
135 | # inside that shell, make sure to use these packages
136 | buildInputs = [];
137 |
138 | nativeBuildInputs = [];
139 |
140 | # run some bash code before starting up the shell
141 | shellHook = ''
142 | # provide access to ncurses for nice terminal interactions
143 | export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${main.packages.ncurses5}/lib"
144 | export LD_LIBRARY_PATH="${main.makeLibraryPath [ main.packages.glib ] }:$LD_LIBRARY_PATH"
145 |
146 | if [ "$FORNIX_DEBUG" = "true" ]; then
147 | echo "finished: 'shellHook' inside the 'settings/extensions/nix/shell.nix' file"
148 | echo ""
149 | echo "Tools/Commands mentioned in 'settings/extensions/nix/nix.toml' are now available/installed"
150 | fi
151 | '';
152 | })
153 | ]
154 | )
155 | )
156 |
--------------------------------------------------------------------------------
/settings/extensions/nix/uninstaller_helper:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo ""
4 | echo "If you've still got a problem after this"
5 | if [ "$(uname)" = "Darwin" ]
6 | then
7 | echo "take a look here: https://nixos.org/manual/nix/stable/installation/installing-binary.html#macos"
8 | else
9 | echo "take a look here: https://nixos.org/manual/nix/stable/installation/installing-binary.html#linux"
10 | fi
11 | echo "Okay?"
12 | read
13 |
14 | if [ -z "$NIX_ROOT" ]
15 | then
16 | export NIX_ROOT="/nix"
17 | fi
18 |
19 |
20 |
21 | if [ "$(uname)" = "Darwin" ]
22 | then
23 | # TODO: make sure this fully removes LaunchDaemon: org.nixos.darwin-store
24 | sudo launchctl bootout system/org.nixos.darwin-store
25 |
26 | # check if file exists
27 | if [ -f "/Library/LaunchDaemon/org.nixos.nix-daemon.plist" ]
28 | then
29 | echo "removing LaunchDaemon1"
30 | sudo launchctl unload /Library/LaunchDaemon/org.nixos.nix-daemon.plist
31 | sudo rm /Library/LaunchDaemons/org.nixos.nix-daemon.plist
32 | fi
33 |
34 |
35 | # check if file exists
36 | if [ -f "/Library/LaunchDaemons/org.nixos.activate-system.plist" ]
37 | then
38 | echo "removing LaunchDaemon2"
39 | sudo launchctl unload /Library/LaunchDaemons/org.nixos.activate-system.plist
40 | sudo rm /Library/LaunchDaemons/org.nixos.activate-system.plist
41 | fi
42 |
43 | # if it was mounted
44 | if sudo diskutil list | grep 'Nix Store' &>/dev/null
45 | then
46 | echo "removing nix volume"
47 | # it was removed successfully
48 | if sudo diskutil apfs deleteVolume /nix
49 | then
50 | sudo diskutil apfs deleteVolume /nix && sudo rm -rf /nix/
51 | fi
52 | echo "may need to reboot for full effect"
53 | fi
54 |
55 | # check if file exists
56 | mount_filepath="/etc/synthetic.conf"
57 | if [ -f "$mount_filepath" ]
58 | then
59 | echo "removing $mount_filepath"
60 | # if file contains "nix"
61 | if cat "$mount_filepath" | grep 'nix' &>/dev/null
62 | then
63 | # remove nix from the file
64 | sudo mount_filepath="$mount_filepath" -- bash -c '
65 | sudo cat "$mount_filepath" | sed -E '"'"'s/nix\n?$//g'"'"' > "$mount_filepath"
66 | '
67 | fi
68 | fi
69 |
70 | # check if file exists
71 | if [ -f "/etc/fstab" ]; then
72 | write_to_fstab() {
73 | new_fstab_lines="$0"
74 | # vifs must be used to edit fstab
75 | # to make that work we create a patch using "diff"
76 | # then tell vifs to use "patch" as an editor and apply the patch
77 | /usr/bin/diff /etc/fstab <(/usr/bin/printf "%s" "$new_fstab_lines") | EDITOR="/usr/bin/patch" sudo vifs
78 | }
79 | # if name_of_command doesnt exist
80 | if /usr/bin/grep "$NIX_ROOT apfs rw" /etc/fstab; then
81 | echo "Patching fstab"
82 | fstab_without_nix="$(/usr/bin/grep -v "$NIX_ROOT apfs rw" /etc/fstab)"
83 | write_to_fstab "$fstab_without_nix"
84 | fi
85 | fi
86 | fi
87 |
88 |
89 | delete_user () {
90 | user="$1"
91 | # logs them out by locking the account
92 | sudo passwd -l "$user" 2>/dev/null
93 | # kill all their processes
94 | sudo pkill -KILL -u "$user" 2>/dev/null
95 | # kill all their cron jobs
96 | sudo crontab -r -u "$user" 2>/dev/null
97 | # kill all their print jobs
98 | if [ -n "$(command -v "lprm")" ]
99 | then
100 | lprm -U "$user" 2>/dev/null
101 | fi
102 | # actually remove the user
103 | sudo deluser --remove-home "$user" 2>/dev/null # debian
104 | sudo userdel --remove "$user" 2>/dev/null # non-debian
105 | }
106 |
107 | remove_service () {
108 | service="$1"
109 | # if systemctl exists
110 | if [ -n "$(command -v "systemctl")" ]
111 | then
112 | sudo systemctl stop "$service"
113 | sudo systemctl disable "$service"
114 | sudo rm -f /etc/systemd/system/"$service"
115 | sudo rm -f /etc/systemd/system/"$service" # and symlinks that might be related
116 | sudo rm -f /usr/lib/systemd/system/"$service"
117 | sudo rm -f /usr/lib/systemd/system/"$service" # and symlinks that might be related
118 | sudo systemctl daemon-reload
119 | sudo systemctl reset-failed
120 | fi
121 | }
122 |
123 | # stop the daemon
124 | echo "removing service"
125 | remove_service nix-daemon.service
126 | remove_service nix-daemon.socket
127 |
128 | # remove the users
129 | echo "removing users"
130 | delete_user nixbld1
131 | delete_user nixbld2
132 | delete_user nixbld3
133 | delete_user nixbld4
134 | delete_user nixbld5
135 | delete_user nixbld6
136 | delete_user nixbld7
137 | delete_user nixbld8
138 | delete_user nixbld9
139 | delete_user nixbld10
140 | delete_user nixbld11
141 | delete_user nixbld12
142 | delete_user nixbld13
143 | delete_user nixbld14
144 | delete_user nixbld15
145 | delete_user nixbld16
146 | delete_user nixbld17
147 | delete_user nixbld18
148 | delete_user nixbld19
149 | delete_user nixbld20
150 | delete_user nixbld21
151 | delete_user nixbld22
152 | delete_user nixbld23
153 | delete_user nixbld24
154 | delete_user nixbld25
155 | delete_user nixbld26
156 | delete_user nixbld27
157 | delete_user nixbld28
158 | delete_user nixbld29
159 | delete_user nixbld30
160 | delete_user nixbld31
161 | delete_user nixbld32
162 |
163 | # remove the group
164 | echo "removing group"
165 | sudo groupdel nixbld 2>/dev/null
166 |
167 | # remove all the files
168 | echo "removing all nixpkgs files"
169 | sudo rm -rf /etc/nix /nix /var/root/.nix-profile /var/root/.nix-defexpr /var/root/.nix-channels "$HOME"/.nix-profile "$HOME"/.nix-defexpr "$HOME"/.nix-channels 2>/dev/null
170 |
171 | # restore the shell files
172 | echo "restoring any shell files"
173 | if [ -f "/etc/bashrc.backup-before-nix" ]
174 | then
175 | sudo mv /etc/bashrc.backup-before-nix /etc/bashrc
176 | fi
177 | if [ -f "/etc/profile.d/nix.sh.backup-before-nix" ]
178 | then
179 | sudo mv /etc/profile.d/nix.sh.backup-before-nix /etc/profile.d/nix.sh
180 | fi
181 | if [ -f "/etc/zshrc.backup-before-nix" ]
182 | then
183 | sudo mv /etc/zshrc.backup-before-nix /etc/zshrc
184 | fi
185 | if [ -f "/etc/bash.bashrc.backup-before-nix" ]
186 | then
187 | sudo mv /etc/bash.bashrc.backup-before-nix /etc/bash.bashrc
188 | fi
189 |
190 | echo "final check"
191 | if [ -e "$NIX_ROOT" ]
192 | then
193 | sudo rm -rf "$NIX_ROOT" &>/dev/null
194 | sudo rm -f "$NIX_ROOT" &>/dev/null
195 | if [ -e "$NIX_ROOT" ]
196 | then
197 | echo
198 | echo
199 | echo
200 | echo "Because your system mounted /nix during boot"
201 | echo "I believe you'll need to restart for changes to take affect"
202 | fi
203 | fi
--------------------------------------------------------------------------------
/settings/extensions/nodejs/#establish_extension.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #
4 | # this is just a helper (common to most all extensions)
5 | #
6 | relatively_link="$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/relative_link"
7 |
8 | #
9 | # connect during_clean
10 | #
11 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/during_clean.sh" "$FORNIX_FOLDER/settings/during_clean/804_nodejs.sh"
12 |
13 | #
14 | # connect during_purge
15 | #
16 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/during_purge.sh" "$FORNIX_FOLDER/settings/during_purge/805_remove_node_modules.sh"
17 |
18 | #
19 | # connect commands
20 | #
21 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands" "$FORNIX_COMMANDS_FOLDER/tools/nodejs"
22 |
23 | #
24 | # connect pnpm store since its content-addressed storage
25 | #
26 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/during_start_prep.sh" "$FORNIX_FOLDER/settings/during_start_prep/032_000_link_pnpm_store.sh"
27 |
28 | unset relatively_link
29 |
--------------------------------------------------------------------------------
/settings/extensions/nodejs/commands/check_node_modules:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | __temp_var__executable="node"
4 | # if pnpm exists
5 | if [ -n "$(command -v "pnpm")" ]
6 | then
7 | __temp_var__executable="pnpm"
8 | fi
9 |
10 | #
11 | # ensure FORNIX_FOLDER exists
12 | #
13 | if [ -z "$FORNIX_FOLDER" ]
14 | then
15 | #
16 | # find fornix_core
17 | #
18 | path_to_file=""
19 | file_name="settings/fornix_core"
20 | folder_to_look_in="$PWD"
21 | while :
22 | do
23 | # check if file exists
24 | if [ -f "$folder_to_look_in/$file_name" ]
25 | then
26 | path_to_file="$folder_to_look_in/$file_name"
27 | break
28 | else
29 | if [ "$folder_to_look_in" = "/" ]
30 | then
31 | break
32 | else
33 | folder_to_look_in="$(dirname "$folder_to_look_in")"
34 | fi
35 | fi
36 | done
37 | if [ -z "$path_to_file" ]
38 | then
39 | #
40 | # what to do if file never found
41 | #
42 | echo "Im a script running with a pwd of:$PWD"
43 | echo "Im looking for settings/fornix_core in a parent folder"
44 | echo "Im exiting now because I wasnt able to find it"
45 | echo "thats all the information I have"
46 | exit
47 | fi
48 | export FORNIX_NEXT_RUN_ONLY_DO_BASIC_INIT="true"
49 | # run the basic init of fornix to get the FORNIX_FOLDER/FORNIX_COMMANDS_FOLDER/FORNIX_HOME etc
50 | . "$path_to_file"
51 | fi
52 |
53 | # main inputs
54 | __temp_var__command_name="tools/nodejs/check_node_modules"
55 | __temp_var__file_to_watch="$FORNIX_FOLDER/package.json"
56 | __temp_var__hash_check_name="node_modules"
57 | failed_check_command () {
58 | # what to do when node modules haven't been installed yet
59 | "$__temp_var__executable" install
60 | # if successful
61 | if [ $? -eq 0 ]
62 | then
63 | echo "[$__temp_var__command_name] Check finished (dependencies installed)"
64 | return 0
65 | else
66 | echo "[$__temp_var__command_name] Check failed: issues with $__temp_var__executable install"
67 | return 1
68 | fi
69 | }
70 |
71 |
72 | # ensure that the source file and hash file exist
73 | echo
74 | echo "[$__temp_var__command_name] Checking"
75 | if [ -f "$__temp_var__file_to_watch" ]; then
76 | #
77 | # create check file
78 | #
79 | __temp_var__location_of_hash="$FORNIX_FOLDER/settings/.cache/.$__temp_var__hash_check_name.cleanable.hash"
80 | if ! [[ -f "$__temp_var__location_of_hash" ]]; then
81 | # make sure the folder exists
82 | mkdir -p "$(dirname "$__temp_var__location_of_hash")"
83 | touch "$__temp_var__location_of_hash"
84 | fi
85 |
86 | #
87 | # compare check files
88 | #
89 | __temp_var__old_hash="$(cat "$__temp_var__location_of_hash")"
90 | __temp_var__new_hash="$(cat "$__temp_var__file_to_watch" | md5sum)"
91 | # if something changed since last time; install!
92 | if [[ "$__temp_var__old_hash" != "$__temp_var__new_hash" ]]; then
93 | failed_check_command && echo "$__temp_var__new_hash" > "$__temp_var__location_of_hash"
94 | else
95 | # CUSTOM check, if nothing is installed (after clean/purge) then install!
96 | if ! [[ -d "$FORNIX_FOLDER/node_modules" ]]; then
97 | failed_check_command && echo "$__temp_var__new_hash" > "$__temp_var__location_of_hash"
98 | mkdir -p "$FORNIX_FOLDER/node_modules"
99 | else
100 | echo "[$__temp_var__command_name] Check Passed => assuming packages are installed"
101 | fi
102 | fi
103 |
104 | unset __temp_var__location_of_hash
105 | unset __temp_var__old_hash
106 | unset __temp_var__new_hash
107 | else
108 | echo "[$__temp_var__command_name] Check Passed (but only because no dependency file was found)"
109 | fi
110 | unset __temp_var__command_name
111 | unset __temp_var__file_to_watch
112 | unset __temp_var__hash_check_name
113 | unset __temp_var__executable
--------------------------------------------------------------------------------
/settings/extensions/nodejs/during_clean.sh:
--------------------------------------------------------------------------------
1 | # delete all the __pycache__'s
2 | for item in $(find "$FORNIX_FOLDER" ! -path . -iregex '__pycache__')
3 | do
4 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$item"
5 | done
--------------------------------------------------------------------------------
/settings/extensions/nodejs/during_purge.sh:
--------------------------------------------------------------------------------
1 | if [ -d "$FORNIX_FOLDER" ]
2 | then
3 | # delete node_modules
4 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_FOLDER/node_modules"
5 | # .npm
6 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/.npm"
7 | # npmrc
8 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/.npmrc"
9 | fi
--------------------------------------------------------------------------------
/settings/extensions/nodejs/during_start_prep.sh:
--------------------------------------------------------------------------------
1 | # if inside start-prep
2 | if [ "$HOME" != "$FORNIX_HOME" ]
3 | then
4 | # system link into project home
5 | __temp_var__which_item=".pnpm-store"
6 |
7 | # if it doesn't exist in the home folder
8 | if ! [ -e "$HOME/$__temp_var__which_item" ]
9 | then
10 | # create the folder
11 | mkdir -p "$HOME/$__temp_var__which_item"
12 | fi
13 | # remove the existing
14 | rm -f "$FORNIX_HOME/$__temp_var__which_item" 2>/dev/null
15 | rm -rf "$FORNIX_HOME/$__temp_var__which_item" 2>/dev/null
16 | # then link it
17 | ln -s "$HOME/$__temp_var__which_item" "$FORNIX_HOME/$__temp_var__which_item"
18 | # make sure to ignore it
19 | "$FORNIX_FOLDER/settings/extensions/git/commands/ignore" "$FORNIX_HOME/$__temp_var__which_item"
20 |
21 | unset __temp_var__which_item
22 | fi
23 |
--------------------------------------------------------------------------------
/settings/extensions/os_mac/#establish_extension.sh:
--------------------------------------------------------------------------------
1 | # this is a helper
2 | relatively_link="$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/relative_link"
3 |
4 | #
5 | # connect during_purge
6 | #
7 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/during_purge.sh" "$FORNIX_FOLDER/settings/during_purge/580_mac_library_caches.sh"
8 |
9 | #
10 | # connect during_start_prep
11 | #
12 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/during_start_prep.sh" "$FORNIX_FOLDER/settings/during_start_prep/049_000_link_keychain.sh"
13 |
14 |
15 | unset relatively_link
--------------------------------------------------------------------------------
/settings/extensions/os_mac/during_purge.sh:
--------------------------------------------------------------------------------
1 | # the mac library cache
2 | if [ -d "$FORNIX_FOLDER" ]
3 | then
4 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/Library/Caches"
5 | fi
--------------------------------------------------------------------------------
/settings/extensions/os_mac/during_start_prep.sh:
--------------------------------------------------------------------------------
1 | # keychain is mac-os specific, just FYI
2 | __temp_var_path_to_keychain="$HOME/Library/Keychains/"
3 | if [[ -d "$__temp_var_path_to_keychain" ]]; then
4 | mkdir -p "$FORNIX_HOME/Library/"
5 | # link all the keys
6 | ln -sf "$__temp_var_path_to_keychain/" "$FORNIX_HOME/Library/"
7 | fi
8 |
9 | # Make sure the user doesn't accidentally commit their keys/passwords!!
10 | "$FORNIX_FOLDER/settings/extensions/git/commands/ignore" "$FORNIX_HOME/Library/Keychains"
--------------------------------------------------------------------------------
/settings/extensions/python/#establish_extension.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #
4 | # this is just a helper (common to most all extensions)
5 | #
6 | relatively_link="$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/relative_link"
7 |
8 | #
9 | # connect during_start
10 | #
11 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands/setup_venv" "$FORNIX_FOLDER/settings/during_start/019_000_setup_python_venv.sh"
12 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands/add_project_to_pythonpath" "$FORNIX_FOLDER/settings/during_start/022_000_setup_pythonpath.sh"
13 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands/ensure_pip_modules" "$FORNIX_FOLDER/settings/during_start/021_000_ensure_pip_modules.sh"
14 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands/refresh_ignores" "$FORNIX_FOLDER/settings/during_start/024_000_python_ignores.sh"
15 |
16 |
17 | #
18 | # connect during_manual_start
19 | #
20 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands/add_project_to_pythonpath" "$FORNIX_FOLDER/settings/during_manual_start/022_000_setup_pythonpath.sh"
21 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands/refresh_ignores" "$FORNIX_FOLDER/settings/during_manual_start/024_000_python_ignores.sh"
22 |
23 | #
24 | # connect during_clean
25 | #
26 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/during_clean.sh" "$FORNIX_FOLDER/settings/during_clean/801_python.sh"
27 |
28 | #
29 | # connect during_purge
30 | #
31 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/during_purge.sh" "$FORNIX_FOLDER/settings/during_purge/802_remove_venv.sh"
32 |
33 | #
34 | # connect commands
35 | #
36 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands" "$FORNIX_COMMANDS_FOLDER/tools/python"
37 |
38 | #
39 | # connect git hooks
40 | #
41 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands/ensure_pip_modules" "$FORNIX_FOLDER/settings/extensions/git/hooks/post-update/901_check_pip_modules"
42 | "$relatively_link" "$__THIS_FORNIX_EXTENSION_FOLDERPATH__/commands/ensure_pip_modules" "$FORNIX_FOLDER/settings/extensions/git/hooks/post-merge/901_check_pip_modules"
43 |
44 | unset relatively_link
--------------------------------------------------------------------------------
/settings/extensions/python/commands/add_project_to_pythonpath:
--------------------------------------------------------------------------------
1 | #
2 | # add pythonpath
3 | #
4 | export PYTHONPATH="$PYTHONPATH:$FORNIX_FOLDER:$FORNIX_FOLDER/main"
--------------------------------------------------------------------------------
/settings/extensions/python/commands/ensure_pip_modules:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 |
4 | # if not in the standard env, try to make it work anyways
5 | if [ -z "$FORNIX_FOLDER" ]
6 | then
7 | #
8 | # find FORNIX_FOLDER by walking up the directories
9 | #
10 | path_to_file=""
11 | file_name="settings/fornix_core"
12 | folder_to_look_in="$PWD"
13 | while :
14 | do
15 | # check if file exists
16 | if [ -f "$folder_to_look_in/$file_name" ]
17 | then
18 | path_to_file="$folder_to_look_in/$file_name"
19 | break
20 | else
21 | if [ "$folder_to_look_in" = "/" ]
22 | then
23 | break
24 | else
25 | folder_to_look_in="$(dirname "$folder_to_look_in")"
26 | fi
27 | fi
28 | done
29 | if [ -z "$path_to_file" ]
30 | then
31 | #
32 | # what to do if file never found
33 | #
34 | echo "Im a script running with a pwd of:$PWD"
35 | echo "Im looking for settings/fornix_core in a parent folder"
36 | echo "Im exiting now because I wasnt able to find it"
37 | echo "thats all the information I have"
38 | exit
39 | fi
40 | export FORNIX_FOLDER="$(dirname "$(dirname "$path_to_file")")"
41 | fi
42 |
43 | # if poetry not installed, install it
44 | if ! python -c "import poetry" 2>/dev/null; then
45 | python -m pip --disable-pip-version-check install poetry==1.2.1 || python -m pip --disable-pip-version-check install poetry
46 | fi
47 |
48 | #
49 | # check for python-poetry
50 | #
51 | if [ -f "$FORNIX_FOLDER/pyproject.toml" ] && [ -n "$(command -v "poetry")" ]
52 | then
53 | # main inputs
54 | __temp_var__command_name="tools/python/check_pip_modules"
55 | __temp_var__file_to_watch="$FORNIX_FOLDER/pyproject.toml"
56 | __temp_var__hash_check_name="pip_poetry_modules"
57 | failed_check_command () {
58 | # for newer versions of poetry tell them to use the existing virtual env
59 | poetry config virtualenvs.path --unset 2>/dev/null
60 | poetry config virtualenvs.in-project true 2>/dev/null
61 |
62 | # what to do when node modules haven't been installed yet
63 | poetry install
64 | # if successful
65 | if [ $? -eq 0 ]
66 | then
67 | echo "[$__temp_var__command_name] Check finished (dependencies installed)"
68 | return 0
69 | # if failed
70 | else
71 | echo "[$__temp_var__command_name] Check failed: issues with install"
72 | return 1
73 | fi
74 | }
75 |
76 | # ensure that the source file and hash file exist
77 | echo
78 | echo "[$__temp_var__command_name] Checking"
79 | if [ -f "$__temp_var__file_to_watch" ]; then
80 | #
81 | # create check file
82 | #
83 | __temp_var__location_of_hash="$FORNIX_FOLDER/settings/.cache/.$__temp_var__hash_check_name.cleanable.hash"
84 | if ! [ -f "$__temp_var__location_of_hash" ]; then
85 | # make sure the folder exists
86 | mkdir -p "$(dirname "$__temp_var__location_of_hash")"
87 | touch "$__temp_var__location_of_hash"
88 | fi
89 |
90 | #
91 | # compare check files
92 | #
93 | __temp_var__old_hash="$(cat "$__temp_var__location_of_hash")"
94 | __temp_var__new_hash="$(cat "$__temp_var__file_to_watch" | md5sum)"
95 | # if something changed since last time; install!
96 | if [ "$__temp_var__old_hash" != "$__temp_var__new_hash" ]; then
97 | failed_check_command && echo "$__temp_var__new_hash" > "$__temp_var__location_of_hash"
98 | else
99 | echo "[$__temp_var__command_name] Check Passed => assuming packages are installed"
100 | fi
101 |
102 | unset __temp_var__location_of_hash
103 | unset __temp_var__old_hash
104 | unset __temp_var__new_hash
105 | else
106 | echo "[$__temp_var__command_name] Check Passed (but only because no dependency file was found)"
107 | fi
108 | unset __temp_var__command_name
109 | unset __temp_var__file_to_watch
110 | unset __temp_var__hash_check_name
111 | fi
112 |
113 | #
114 | # check for requirements.txt
115 | #
116 | if [ -f "$FORNIX_FOLDER/requirements.txt" ]
117 | then
118 | # main inputs
119 | __temp_var__command_name="tools/python/check_pip_modules"
120 | __temp_var__file_to_watch="$FORNIX_FOLDER/requirements.txt"
121 | __temp_var__hash_check_name="pip_modules"
122 | failed_check_command () {
123 | # what to do when node modules haven't been installed yet
124 | python -m pip --disable-pip-version-check install -r "$__temp_var__file_to_watch"
125 | # if successful
126 | if [ $? -eq 0 ]
127 | then
128 | echo "[$__temp_var__command_name] Check finished (dependencies installed)"
129 | return 0
130 | # if failed
131 | else
132 | echo "[$__temp_var__command_name] Check failed: issues with install"
133 | return 1
134 | fi
135 | }
136 |
137 | # ensure that the source file and hash file exist
138 | echo
139 | echo "[$__temp_var__command_name] Checking"
140 | if [ -f "$__temp_var__file_to_watch" ]; then
141 | #
142 | # create check file
143 | #
144 | __temp_var__location_of_hash="$FORNIX_FOLDER/settings/.cache/.$__temp_var__hash_check_name.cleanable.hash"
145 | if ! [ -f "$__temp_var__location_of_hash" ]; then
146 | # make sure the folder exists
147 | mkdir -p "$(dirname "$__temp_var__location_of_hash")"
148 | touch "$__temp_var__location_of_hash"
149 | fi
150 |
151 | #
152 | # compare check files
153 | #
154 | __temp_var__old_hash="$(cat "$__temp_var__location_of_hash")"
155 | __temp_var__new_hash="$(cat "$__temp_var__file_to_watch" | md5sum)"
156 | # if something changed since last time; install!
157 | if [ "$__temp_var__old_hash" != "$__temp_var__new_hash" ]; then
158 | failed_check_command && echo "$__temp_var__new_hash" > "$__temp_var__location_of_hash"
159 | else
160 | echo "[$__temp_var__command_name] Check Passed => assuming packages are installed"
161 | fi
162 |
163 | unset __temp_var__location_of_hash
164 | unset __temp_var__old_hash
165 | unset __temp_var__new_hash
166 | else
167 | echo "[$__temp_var__command_name] Check Passed (but only because no dependency file was found)"
168 | fi
169 | unset __temp_var__command_name
170 | unset __temp_var__file_to_watch
171 | unset __temp_var__hash_check_name
172 | fi
173 |
174 | # fix for https://askubuntu.com/questions/441744/pressing-enter-produces-m-instead-of-a-newline
175 | stty sane
--------------------------------------------------------------------------------
/settings/extensions/python/commands/refresh_ignores:
--------------------------------------------------------------------------------
1 | "$FORNIX_FOLDER/settings/extensions/git/commands/ignore" ".venv"
2 | # python creates a cache here on MacOS
3 | "$FORNIX_FOLDER/settings/extensions/git/commands/ignore" "settings/home/Library/Caches"
--------------------------------------------------------------------------------
/settings/extensions/python/commands/setup_venv:
--------------------------------------------------------------------------------
1 | # TMPDIR fixes a pip issue
2 | export TMPDIR="$FORNIX_HOME/tmp.cleanable"
3 | mkdir -p "$TMPDIR"
4 | export VIRTUAL_ENV="$FORNIX_FOLDER/.venv"
5 | export PATH="$FORNIX_HOME/.local/bin:$PATH"
6 | if ! [ -d "$VIRTUAL_ENV" ]
7 | then
8 | echo "creating virtual env for python"
9 | # run the cleanup
10 | . "$FORNIX_FOLDER/settings/extensions/python/during_clean.sh"
11 | python -m venv "$VIRTUAL_ENV" && echo "virtual env created"
12 | fi
13 |
14 | export PATH="$VIRTUAL_ENV/bin:$PATH"
15 |
16 | # fix SSL issues
17 | export SSL_CERT_FILE="$(python -c 'import ssl; print(ssl.get_default_verify_paths().openssl_cafile)')"
--------------------------------------------------------------------------------
/settings/extensions/python/during_clean.sh:
--------------------------------------------------------------------------------
1 | # delete all the __pycache__'s
2 | for item in $(find "$FORNIX_FOLDER" ! -path . -iregex '__pycache__')
3 | do
4 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$item"
5 | done
6 |
7 | # remove the hashes
8 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_FOLDER/.cache/.pip_poetry_modules.cleanable.hash"
9 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_FOLDER/.cache/.pip_modules.cleanable.hash"
--------------------------------------------------------------------------------
/settings/extensions/python/during_purge.sh:
--------------------------------------------------------------------------------
1 | if [ -d "$FORNIX_FOLDER" ]
2 | then
3 | # delete venv
4 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_FOLDER/.venv"
5 |
6 | # if poetry exists
7 | if [ -n "$(command -v "poetry")" ]
8 | then
9 | # clear all the caches
10 | yes | poetry cache clear . --all
11 | fi
12 |
13 | # all the home folder junk from python and common pip modules
14 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/.cache/pip"
15 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/.cache/pypoetry/"
16 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/.local/share/virtualenv"
17 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/.config/pypoetry"
18 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/.config/matplotlib"
19 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/.ipython"
20 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/.jupyter"
21 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/.keras"
22 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/.local/share/jupyter"
23 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/.python_history"
24 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/Library/Application Support/pypoetry"
25 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/Library/Application Support/virtualenv"
26 | "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/file_system/remove" "$FORNIX_HOME/Library/Library/Preferences/pypoetry"
27 | fi
--------------------------------------------------------------------------------
/settings/fornix_core:
--------------------------------------------------------------------------------
1 | #
2 | # NOTE: I wouldn't recommend adding new variables (or anything) here
3 | #
4 | # (but the existing vars can be changed, and you can add custom logic with settings/extensions/YOUR_THING/#establish_extension.sh)
5 |
6 | # change the "false" to "true" to see how everything works!
7 | export FORNIX_DEBUG="false"
8 |
9 | #
10 | # helper function
11 | #
12 | __fornix_debug_message () { if [ "$FORNIX_DEBUG" = "true" ]; then echo "$@"; fi }
13 | __fornix_debug_message "starting: settings/fornix_core"
14 |
15 | #
16 | # find this file
17 | #
18 | __fornix_debug_message " looking for settings/fornix_core (yes, I'm trying to find myself)"
19 | path_to_file=""
20 | file_name="settings/fornix_core"
21 | folder_to_look_in="$PWD"
22 | while :
23 | do
24 | # check if file exists
25 | if [ -f "$folder_to_look_in/$file_name" ]
26 | then
27 | path_to_file="$folder_to_look_in/$file_name"
28 | break
29 | else
30 | if [ "$folder_to_look_in" = "/" ]
31 | then
32 | break
33 | else
34 | folder_to_look_in="$(dirname "$folder_to_look_in")"
35 | fi
36 | fi
37 | done
38 | if [ -z "$path_to_file" ]
39 | then
40 | #
41 | # what to do if file never found
42 | #
43 | echo "Im a script running with a pwd of:$PWD"
44 | echo "Im looking for settings/fornix_core in a parent folder"
45 | echo "Im exiting now because I wasnt able to find it"
46 | echo "thats all the information I have"
47 | exit
48 | fi
49 | __fornix_debug_message " I found myself"
50 |
51 | #
52 | # set main vars
53 | #
54 | __fornix_debug_message " Establishing (possibly re-establishing) the three core env variables"
55 | export FORNIX_FOLDER="$(dirname "$(dirname "$path_to_file")")"
56 | export FORNIX_HOME="$FORNIX_FOLDER/settings/home/"
57 | export FORNIX_COMMANDS_FOLDER="$FORNIX_FOLDER/commands/"
58 | __fornix_debug_message " FORNIX_FOLDER: '$FORNIX_FOLDER'"
59 | __fornix_debug_message " FORNIX_HOME: '$FORNIX_HOME'"
60 | __fornix_debug_message " FORNIX_COMMANDS_FOLDER: '$FORNIX_COMMANDS_FOLDER'"
61 |
62 | #
63 | # run the refresh for each of the extensions (if the flag it not set)
64 | #
65 | if ! [ "$FORNIX_NEXT_RUN_ONLY_DO_BASIC_INIT" = "true" ]
66 | then
67 | __fornix_debug_message " Becase FORNIX_NEXT_RUN_ONLY_DO_BASIC_INIT != 'true'"
68 | __fornix_debug_message " I'm going to run each of the #establish_extension.sh files for every folder inside settings/extensions/"
69 | #
70 | # check that realpath exists and works
71 | #
72 |
73 | # if realpath doesnt exist, try to install it with nix-env
74 | if [ -z "$(command -v "realpath")" ]
75 | then
76 | # if nix-env exists
77 | if [ -n "$(command -v "nix-env")" ]
78 | then
79 | # this is the 21.05 release
80 | nix-env -i coreutils -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/a7ecde854aee5c4c7cd6177f54a99d2c1ff28a31.tar.gz
81 | fi
82 | fi
83 |
84 | __temp_var__realpath_works=""
85 | # if realpath exists
86 | if [ -n "$(command -v "realpath")" ]
87 | then
88 | __temp_var__test_output="$(realpath "/Blah/blahBlahBlah/aFolder/fornix/settings/extensions/#standard" --relative-to="/Blah/blahBlahBlah/aFolder/fornix/commands//tools" --canonicalize-missing)"
89 | if [ "$__temp_var__test_output" = '../../settings/extensions/#standard' ]
90 | then
91 | __temp_var__realpath_works="true"
92 | fi
93 | unset __temp_var__test_output
94 | fi
95 | #
96 | # run all the #establish_extension.sh files
97 | #
98 | if [ "$__temp_var__realpath_works" = "true" ]
99 | then
100 | # this loop is so stupidly complicated because of many inherent-to-shell reasons, for example: https://stackoverflow.com/questions/13726764/while-loop-subshell-dilemma-in-bash
101 | for_each_item_in="$FORNIX_FOLDER/settings/extensions/"; [ -z "$__NESTED_WHILE_COUNTER" ] && __NESTED_WHILE_COUNTER=0;__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER + 1))"; trap 'rm -rf "$__temp_var__temp_folder"' EXIT; __temp_var__temp_folder="$(mktemp -d)"; mkfifo "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER"; (find "$for_each_item_in" -maxdepth 1 ! -path . -print0 2>/dev/null | sort -z > "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER" &); while read -d $'\0' each
102 | do
103 | __temp_var__file_path="$each/#establish_extension.sh"
104 | # check if file exists
105 | if [ -f "$__temp_var__file_path" ]
106 | then
107 | __fornix_debug_message " loading: $__temp_var__file_path"
108 | # tell the scripts what file they're inside of
109 | export __THIS_FORNIX_EXTENSION_FILEPATH__="$__temp_var__file_path"
110 | export __THIS_FORNIX_EXTENSION_FOLDERPATH__="$each"
111 | . "$__temp_var__file_path"
112 | fi
113 | unset __temp_var__file_path
114 | done < "$__temp_var__temp_folder/pipe_for_while_$__NESTED_WHILE_COUNTER";__NESTED_WHILE_COUNTER="$((__NESTED_WHILE_COUNTER - 1))"
115 | else
116 | echo 'Warning: skipping establish_extension'
117 | echo ' It looks like either you dont have a `realpath` command or the realpath'
118 | echo ' you do have doesnt support --relative-to= and/or --canonicalize-missing'
119 | echo ' this `'"$(which realpath)"'` is what I get after running `which realpath`'
120 | echo " because realpath isn't working, I will be skipping the establish_extension/ "
121 | fi
122 | unset __temp_var__realpath_works
123 | __fornix_debug_message " Finished running the #establish_extension.sh in every folder inside settings/extensions/"
124 |
125 | #
126 | # run manual setup by default
127 | #
128 | if ! [ "$FORNIX_NEXT_RUN_DONT_DO_MANUAL_START" = "true" ]
129 | then
130 | __fornix_debug_message " Becase FORNIX_NEXT_RUN_DONT_DO_MANUAL_START != 'true'"
131 | __fornix_debug_message " I'm going to run all the settings/during_manual_start/ files"
132 | #
133 | # find and run all the manual setup scripts in alphabetical order
134 | #
135 | . "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/fornix/trigger" "$FORNIX_FOLDER/settings/during_manual_start"
136 | fi
137 | else
138 | __fornix_debug_message " Becase FORNIX_NEXT_RUN_ONLY_DO_BASIC_INIT = 'true', I'm done"
139 | fi
140 | # reset flags
141 | export FORNIX_NEXT_RUN_ONLY_DO_BASIC_INIT=""
142 | export FORNIX_NEXT_RUN_DONT_DO_MANUAL_START=""
143 | unset __temp_var__should_run_during_manual_start
144 | __fornix_debug_message "finished: settings/fornix_core"
--------------------------------------------------------------------------------
/settings/home/.zshenv:
--------------------------------------------------------------------------------
1 | #
2 | # if you want to customize things,
3 | # change settings/during_start/00100#setup_zsh.sh instead of editing this file
4 | #
5 |
6 | # don't let zsh update itself without telling all the other packages
7 | # instead use nix to update zsh
8 | DISABLE_AUTO_UPDATE="true"
9 | DISABLE_UPDATE_PROMPT="true"
10 |
11 | #
12 | # this shouldnt ever happen (FORNIX undefined), but just encase
13 | #
14 | if [[ -z "$FORNIX_FOLDER" ]]
15 | then
16 | path_to_file=""
17 | file_name="settings/fornix_core"
18 | folder_to_look_in="$PWD"
19 | while :
20 | do
21 | # check if file exists
22 | if [ -f "$folder_to_look_in/$file_name" ]
23 | then
24 | path_to_file="$folder_to_look_in/$file_name"
25 | break
26 | else
27 | if [ "$folder_to_look_in" = "/" ]
28 | then
29 | break
30 | else
31 | folder_to_look_in="$(dirname "$folder_to_look_in")"
32 | fi
33 | fi
34 | done
35 | if [ -z "$path_to_file" ]
36 | then
37 | #
38 | # what to do if file never found
39 | #
40 | echo "Im a script running with a pwd of:$PWD"
41 | echo "Im looking for settings/fornix_core in a parent folder"
42 | echo "Im exiting now because I wasnt able to find it"
43 | echo "thats all the information I have"
44 | exit
45 | fi
46 | export FORNIX_NEXT_RUN_DONT_DO_MANUAL_START="true"
47 | . "$path_to_file"
48 | fi
49 |
50 | # run the automatic non-zsh-specific setup
51 | . "$FORNIX_FOLDER/settings/extensions/#standard/commands/tools/fornix/trigger" "$FORNIX_FOLDER/settings/during_start"
--------------------------------------------------------------------------------
/settings/home/.zshrc:
--------------------------------------------------------------------------------
1 | # TODO: fixme
2 | . "$spaceship_prompt__path/lib/spaceship-prompt/spaceship.zsh"
--------------------------------------------------------------------------------
/settings/requirements/advanced_system_tools.nix:
--------------------------------------------------------------------------------
1 | ../extensions/nix/shell.nix
--------------------------------------------------------------------------------
/settings/requirements/system_tools.toml:
--------------------------------------------------------------------------------
1 | ../extensions/nix/nix.toml
--------------------------------------------------------------------------------