Skip to content

Commit

Permalink
Add packages.twenty-twenty-twenty-static to flake.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Jan 10, 2024
1 parent 1dd295f commit 98d72ff
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 31 deletions.
37 changes: 6 additions & 31 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,13 @@
let pkgs = nixpkgsFor.${system};
in {
default = self.packages.${system}.twenty-twenty-twenty;
twenty-twenty-twenty = pkgs.buildGoModule {
pname = "twenty-twenty-twenty";
twenty-twenty-twenty = pkgs.callPackage ./twenty-twenty-twenty.nix { inherit version; };
twenty-twenty-twenty-static = (pkgs.callPackage ./twenty-twenty-twenty.nix rec {
inherit version;
src = ./.;
vendorHash = "sha256-3RtdnS4J7JbdU+jMTEzClSlDDPh6bWqbjchvrtS8HUc";

nativeBuildInputs = with pkgs; lib.optionals stdenv.hostPlatform.isLinux [
pkg-config
];

buildInputs = with pkgs;
lib.optionals stdenv.hostPlatform.isLinux [
alsa-lib
] ++
lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk_11_0.frameworks.MetalKit
darwin.apple_sdk_11_0.frameworks.UserNotifications
];

# Tests are mostly useful for development, not to ensure that
# program is running correctly.
doCheck = false;

ldflags = [ "-X=main.version=${version}" ];

meta = with pkgs.lib; {
description = "Alerts every 20 minutes to look something at 20 feet away for 20 seconds";
homepage = "https://github.com/thiagokokada/twenty-twenty-twenty";
license = licenses.mit;
mainProgram = "twenty-twenty-twenty";
};
};
inherit (pkgs.pkgsStatic) alsa-lib stdenv;
buildGoModule = pkgs.buildGoModule.override { inherit stdenv; };
extraLdflags = [ "-linkmode external" ''-extldflags "-static"'' ];
});
});

devShells = forAllSystems (system:
Expand Down
41 changes: 41 additions & 0 deletions twenty-twenty-twenty.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{ lib
, stdenv
, alsa-lib
, buildGoModule
, darwin
, pkg-config
, extraLdflags ? [ ]
, version ? "unknown"
}:

buildGoModule {
pname = "twenty-twenty-twenty";
inherit version;
src = ./.;
vendorHash = "sha256-3RtdnS4J7JbdU+jMTEzClSlDDPh6bWqbjchvrtS8HUc";

nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [
pkg-config
];

buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
alsa-lib
] ++
lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk_11_0.frameworks.MetalKit
darwin.apple_sdk_11_0.frameworks.UserNotifications
];

# Tests are mostly useful for development, not to ensure that
# program is running correctly.
doCheck = false;

ldflags = [ "-X=main.version=${version}" ] ++ extraLdflags;

meta = with lib; {
description = "Alerts every 20 minutes to look something at 20 feet away for 20 seconds";
homepage = "https://github.com/thiagokokada/twenty-twenty-twenty";
license = licenses.mit;
mainProgram = "twenty-twenty-twenty";
};
}

0 comments on commit 98d72ff

Please sign in to comment.