Files
git-pages/flake.nix
2026-04-12 10:56:44 +00:00

90 lines
1.9 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
nix-filter.url = "github:numtide/nix-filter";
gomod2nix = {
url = "github:nix-community/gomod2nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
nix-filter,
...
}@inputs:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
inputs.gomod2nix.overlays.default
];
};
git-pages = pkgs.buildGoApplication {
pname = "git-pages";
version = "0";
src = nix-filter {
root = self;
include = [
"go.mod"
"go.sum"
"main.go"
(nix-filter.lib.inDirectory "src")
];
};
buildInputs = pkgs.lib.optionals pkgs.stdenv.targetPlatform.isLinux (
with pkgs;
[
pkgsStatic.musl
]
);
ldflags = [
"-linkmode external"
"-X main.versionOverride=${self.shortRev or self.dirtyShortRev}"
]
++ pkgs.lib.optionals pkgs.stdenv.targetPlatform.isLinux [
"-extldflags -static"
"-s -w"
];
go = pkgs.go_1_25;
modules = ./gomod2nix.toml;
};
in
{
formatter = pkgs.nixfmt-tree;
devShells.default = pkgs.mkShell {
inputsFrom = [
git-pages
];
packages = with pkgs; [
caddy
gomod2nix
];
};
packages = {
inherit git-pages;
default = git-pages;
};
}
);
}