default.nix: add option for static build

This commit is contained in:
Michele Guerini Rocco 2024-07-25 17:32:35 +02:00
parent eeeaa00de6
commit 47f4f46e65
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450

View File

@ -1,13 +1,16 @@
{ static ? false # whether to build fully static binaries
}:
let
nixpkgs = builtins.fetchTarball
nixpkgs = import (builtins.fetchTarball
{ url = "https://github.com/NixOS/nixpkgs/archive/f12ee5f64c6a.tar.gz";
sha256 = "14afxk35w3kbqimxcp39ngv9cqpc24glss1727ymk4napfg5v7hm";
};
}) { };
pkgs = import <nixpkgs> { };
pkgs = if static then nixpkgs.pkgsStatic else nixpkgs;
magnetico = { lib, buildGoModule, nixosTests, sqlite }:
magnetico = { lib, stdenv, buildGoModule, nixosTests, sqlite }:
buildGoModule {
pname = "magnetico";
version = "0.12.1";
@ -21,6 +24,8 @@ let
tags = [ "fts5" "libsqlite3" ];
ldflags = [ "-s" "-w" ];
doCheck = !stdenv.hostPlatform.isStatic;
passthru.tests = { inherit (nixosTests) magnetico; };
meta = with lib; {