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 ia-fonts-src = {
19 url = "github:iaolo/iA-Fonts";
20 flake = false;
21 };
22 gitignore = {
23 url = "github:hercules-ci/gitignore.nix";
24 inputs.nixpkgs.follows = "nixpkgs";
25 };
26 };
27
28 outputs = {
29 self,
30 nixpkgs,
31 indigo,
32 htmx-src,
33 lucide-src,
34 gitignore,
35 ia-fonts-src,
36 }: let
37 supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
38 forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
39 nixpkgsFor = forAllSystems (system:
40 import nixpkgs {
41 inherit system;
42 overlays = [self.overlays.default];
43 });
44 inherit (gitignore.lib) gitignoreSource;
45 in {
46 overlays.default = final: prev: {
47 indigo-lexgen = with final;
48 final.buildGoModule {
49 pname = "indigo-lexgen";
50 version = "0.1.0";
51 src = indigo;
52 subPackages = ["cmd/lexgen"];
53 vendorHash = "sha256-pGc29fgJFq8LP7n/pY1cv6ExZl88PAeFqIbFEhB3xXs=";
54 doCheck = false;
55 };
56
57 appview = with final;
58 final.pkgsStatic.buildGoModule {
59 pname = "appview";
60 version = "0.1.0";
61 src = gitignoreSource ./.;
62 postUnpack = ''
63 pushd source
64 cp -f ${htmx-src} appview/pages/static/htmx.min.js
65 cp -f ${lucide-src} appview/pages/static/lucide.min.js
66 ${pkgs.tailwindcss}/bin/tailwindcss -i input.css -o appview/pages/static/tw.css
67 popd
68 '';
69 doCheck = false;
70 subPackages = ["cmd/appview"];
71 vendorHash = "sha256-ywhhGrv8KNqy9tCMCnA1PU/RQ/+0Xyitej1L48TcFvI=";
72 env.CGO_ENABLED = 1;
73 stdenv = pkgsStatic.stdenv;
74 };
75 knotserver = with final;
76 final.pkgsStatic.buildGoModule {
77 pname = "knotserver";
78 version = "0.1.0";
79 src = gitignoreSource ./.;
80 subPackages = ["cmd/knotserver"];
81 vendorHash = "sha256-ywhhGrv8KNqy9tCMCnA1PU/RQ/+0Xyitej1L48TcFvI=";
82 env.CGO_ENABLED = 1;
83 };
84 repoguard = with final;
85 final.pkgsStatic.buildGoModule {
86 pname = "repoguard";
87 version = "0.1.0";
88 src = gitignoreSource ./.;
89 subPackages = ["cmd/repoguard"];
90 vendorHash = "sha256-ywhhGrv8KNqy9tCMCnA1PU/RQ/+0Xyitej1L48TcFvI=";
91 env.CGO_ENABLED = 0;
92 };
93 keyfetch = with final;
94 final.pkgsStatic.buildGoModule {
95 pname = "keyfetch";
96 version = "0.1.0";
97 src = gitignoreSource ./.;
98 subPackages = ["cmd/keyfetch"];
99 vendorHash = "sha256-ywhhGrv8KNqy9tCMCnA1PU/RQ/+0Xyitej1L48TcFvI=";
100 env.CGO_ENABLED = 0;
101 };
102 };
103 packages = forAllSystems (system: {
104 inherit (nixpkgsFor."${system}") indigo-lexgen appview knotserver repoguard keyfetch;
105 });
106 defaultPackage = forAllSystems (system: nixpkgsFor.${system}.appview);
107 formatter = forAllSystems (system: nixpkgsFor."${system}".alejandra);
108 devShells = forAllSystems (system: let
109 pkgs = nixpkgsFor.${system};
110 staticShell = pkgs.mkShell.override {
111 stdenv = pkgs.pkgsStatic.stdenv;
112 };
113 in {
114 default = staticShell {
115 nativeBuildInputs = [
116 pkgs.go
117 pkgs.air
118 pkgs.gopls
119 pkgs.httpie
120 pkgs.indigo-lexgen
121 pkgs.litecli
122 pkgs.websocat
123 pkgs.tailwindcss
124 ];
125 shellHook = ''
126 cp -f ${htmx-src} appview/pages/static/htmx.min.js
127 cp -f ${lucide-src} appview/pages/static/lucide.min.js
128 cp -f ${ia-fonts-src}/"iA Writer Quattro"/Static/*.ttf appview/pages/static/fonts/
129 cp -f ${ia-fonts-src}/"iA Writer Mono"/Static/*.ttf appview/pages/static/fonts/
130 '';
131 };
132 });
133 apps = forAllSystems (system: let
134 pkgs = nixpkgsFor."${system}";
135 air-watcher = name:
136 pkgs.writeShellScriptBin "run"
137 ''
138 ${pkgs.air}/bin/air -c /dev/null \
139 -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" \
140 -build.bin "./out/${name}.out" \
141 -build.include_ext "go,html,css"
142 '';
143 in {
144 watch-appview = {
145 type = "app";
146 program = ''${air-watcher "appview"}/bin/run'';
147 };
148 watch-knotserver = {
149 type = "app";
150 program = ''${air-watcher "knotserver"}/bin/run'';
151 };
152 });
153 };
154}