Merge pull request #81 from adisbladis/null-modules

Allow passing `null` as modules for packages that don't have dependencies or that vendor them
This commit is contained in:
adisbladis 2022-08-24 19:04:02 +12:00 committed by GitHub
commit 3b14c28de9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 3 deletions

View file

@ -221,7 +221,7 @@ let
, ...
}@attrs:
let
modulesStruct = fromTOML (readFile modules);
modulesStruct = if modules == null then { } else fromTOML (readFile modules);
goModPath = "${toString pwd}/go.mod";
@ -268,10 +268,13 @@ let
export GOSUMDB=off
export GOPROXY=off
cd "$modRoot"
if [ -n "${vendorEnv}" ]; then
${optionalString (modulesStruct != { }) ''
if [ -n "${vendorEnv}" ]; then
rm -rf vendor
cp -r ${vendorEnv} vendor
fi
fi
''}
runHook postConfigure
'';

View file

@ -0,0 +1,28 @@
{ runCommand, buildGoApplication, fetchFromGitHub }:
let
version = "0.23.1";
in
buildGoApplication {
pname = "dstask";
inherit version;
src = fetchFromGitHub {
owner = "naggie";
repo = "dstask";
rev = "v${version}";
sha256 = "0rfz8jim0xqcwdb5n28942v9r3hbvhjrwdgzvbwc9f9psqg2s8d2";
};
modules = null;
ldflags = [
"-w"
"-s"
"-X github.com/naggie/dstask.VERSION=${version}"
"-X github.com/naggie/dstask.GIT_COMMIT=v${version}"
];
subPackages = [ "cmd/dstask.go" ];
}

2
tests/vendored-modules/script Executable file
View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
# No-op