Gleam CLI client for Tangled (clone of aly.codes/tg)
0

Configure Feed

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

gtg / flake.nix
2.7 kB 96 lines
1{ 2 description = "gtg Gleam CLI client for Tangled (git forge on atproto)"; 3 4 inputs = { 5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 6 }; 7 8 outputs = 9 { self, nixpkgs }: 10 let 11 systems = [ 12 "x86_64-linux" 13 "aarch64-linux" 14 "x86_64-darwin" 15 "aarch64-darwin" 16 ]; 17 forAllSystems = nixpkgs.lib.genAttrs systems; 18 in 19 { 20 # nix develop 21 devShells = forAllSystems ( 22 system: 23 let 24 pkgs = nixpkgs.legacyPackages.${system}; 25 in 26 { 27 default = pkgs.mkShell { 28 name = "gtg"; 29 30 packages = [ 31 pkgs.gleam 32 pkgs.beamPackages.erlang 33 pkgs.rebar3 34 pkgs.beamPackages.hex 35 pkgs.git 36 ]; 37 38 shellHook = '' 39 echo "gtg dev shell" 40 echo " gleam $(gleam --version 2>/dev/null || echo '?')" 41 echo " erl OTP $(erl -eval 'io:format("~s", [erlang:system_info(otp_release)]), halt().' -noshell 2>/dev/null || echo '?')" 42 echo "" 43 echo " gleam run -- --help" 44 echo " gleam run -- auth login <handle>" 45 echo " gleam test" 46 ''; 47 }; 48 } 49 ); 50 51 # nix run . -- --help 52 # Copies sources to a writable temp dir (store paths are read-only; gleam 53 # needs to write build/ and download hex packages). 54 apps = forAllSystems ( 55 system: 56 let 57 pkgs = nixpkgs.legacyPackages.${system}; 58 gtg = pkgs.writeShellApplication { 59 name = "gtg"; 60 runtimeInputs = [ 61 pkgs.gleam 62 pkgs.beamPackages.erlang 63 pkgs.rebar3 64 pkgs.beamPackages.hex 65 pkgs.rsync 66 pkgs.coreutils 67 ]; 68 text = '' 69 root="${self}" 70 if [[ ! -f "$root/gleam.toml" ]]; then 71 echo "gtg: flake source not found at $root" >&2 72 exit 1 73 fi 74 work=$(mktemp -d) 75 trap 'rm -rf "$work"' EXIT 76 # Nix store files are mode 444; gleam must write build/ here. 77 rsync -a --chmod=u+w --exclude build --exclude result \ 78 --exclude .direnv --exclude .git \ 79 "$root"/ "$work"/ 80 chmod -R u+w "$work" 81 cd "$work" 82 exec gleam run --no-print-progress -- "$@" 83 ''; 84 }; 85 in 86 { 87 default = { 88 type = "app"; 89 program = "${gtg}/bin/gtg"; 90 }; 91 } 92 ); 93 94 formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style); 95 }; 96}