A structured-data shell in Gleam, inspired by Nushell
0

Configure Feed

Select the types of activity you want to include in your feed.

gleshell / flake.nix
2.6 kB 90 lines
1{ 2 description = "gleshell structured-data shell in Gleam, inspired by Nushell"; 3 4 inputs = { 5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 6 systems.url = "github:nix-systems/default"; 7 devenv.url = "github:cachix/devenv"; 8 devenv.inputs.nixpkgs.follows = "nixpkgs"; 9 }; 10 11 nixConfig = { 12 extra-substituters = [ "https://devenv.cachix.org" ]; 13 extra-trusted-public-keys = [ 14 "devenv.cachix.org-1:ppRjvZf4JrQqfA3n7eHkSxX4z1M0RKZ77N8D66zCFAI=" 15 ]; 16 }; 17 18 outputs = 19 { 20 self, 21 nixpkgs, 22 devenv, 23 systems, 24 ... 25 }@inputs: 26 let 27 forEachSystem = nixpkgs.lib.genAttrs (import systems); 28 in 29 { 30 packages = forEachSystem ( 31 system: 32 let 33 pkgs = nixpkgs.legacyPackages.${system}; 34 runtimeInputs = [ 35 pkgs.gleam 36 pkgs.beamPackages.erlang 37 pkgs.rebar3 38 ]; 39 # Thin wrapper: needs the gleshell source tree (cwd or GLESHELL_ROOT). 40 gleshell = pkgs.writeShellApplication { 41 name = "gleshell"; 42 inherit runtimeInputs; 43 text = '' 44 root="''${GLESHELL_ROOT:-}" 45 if [ -z "$root" ]; then 46 if [ -f gleam.toml ] && grep -q 'name = "gleshell"' gleam.toml 2>/dev/null; then 47 root="$PWD" 48 else 49 echo "gleshell: run from the gleshell repo root, or set GLESHELL_ROOT" >&2 50 exit 1 51 fi 52 fi 53 cd "$root" 54 # +Bc: Ctrl+C cancels the line; do not open the Erlang BREAK/abort menu. 55 export ERL_AFLAGS="+Bc ''${ERL_AFLAGS:-}" 56 exec gleam run -- "$@" 57 ''; 58 }; 59 in 60 { 61 default = gleshell; 62 inherit gleshell; 63 } 64 ); 65 66 apps = forEachSystem (system: { 67 default = { 68 type = "app"; 69 program = "${self.packages.${system}.gleshell}/bin/gleshell"; 70 }; 71 }); 72 73 devShells = forEachSystem ( 74 system: 75 let 76 pkgs = nixpkgs.legacyPackages.${system}; 77 in 78 { 79 # --no-pure-eval (or direnv) is required so devenv can resolve 80 # devenv.root from $PWD; pure eval would point ./. at the store. 81 default = devenv.lib.mkShell { 82 inherit inputs pkgs; 83 modules = [ ./devenv.nix ]; 84 }; 85 } 86 ); 87 88 formatter = forEachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style); 89 }; 90}