[mirror] Scalable static site server for Git forges (like GitHub Pages)
at main 1.6 kB view raw
1{ 2 inputs = { 3 nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; 4 flake-utils.url = "github:numtide/flake-utils"; 5 nix-filter.url = "github:numtide/nix-filter"; 6 7 gomod2nix = { 8 url = "github:nix-community/gomod2nix"; 9 inputs.nixpkgs.follows = "nixpkgs"; 10 inputs.flake-utils.follows = "flake-utils"; 11 }; 12 }; 13 14 outputs = 15 { 16 self, 17 nixpkgs, 18 flake-utils, 19 nix-filter, 20 ... 21 }@inputs: 22 flake-utils.lib.eachDefaultSystem ( 23 system: 24 let 25 pkgs = import nixpkgs { 26 inherit system; 27 28 overlays = [ 29 inputs.gomod2nix.overlays.default 30 ]; 31 }; 32 33 git-pages = pkgs.buildGoApplication { 34 pname = "git-pages"; 35 version = "0"; 36 37 src = nix-filter { 38 root = self; 39 40 include = [ 41 "go.mod" 42 "go.sum" 43 "main.go" 44 45 (nix-filter.lib.inDirectory "src") 46 ]; 47 }; 48 49 buildInputs = with pkgs; [ 50 pkgsStatic.musl 51 ]; 52 53 ldflags = [ 54 "-linkmode external" 55 "-extldflags -static" 56 "-s -w" 57 ]; 58 59 go = pkgs.go_1_25; 60 modules = ./gomod2nix.toml; 61 }; 62 in 63 { 64 formatter = pkgs.nixfmt-tree; 65 66 devShells.default = pkgs.mkShell { 67 inputsFrom = [ 68 git-pages 69 ]; 70 71 packages = with pkgs; [ 72 caddy 73 gomod2nix 74 ]; 75 }; 76 77 packages = { 78 inherit git-pages; 79 default = git-pages; 80 }; 81 } 82 ); 83}