nix: build directly with buildGoModules

Since we have no dependencies, we don't need a vendor hash, so doing this actually makes sense.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
Ophestra Umiker 2024-07-16 21:54:44 +09:00
parent 1f72c30033
commit 09507a541b
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
1 changed files with 42 additions and 22 deletions

View File

@ -5,32 +5,52 @@
nixpkgs.url = "github:NixOS/nixpkgs/24.05";
};
outputs = { self, nixpkgs }:
outputs =
{ self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
in
{
devShells = forAllSystems
(system:
let
pkgs = import nixpkgs {
inherit system;
devShells = forAllSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
default =
let
inherit (pkgs)
mkShell
buildGoModule
acl
xorg
;
in
mkShell {
packages = [
(buildGoModule rec {
pname = "ego";
version = "flake";
src = ./.;
vendorHash = null; # we have no dependencies :3
ldflags = [
"-s"
"-w"
"-X"
"main.Version=v${version}"
];
buildInputs = [
acl
xorg.libxcb
];
})
];
};
in
{
default = with pkgs; mkShell
{
packages = [
clang
acl
xorg.libxcb
(pkgs.writeShellScriptBin "build" ''
go build -v -ldflags '-s -w -X main.Version=flake'
'')
];
};
}
);
}
);
};
}
}