mirror of
https://github.com/tweag/gomod2nix.git
synced 2024-11-05 01:59:08 +00:00
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:
commit
3b14c28de9
3 changed files with 36 additions and 3 deletions
|
@ -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
|
||||
'';
|
||||
|
|
28
tests/vendored-modules/default.nix
Normal file
28
tests/vendored-modules/default.nix
Normal 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
2
tests/vendored-modules/script
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env bash
|
||||
# No-op
|
Loading…
Reference in a new issue