| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- {
- description = "templ";
- inputs = {
- nixpkgs.url = "github:NixOS/nixpkgs/release-24.05";
- gomod2nix = {
- url = "github:nix-community/gomod2nix";
- inputs.nixpkgs.follows = "nixpkgs";
- };
- gitignore = {
- url = "github:hercules-ci/gitignore.nix";
- inputs.nixpkgs.follows = "nixpkgs";
- };
- xc = {
- url = "github:joerdav/xc";
- inputs.nixpkgs.follows = "nixpkgs";
- };
- };
- outputs = { self, nixpkgs, gomod2nix, gitignore, xc }:
- let
- allSystems = [
- "x86_64-linux" # 64-bit Intel/AMD Linux
- "aarch64-linux" # 64-bit ARM Linux
- "x86_64-darwin" # 64-bit Intel macOS
- "aarch64-darwin" # 64-bit ARM macOS
- ];
- forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
- inherit system;
- pkgs = import nixpkgs { inherit system; };
- });
- in
- {
- packages = forAllSystems ({ system, pkgs, ... }:
- let
- buildGoApplication = gomod2nix.legacyPackages.${system}.buildGoApplication;
- in
- rec {
- default = templ;
- templ = buildGoApplication {
- name = "templ";
- src = gitignore.lib.gitignoreSource ./.;
- # Update to latest Go version when https://nixpk.gs/pr-tracker.html?pr=324123 is backported to release-24.05.
- go = pkgs.go;
- # Must be added due to bug https://github.com/nix-community/gomod2nix/issues/120
- pwd = ./.;
- subPackages = [ "cmd/templ" ];
- CGO_ENABLED = 0;
- flags = [
- "-trimpath"
- ];
- ldflags = [
- "-s"
- "-w"
- "-extldflags -static"
- ];
- };
- });
- # `nix develop` provides a shell containing development tools.
- devShell = forAllSystems ({ system, pkgs }:
- pkgs.mkShell {
- buildInputs = with pkgs; [
- golangci-lint
- cosign # Used to sign container images.
- esbuild # Used to package JS examples.
- go_1_22
- gomod2nix.legacyPackages.${system}.gomod2nix
- gopls
- goreleaser
- gotestsum
- ko # Used to build Docker images.
- nodejs # Used to build templ-docs.
- xc.packages.${system}.xc
- ];
- });
- # This flake outputs an overlay that can be used to add templ and
- # templ-docs to nixpkgs as per https://templ.guide/quick-start/installation/#nix
- #
- # Example usage:
- #
- # nixpkgs.overlays = [
- # inputs.templ.overlays.default
- # ];
- overlays.default = final: prev: {
- templ = self.packages.${final.stdenv.system}.templ;
- templ-docs = self.packages.${final.stdenv.system}.templ-docs;
- };
- };
- }
|