diff --git a/default.nix b/default.nix index 4e2d9e2..3a26bca 100644 --- a/default.nix +++ b/default.nix @@ -1,21 +1,35 @@ -{ lib, rustPlatform, pkg-config, openssl, rust }: +{ + lib, + rustPlatform, + pkg-config, + openssl, + vscode-utils, +}: rec { + default = goboscript; + goboscript = rustPlatform.buildRustPackage { + pname = "goboscript"; + version = "3.3.0"; -rustPlatform.buildRustPackage { - pname = "goboscript"; - version = "3.3.0"; + src = ./.; - src = ./.; + cargoLock.lockFile = ./Cargo.lock; - cargoLock = { - lockFile = ./Cargo.lock; - }; - - nativeBuildInputs = [ pkg-config rust ]; - buildInputs = [ openssl ]; + nativeBuildInputs = [pkg-config]; + buildInputs = [openssl]; - meta = { - description = "goboscript is the Scratch compiler"; - homepage = "https://github.com/aspizu/goboscript"; - license = lib.licenses.mit; + meta = { + description = "goboscript is the Scratch compiler"; + homepage = "https://github.com/aspizu/goboscript"; + license = lib.licenses.mit; + }; + }; + # Just fetch the existing builds which are sent to the VS Marketplace + goboscript-vscode = vscode-utils.buildVscodeMarketplaceExtension { + mktplcRef = { + name = "goboscript"; + publisher = "aspizu"; + version = "1.0.3"; + hash = "sha256-myVGhoighWMktD78qHTTs/t0dU0S68xX0aWbWiFEtqs="; + }; }; } diff --git a/docs/editor-integration/vscode.md b/docs/editor-integration/vscode.md index 234407c..d4fb99c 100644 --- a/docs/editor-integration/vscode.md +++ b/docs/editor-integration/vscode.md @@ -28,3 +28,22 @@ updated `.sb3` file. The preview does not reload automatically. The preview's **Console** shows messages from [`log`, `warn`, and `error`](../language/blocks/debugger.md), along with the sprite or clone that sent them. Messages can be filtered by level. + +## Install on nix + +To install with nix, add the goboscript flake to your flake inputs. +You can then use `inputs.goboscript.packages.${system}.goboscript-vscode` +(`${system}` is a string like `x86_64-linux` or `aarch64-darwin`) to access the +packaged VSCode extension. You can then use this package much like any other +VSCode package which you would find in nixpkgs: e.g. for use with `home-manager`: + +```nix +programs.vscode = { + enable = true; + profiles.default = { + extensions = [ + inputs.goboscript.packages.${pkgs.stdenv.hostPlatform.system}.goboscript-vscode + ]; + }; +}; +``` diff --git a/docs/install.md b/docs/install.md index f4eb109..d19f621 100644 --- a/docs/install.md +++ b/docs/install.md @@ -39,25 +39,23 @@ cargo install --git https://github.com/aspizu/goboscript --locked --force The nix flake installs goboscript from source, like the other methods, so you will need to be patient. -### devShell + You can also [install the goboscript VSCode extension with nix](./editor-integration/vscode.md). -You can test goboscript without installing it to your system with the nix devshell, a bit like `nix-shell -p {some package}`. -This will create a subshell where `goboscript` is installed. -Once you exit this subshell, you will no longer be able to use the `goboscript` command -(until you open a new devShell or install it system-wide). -Once you run `nix-collect-garbage`, the `goboscript` installation files will actually be removed from your system. +### devShell -Simply run the command `nix develop github:aspizu/goboscript` +The demo devshell can be accessed with `nix develop github:aspizu/goboscript#demo` ### Nixos standalone installation (flake) -This is for if you want to have `goboscript` available system-wide. -For nix flakes, add the input `goboscript` and add it to `environment.systemPackages` in your flake, roughly like so: +To install the goboscript *compiler*, you can add `goboscript.packages.${pkgs.stdenv.hostPlatform.system}.goboscript` to your system packages list. +For nix flakes, add the input `goboscript` and add it to `environment.systemPackages` in your flake like so: + +[This repository](https://codeberg.org/rtk/dotfiles) is an example usage of the goboscript flake. ```nix { inputs = { - nixpkgs.url = "github:nixos/nixpkgs?ref=25.11"; + nixpkgs.url = "github:nixos/nixpkgs?ref=26.05"; goboscript.url = "github:aspizu/goboscript"; }; outputs = { self, nixpkgs, goboscript, ... }: { @@ -65,9 +63,10 @@ For nix flakes, add the input `goboscript` and add it to `environment.systemPack modules = [ ({ pkgs, ... }: { environment.systemPackages = [ - goboscript.packages.${pkgs.stdenv.hostPlatform.system}.goboscript + goboscript.packages.${pkgs.stdenv.hostPlatform.system}.goboscript # this is the important line ]; }) + # The rest of your nixos configuration... ]; }; }; diff --git a/flake.lock b/flake.lock index f22118b..04210c1 100644 --- a/flake.lock +++ b/flake.lock @@ -1,30 +1,12 @@ { "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1741513245, - "narHash": "sha256-7rTAMNTY1xoBwz0h7ZMtEcd8LELk9R5TzBPoHuhNSCk=", + "lastModified": 1790822859, + "narHash": "sha256-69xHQhAeMAD2wDXO7T2pcOZIF9Sga2W+JkmY2a11Ops=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e3e32b642a31e6714ec1b712de8c91a3352ce7e1", + "rev": "c59305bab2065cfecc4944690d9eedbb56f3a9fa", "type": "github" }, "original": { @@ -34,60 +16,9 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1744536153, - "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" - } - }, - "rust-overlay": { - "inputs": { - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "lastModified": 1773975983, - "narHash": "sha256-zrRVwdfhDdohANqEhzY/ydeza6EXEi8AG6cyMRNYT9Q=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "cc80954a95f6f356c303ed9f08d0b63ca86216ac", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 4d6b67f..57b7f3b 100644 --- a/flake.nix +++ b/flake.nix @@ -3,31 +3,34 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - rust-overlay.url = "github:oxalica/rust-overlay"; }; - outputs = inputs@{ self, nixpkgs, flake-utils, rust-overlay, ... }: - flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-darwin" ] (system: let - overlays = [ (import rust-overlay) ]; - pkgs = import nixpkgs { - inherit system overlays; - }; - rust = pkgs.rust-bin.stable.latest.default; - in rec { - packages.goboscript = pkgs.callPackage ./default.nix { - inherit (pkgs) pkg-config openssl; - inherit rust; - }; - - legacyPackages = packages; - - defaultPackage = packages.goboscript; - - devShell = pkgs.mkShell { - buildInputs = with pkgs; [ git openssl pkg-config ]; - packages = [ packages.goboscript ]; - nativeBuildInputs = [ rust ]; - }; - }); + outputs = { + self, + nixpkgs, + ... + }: let + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system (pkgsFor system)); + pkgsFor = system: nixpkgs.legacyPackages.${system}; + in { + packages = forAllSystems (_: pkgs: pkgs.callPackage ./default.nix {}); + devShells = forAllSystems (system: pkgs: { + default = pkgs.mkShell { + buildInputs = with pkgs; [git cargo rustc]; + inputsFrom = [self.packages.${system}.goboscript]; + }; + demo = pkgs.mkShell { + packages = [self.packages.${system}.goboscript]; + shellHook = '' + goboscript --help + ''; + }; + }); + }; }