feat: nix tooling

This commit is contained in:
raf 2023-10-26 19:39:06 +03:00
parent 716b27da8f
commit 5203a18d2d
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
5 changed files with 79 additions and 1 deletions

2
.envrc
View file

@ -1 +1 @@
use flake use flake . --builders ""

View file

@ -0,0 +1,11 @@
{buildGoModule}:
buildGoModule {
pname = "sample-go";
version = "0.0.1";
src = ./.;
vendorHash = null;
ldflags = ["-s" "-w"];
}

26
flake.lock Normal file
View file

@ -0,0 +1,26 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1698331563,
"narHash": "sha256-arDwz/scx6iPEkxLV78hTL7U2M+BLH/zxgzPOLuyd6M=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "338a8633bc883122459c3f3daeb0a782d6e3bb56",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

View file

@ -0,0 +1,26 @@
{
description = "Golang Project Template";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
};
outputs = {
self,
nixpkgs,
}: let
systems = ["x86_64-linux" "aarch64-linux"];
forEachSystem = nixpkgs.lib.genAttrs systems;
pkgsForEach = nixpkgs.legacyPackages;
in rec {
packages = forEachSystem (system: {
default = pkgsForEach.${system}.callPackage ./default.nix {};
});
devShells = forEachSystem (system: {
default = pkgsForEach.${system}.callPackage ./shell.nix {};
});
hydraJobs = packages;
};
}

View file

@ -0,0 +1,15 @@
{
callPackage,
gopls,
go,
}: let
mainPkg = callPackage ./default.nix {};
in
mainPkg.overrideAttrs (oa: {
nativeBuildInputs =
[
gopls
go
]
++ (oa.nativeBuildInputs or []);
})