69 lines
1.6 KiB
Nix
69 lines
1.6 KiB
Nix
{
|
|
description = "Example go flake";
|
|
|
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
outputs =
|
|
{ self, nixpkgs }:
|
|
let
|
|
allSystems = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
"x86_64-darwin"
|
|
"aarch64-darwin"
|
|
];
|
|
forAllSystems =
|
|
f:
|
|
nixpkgs.lib.genAttrs allSystems (
|
|
system:
|
|
f {
|
|
pkgs = import nixpkgs { inherit system; };
|
|
}
|
|
);
|
|
# Gets version from first line containg Version in main.go
|
|
version = nixpkgs.lib.strings.removePrefix "v" (
|
|
builtins.elemAt (nixpkgs.lib.strings.split "\"" (
|
|
nixpkgs.lib.lists.findFirst (x: nixpkgs.lib.strings.hasInfix "Version" x) null (
|
|
nixpkgs.lib.strings.splitString "\n" (builtins.readFile ./main.go)
|
|
)
|
|
)) 2
|
|
);
|
|
in
|
|
{
|
|
overlays.default = final: prev: {
|
|
ghettoptt = self.packages.${prev.system}.default;
|
|
};
|
|
|
|
packages = forAllSystems (
|
|
{ pkgs }:
|
|
{
|
|
default =
|
|
let
|
|
src = pkgs.lib.sourceFilesBySuffices ./. [
|
|
"go.mod"
|
|
"go.sum"
|
|
".go"
|
|
];
|
|
in
|
|
pkgs.buildGoModule {
|
|
inherit version;
|
|
pname = "example-go";
|
|
src = src;
|
|
vendorHash = null;
|
|
};
|
|
}
|
|
);
|
|
devShells = forAllSystems (
|
|
{ pkgs }:
|
|
{
|
|
default = pkgs.mkShell {
|
|
buildInputs = with pkgs; [
|
|
go
|
|
golangci-lint
|
|
];
|
|
};
|
|
}
|
|
);
|
|
};
|
|
}
|