default.nix

nix tooling
This commit is contained in:
raf 2023-12-01 21:51:47 +03:00
parent 658048a173
commit 475f8d0c3c
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
4 changed files with 87 additions and 0 deletions

23
default.nix Normal file
View file

@ -0,0 +1,23 @@
{
buildGoModule,
lib,
...
}: let
pname = "echo";
version = "0.1.0";
in
buildGoModule {
inherit pname version;
src = builtins.filterSource (path: type: type != "directory" || baseNameOf path != ".git" || lib.hasSuffix ".nix" path) ./.;
vendorHash = null;
ldflags = ["-s" "-w" "-X main.version=${version}"];
meta = {
description = "Simple & lighweight mock server on localhost for testing.";
homepage = "https://github.com/notAShelf/echo";
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [NotAShelf];
mainProgram = pname;
};
}

26
flake.lock Normal file
View file

@ -0,0 +1,26 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1701454111,
"narHash": "sha256-G0Fvu9rBmeEozsFxLLIJKx/KG+/+MNW9Rq5y3V/BBqs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c1f0be03736e6d5ab4d19e867e6684686203eee8",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

23
flake.nix Normal file
View file

@ -0,0 +1,23 @@
{
description = "Simple & lighweight mock server on localhost for testing. ";
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 {
packages = forEachSystem (system: {
echo = pkgsForEach.${system}.callPackage ./default.nix {};
default = self.packages.${system}.echo;
});
devShells = forEachSystem (system: {
default = pkgsForEach.${system}.callPackage ./shell.nix {};
});
};
}

15
shell.nix Normal file
View file

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