forked from tangled.org/core
Monorepo for Tangled — https://tangled.org
1{ 2 description = "atproto github"; 3 4 inputs = { 5 nixpkgs.url = "github:nixos/nixpkgs"; 6 indigo = { 7 url = "github:oppiliappan/indigo"; 8 flake = false; 9 }; 10 htmx-src = { 11 url = "https://unpkg.com/htmx.org@2.0.4/dist/htmx.min.js"; 12 flake = false; 13 }; 14 lucide-src = { 15 url = "https://unpkg.com/lucide@latest"; 16 flake = false; 17 }; 18 gitignore = { 19 url = "github:hercules-ci/gitignore.nix"; 20 inputs.nixpkgs.follows = "nixpkgs"; 21 }; 22 }; 23 24 outputs = { 25 self, 26 nixpkgs, 27 indigo, 28 htmx-src, 29 lucide-src, 30 gitignore, 31 }: let 32 supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; 33 forAllSystems = nixpkgs.lib.genAttrs supportedSystems; 34 nixpkgsFor = forAllSystems (system: 35 import nixpkgs { 36 inherit system; 37 overlays = [self.overlays.default]; 38 }); 39 inherit (gitignore.lib) gitignoreSource; 40 in { 41 overlays.default = final: prev: { 42 indigo-lexgen = with final; 43 final.buildGoModule { 44 pname = "indigo-lexgen"; 45 version = "0.1.0"; 46 src = indigo; 47 subPackages = ["cmd/lexgen"]; 48 vendorHash = "sha256-pGc29fgJFq8LP7n/pY1cv6ExZl88PAeFqIbFEhB3xXs="; 49 doCheck = false; 50 }; 51 52 appview = with final; 53 final.pkgsStatic.buildGoModule { 54 pname = "appview"; 55 version = "0.1.0"; 56 src = gitignoreSource ./.; 57 postUnpack = '' 58 pushd source 59 cp -f ${htmx-src} appview/pages/static/htmx.min.js 60 cp -f ${lucide-src} appview/pages/static/lucide.min.js 61 ${pkgs.tailwindcss}/bin/tailwindcss -i input.css -o appview/pages/static/tw.css 62 popd 63 ''; 64 doCheck = false; 65 subPackages = ["cmd/appview"]; 66 vendorHash = "sha256-u9LwvapAwyVOIOAag0IRrk+ot6B0PaqyEnt0EeJciGQ="; 67 env.CGO_ENABLED = 1; 68 stdenv = pkgsStatic.stdenv; 69 }; 70 knotserver = with final; 71 final.pkgsStatic.buildGoModule { 72 pname = "knotserver"; 73 version = "0.1.0"; 74 src = gitignoreSource ./.; 75 subPackages = ["cmd/knotserver"]; 76 vendorHash = "sha256-t7lWrCyFWCI7zjUcC6XNWzCrUPSCFnFu9gTmRTsYrz0="; 77 env.CGO_ENABLED = 1; 78 }; 79 repoguard = with final; 80 final.pkgsStatic.buildGoModule { 81 pname = "repoguard"; 82 version = "0.1.0"; 83 src = gitignoreSource ./.; 84 subPackages = ["cmd/repoguard"]; 85 vendorHash = "sha256-t7lWrCyFWCI7zjUcC6XNWzCrUPSCFnFu9gTmRTsYrz0="; 86 env.CGO_ENABLED = 0; 87 }; 88 keyfetch = with final; 89 final.pkgsStatic.buildGoModule { 90 pname = "keyfetch"; 91 version = "0.1.0"; 92 src = gitignoreSource ./.; 93 subPackages = ["cmd/keyfetch"]; 94 vendorHash = "sha256-t7lWrCyFWCI7zjUcC6XNWzCrUPSCFnFu9gTmRTsYrz0="; 95 env.CGO_ENABLED = 0; 96 }; 97 }; 98 packages = forAllSystems (system: { 99 inherit (nixpkgsFor."${system}") indigo-lexgen appview knotserver repoguard keyfetch; 100 }); 101 defaultPackage = forAllSystems (system: nixpkgsFor.${system}.appview); 102 formatter = forAllSystems (system: nixpkgsFor."${system}".alejandra); 103 devShells = forAllSystems (system: let 104 pkgs = nixpkgsFor.${system}; 105 staticShell = pkgs.mkShell.override { 106 stdenv = pkgs.pkgsStatic.stdenv; 107 }; 108 in { 109 default = staticShell { 110 nativeBuildInputs = [ 111 pkgs.go 112 pkgs.air 113 pkgs.gopls 114 pkgs.httpie 115 pkgs.indigo-lexgen 116 pkgs.litecli 117 pkgs.websocat 118 pkgs.tailwindcss 119 ]; 120 }; 121 }); 122 apps = forAllSystems (system: let 123 pkgs = nixpkgsFor."${system}"; 124 air-watcher = name: 125 pkgs.writeShellScriptBin "run" 126 '' 127 ${pkgs.air}/bin/air -c /dev/null \ 128 -build.cmd "${pkgs.tailwindcss}/bin/tailwindcss -i input.css -o ./appview/pages/static/tw.css && ${pkgs.go}/bin/go build -o ./out/${name}.out ./cmd/${name}/main.go" \ 129 -build.bin "./out/${name}.out" \ 130 -build.include_ext "go,html,css" 131 ''; 132 in { 133 watch-appview = { 134 type = "app"; 135 program = ''${air-watcher "appview"}/bin/run''; 136 }; 137 watch-knotserver = { 138 type = "app"; 139 program = ''${air-watcher "knotserver"}/bin/run''; 140 }; 141 }); 142 }; 143}