diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..247a291 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +source_url "https://raw.githubusercontent.com/cachix/devenv/95f329d49a8a5289d31e0982652f7058a189bfca/direnvrc" "sha256-d+8cBpDfDBj41inrADaJt+bDWhOktwslgoP5YiGJ1v0=" + +use devenv diff --git a/.gitignore b/.gitignore index 40e5032..61fb62a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ /_/ + +.devenv* +.direnv diff --git a/.vscode/extensions.json b/.vscode/extensions.json index b29383a..4bf5768 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,9 +1,13 @@ { "recommendations": [ // general + "mkhl.direnv", "skellock.just", "usernamehw.errorlens", + // nix + "jnoortheen.nix-ide", + // js "esbenp.prettier-vscode", diff --git a/.vscode/settings.json b/.vscode/settings.json index 32abfaa..f7b6338 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,8 @@ "cSpell.words": [ "developomp", + "devenv", + "direnv", "fstat", "nums", "rustup", @@ -23,6 +25,13 @@ "editor.defaultFormatter": "esbenp.prettier-vscode" }, + "[nix]": { + "editor.defaultFormatter": "jnoortheen.nix-ide" + }, + "nix.formatterPath": "nixfmt", + "nix.enableLanguageServer": true, + "nix.serverPath": "nixd", + "[c]": { "editor.defaultFormatter": "ms-vscode.cpptools" }, diff --git a/README.md b/README.md index 7c25c74..c1db225 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,20 @@ # Playground -This is [developomp](https://github.com/developomp)'s vscode-based coding playground. +This is my coding playground for... -The playground is used to... - -- quickly test and benchmark snippets of code -- solve algorithm problems +- quickly testing and benchmarking snippets of code +- solving algorithm problems +- playing with new tech without having to create and configure a new project ## Setting up -Setup the following: - -- shell (only if you're a Windows user. Get [Git bash](https://git-scm.com/downloads) / [GitHub Desktop](https://desktop.github.com) / [Cygwin](https://cygwin.com/install.html) / ... ) -- [just](https://github.com/casey/just) -- [hyperfine](https://github.com/sharkdp/hyperfine) -- [python](https://python.org) -- [node](https://nodejs.org) -- [rust](https://rust-lang.org) (recommend using [rustup](https://github.com/rust-lang/rustup)) -- [go](https://go.dev) -- [clang](https://clang.llvm.org) -- [GCC](https://gcc.gnu.org) -- [yasm](https://yasm.tortall.net) -- [texlive](https://tug.org/texlive) - -You can check other dev tools I use and more over [here](https://github.com/developomp/pompup). +- Install the following: + - [devenv](https://devenv.sh/getting-started) + - [direnv](https://devenv.sh/automatic-shell-activation) ## Usage -Simply call just recipes using the `just` command runner CLI. - -Examples: +Run [just](https://github.com/casey/just) recipes: ```bash just run-go # automatically build go code before running it and pass arguments from input.txt diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..2305638 --- /dev/null +++ b/devenv.lock @@ -0,0 +1,116 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1728740426, + "owner": "cachix", + "repo": "devenv", + "rev": "ef61728d91ad5eb91f86cdbcc16070602e7afa16", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1728538411, + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1728627514, + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c505ebf777526041d792a49d5f6dd4095ea391a7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1728778939, + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "ff68f91754be6f3427e4986d7949e6273659be1d", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..3271569 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,75 @@ +{ pkgs, ... }: + +{ + packages = with pkgs; [ + just + hyperfine + + ruff + yasm + nixfmt-rfc-style + ]; + + # https://github.com/cachix/devenv/blob/main/src/modules/languages/c.nix + # https://devenv.sh/supported-languages/c + languages.c.enable = true; + + # https://github.com/cachix/devenv/blob/main/src/modules/languages/cplusplus.nix + # https://devenv.sh/supported-languages/cplusplus + languages.cplusplus.enable = true; + + # https://github.com/cachix/devenv/blob/main/src/modules/languages/go.nix + # https://devenv.sh/supported-languages/go + languages.go.enable = true; + + # https://github.com/cachix/devenv/blob/main/src/modules/languages/javascript.nix + # https://devenv.sh/supported-languages/javascript + languages.javascript = { + enable = true; + directory = "./js"; + + pnpm.enable = true; + bun.enable = true; + }; + + # https://devenv.sh/supported-languages/typescript + + # https://github.com/cachix/devenv/blob/main/src/modules/languages/nix.nix + # https://devenv.sh/supported-languages/nix + languages.nix = { + enable = true; + lsp.package = pkgs.nixd; + }; + + # https://github.com/cachix/devenv/blob/main/src/modules/languages/php.nix + # https://devenv.sh/supported-languages/php + languages.php.enable = true; + + # https://github.com/cachix/devenv/blob/main/src/modules/languages/python.nix + # https://devenv.sh/supported-languages/python + languages.python = { + enable = true; + directory = "./py"; + + venv.enable = true; + }; + + # https://github.com/cachix/devenv/blob/main/src/modules/languages/rust.nix + # https://devenv.sh/supported-languages/rust + languages.rust.enable = true; + + # https://github.com/cachix/devenv/blob/main/src/modules/languages/texlive.nix + # https://devenv.sh/supported-languages/texlive + languages.texlive = { + enable = true; + + # texlive is broken rn + # https://github.com/cachix/devenv/issues/1521 + # https://github.com/Glavin001/atom-beautify/issues/1792#issuecomment-327071117 + # base = pkgs.texliveFull; + }; + + # https://github.com/cachix/devenv/blob/main/src/modules/languages/zig.nix + # https://devenv.sh/supported-languages/zig + languages.zig.enable = true; +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..397b9cb --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,7 @@ +# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json + +inputs: + nixpkgs: + url: github:nixos/nixpkgs/nixpkgs-unstable + +allowUnfree: true