Skip to content

Commit

Permalink
Merge pull request #18 from Warashi/fix/build-with-nix
Browse files Browse the repository at this point in the history
fix: build with nix
  • Loading branch information
Warashi authored Jun 8, 2024
2 parents d7f5eb5 + 0b349d9 commit 0f4aae0
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@
go.work


### nix
/result
20 changes: 12 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
go
buf
];
};
});
in
with pkgs; {
packages.default = (callPackage ./package.nix {});

devShell = mkShell {
GOTOOLCHAIN = "local";
nativeBuildInputs = [
go
buf
];
};
});
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Warashi/muscat/v2

go 1.22.4
go 1.22.3

require (
connectrpc.com/connect v1.11.1
Expand Down
52 changes: 52 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
stdenv,
lib,
darwin,
xorg,
makeWrapper,
buildGoModule,
useGolangDesign ? false,
...
}:
buildGoModule {
pname = "muscat";
version = "2.2.1";
vendorHash = "sha256-NyXFyuHYoRP6pXz5cmA99IzMawduPhlBs/m4BVC2h6A=";

src = ./.;

tags =
if useGolangDesign
then ["golangdesign"]
else [];

buildInputs =
if stdenv.isDarwin
then [
darwin.apple_sdk.frameworks.Cocoa
]
else if useGolangDesign
then [
xorg.libX11
]
else [];

nativeBuildInputs =
if (stdenv.isLinux && useGolangDesign)
then [makeWrapper]
else [];

postFixup =
if (stdenv.isLinux && useGolangDesign)
then ''
wrapProgram $out/bin/muscat \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [xorg.libX11]}
''
else "";

meta = with lib; {
description = "remote code development utils";
homepage = "https://github.com/Warashi/muscat";
license = licenses.mit;
};
}

0 comments on commit 0f4aae0

Please sign in to comment.