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 ,
32 }:
33 let
34 supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
35 forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
36 nixpkgsFor = forAllSystems (system:
37 import nixpkgs {
38 inherit system;
39 overlays = [ self.overlays.default ];
40 });
41 inherit (gitignore.lib) gitignoreSource;
42 in
43 {
44 overlays.default = final: prev: {
45 indigo-lexgen = with final;
46 final.buildGoModule {
47 pname = "indigo-lexgen";
48 version = "0.1.0";
49 src = indigo;
50 subPackages = [ "cmd/lexgen" ];
51 vendorHash = "sha256-pGc29fgJFq8LP7n/pY1cv6ExZl88PAeFqIbFEhB3xXs=";
52 doCheck = false;
53 };
54
55 appview = with final;
56 final.pkgsStatic.buildGoModule {
57 pname = "appview";
58 version = "0.1.0";
59 src = gitignoreSource ./.;
60 postConfigureHook = ''
61 cp -f ${htmx-src} appview/pages/static/htmx.min.js
62 cp -f ${lucide-src} appview/pages/static/lucide.min.js
63 ${pkgs.tailwindcss}/bin/tailwindcss -i input.css -o appview/pages/static/tw.css
64 '';
65 subPackages = [ "cmd/appview" ];
66 vendorHash = "sha256-t7lWrCyFWCI7zjUcC6XNWzCrUPSCFnFu9gTmRTsYrz0=";
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:
104 let
105 pkgs = nixpkgsFor.${system};
106 staticShell = pkgs.mkShell.override {
107 stdenv = pkgs.pkgsStatic.stdenv;
108 };
109 in
110 {
111 default = staticShell {
112 nativeBuildInputs = [
113 pkgs.go
114 pkgs.air
115 pkgs.gopls
116 pkgs.httpie
117 pkgs.indigo-lexgen
118 pkgs.litecli
119 pkgs.websocat
120 pkgs.tailwindcss
121 ];
122 };
123 });
124 apps = forAllSystems (system:
125 let
126 pkgs = nixpkgsFor."${system}";
127 air-watcher = name:
128 pkgs.writeShellScriptBin "run"
129 ''
130 ${pkgs.air}/bin/air -c /dev/null \
131 -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" \
132 -build.bin "./out/${name}.out" \
133 -build.include_ext "go,html,css"
134 '';
135 in
136 {
137 watch-appview = {
138 type = "app";
139 program = ''${air-watcher "appview"}/bin/run'';
140 };
141 watch-knotserver = {
142 type = "app";
143 program = ''${air-watcher "knotserver"}/bin/run'';
144 };
145 });
146 };
147}