mirror of
https://github.com/tweag/gomod2nix.git
synced 2024-11-09 12:09:08 +00:00
Merge pull request #82 from adisbladis/passthru-updatescript
Add passthru.updateScript when package is fully auto generated
This commit is contained in:
commit
098fb7f906
1 changed files with 29 additions and 2 deletions
|
@ -8,6 +8,9 @@
|
||||||
, cacert
|
, cacert
|
||||||
, pkgs
|
, pkgs
|
||||||
, pkgsBuildBuild
|
, pkgsBuildBuild
|
||||||
|
, runtimeShell
|
||||||
|
, writeScript
|
||||||
|
, gomod2nix
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -238,13 +241,15 @@ let
|
||||||
inherit go modulesStruct defaultPackage goMod pwd;
|
inherit go modulesStruct defaultPackage goMod pwd;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pname = attrs.pname or baseNameOf defaultPackage;
|
||||||
|
|
||||||
in
|
in
|
||||||
warnIf (buildFlags != "" || buildFlagsArray != "")
|
warnIf (buildFlags != "" || buildFlagsArray != "")
|
||||||
"Use the `ldflags` and/or `tags` attributes instead of `buildFlags`/`buildFlagsArray`"
|
"Use the `ldflags` and/or `tags` attributes instead of `buildFlags`/`buildFlagsArray`"
|
||||||
stdenv.mkDerivation
|
stdenv.mkDerivation
|
||||||
(optionalAttrs (defaultPackage != "")
|
(optionalAttrs (defaultPackage != "")
|
||||||
{
|
{
|
||||||
pname = attrs.pname or baseNameOf defaultPackage;
|
inherit pname;
|
||||||
version = stripVersion (modulesStruct.mod.${defaultPackage}).version;
|
version = stripVersion (modulesStruct.mod.${defaultPackage}).version;
|
||||||
src = vendorEnv.passthru.sources.${defaultPackage};
|
src = vendorEnv.passthru.sources.${defaultPackage};
|
||||||
} // optionalAttrs (hasAttr "subPackages" modulesStruct) {
|
} // optionalAttrs (hasAttr "subPackages" modulesStruct) {
|
||||||
|
@ -393,7 +398,29 @@ let
|
||||||
|
|
||||||
disallowedReferences = optional (!allowGoReference) go;
|
disallowedReferences = optional (!allowGoReference) go;
|
||||||
|
|
||||||
passthru = { inherit go vendorEnv; } // passthru;
|
passthru = {
|
||||||
|
inherit go vendorEnv;
|
||||||
|
} // optionalAttrs (hasAttr "goPackagePath" modulesStruct) {
|
||||||
|
|
||||||
|
updateScript =
|
||||||
|
let
|
||||||
|
generatorArgs =
|
||||||
|
if hasAttr "subPackages" modulesStruct
|
||||||
|
then
|
||||||
|
concatStringsSep " "
|
||||||
|
(
|
||||||
|
map (subPackage: modulesStruct.goPackagePath + "/" + subPackage) modulesStruct.subPackages
|
||||||
|
)
|
||||||
|
else modulesStruct.goPackagePath;
|
||||||
|
|
||||||
|
in
|
||||||
|
writeScript "${pname}-updater" ''
|
||||||
|
#!${runtimeShell}
|
||||||
|
${optionalString (pwd != null) "cd ${toString pwd}"}
|
||||||
|
exec ${gomod2nix}/bin/gomod2nix generate ${generatorArgs}
|
||||||
|
'';
|
||||||
|
|
||||||
|
} // passthru;
|
||||||
|
|
||||||
meta = { platforms = go.meta.platforms or platforms.all; } // meta;
|
meta = { platforms = go.meta.platforms or platforms.all; } // meta;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue