treewide: go-modules -> goModules

In 787af0f79f
I had to change ${go-modules} to $goModules to allow overrideAttrs to work;
However, env vars cannot contain -, so  i had to change go-modules too.
This in turn broke nix-update because it uses the go-modules attr.

Instead of making nix-update more complicated, make go-modules naming match cargoDeps.

`fd --type f | xargs sd '\bgo-modules\b' 'goModules'`
and revert change to pkgs/applications/misc/dstask/default.nix
and pkgs/servers/http/dave/default.nix
and pkgs/os-specific/darwin/plistwatch/default.nix

release note added
This commit is contained in:
Artturin 2023-07-11 21:16:30 +03:00
parent 9caab144be
commit 1c29673fcc
30 changed files with 40 additions and 39 deletions

View file

@ -20,7 +20,7 @@ In the following is an example expression using `buildGoModule`, the following a
To obtain the actual hash, set `vendorHash = lib.fakeSha256;` and run the build ([more details here](#sec-source-hashes)).
- `proxyVendor`: Fetches (go mod download) and proxies the vendor directory. This is useful if your code depends on c code and go mod tidy does not include the needed sources to build or if any dependency has case-insensitive conflicts which will produce platform-dependent `vendorHash` checksums.
- `modPostBuild`: Shell commands to run after the build of the go-modules executes `go mod vendor`, and before calculating fixed output derivation's `vendorHash` (or `vendorSha256`). Note that if you change this attribute, you need to update `vendorHash` (or `vendorSha256`) attribute.
- `modPostBuild`: Shell commands to run after the build of the goModules executes `go mod vendor`, and before calculating fixed output derivation's `vendorHash` (or `vendorSha256`). Note that if you change this attribute, you need to update `vendorHash` (or `vendorSha256`) attribute.
```nix
pet = buildGoModule rec {
@ -115,7 +115,7 @@ done
## Attributes used by the builders {#ssec-go-common-attributes}
Many attributes [controlling the build phase](#variables-controlling-the-build-phase) are respected by both `buildGoModule` and `buildGoPackage`. Note that `buildGoModule` reads the following attributes also when building the `vendor/` go-modules fixed output derivation as well:
Many attributes [controlling the build phase](#variables-controlling-the-build-phase) are respected by both `buildGoModule` and `buildGoPackage`. Note that `buildGoModule` reads the following attributes also when building the `vendor/` goModules fixed output derivation as well:
- [`sourceRoot`](#var-stdenv-sourceRoot)
- [`prePatch`](#var-stdenv-prePatch)

View file

@ -98,6 +98,8 @@
- DocBook option documentation is no longer supported, all module documentation now uses markdown.
- `buildGoModule` `go-modules` attrs have been renamed to `goModules`.
- `services.fail2ban.jails` can now be configured with attribute sets defining settings and filters instead of lines. The stringed options `daemonConfig` and `extraSettings` have respectively been replaced by `daemonSettings` and `jails.DEFAULT.settings` which use attribute sets.
- The module [services.ankisyncd](#opt-services.ankisyncd.package) has been switched to [anki-sync-server-rs](https://github.com/ankicommunity/anki-sync-server-rs) from the old python version, which was difficult to update, had not been updated in a while, and did not support recent versions of anki.

View file

@ -114,7 +114,7 @@ cat >versions.nix <<EOF
EOF
set +e
K3S_VENDOR_SHA256=$(nix-prefetch -I nixpkgs=${NIXPKGS_ROOT} "{ sha256 }: (import ${NIXPKGS_ROOT}. {}).k3s_1_${MINOR_VERSION}.go-modules.overrideAttrs (_: { vendorSha256 = sha256; })")
K3S_VENDOR_SHA256=$(nix-prefetch -I nixpkgs=${NIXPKGS_ROOT} "{ sha256 }: (import ${NIXPKGS_ROOT}. {}).k3s_1_${MINOR_VERSION}.goModules.overrideAttrs (_: { vendorSha256 = sha256; })")
set -e
if [ -n "${K3S_VENDOR_SHA256:-}" ]; then

View file

@ -28,6 +28,6 @@ buildGoModule rec {
homepage = "https://github.com/kubeflow/kfctl";
license = licenses.asl20;
maintainers = with maintainers; [ mvnetbiz ];
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.go-modules --check
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.goModules --check
};
}

View file

@ -21,6 +21,6 @@ buildGoModule rec {
description = "Kubemqctl is a command line interface (CLI) for Kubemq Kubernetes Message Broker.";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ brianmcgee ];
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.go-modules --check
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.goModules --check
};
}

View file

@ -151,7 +151,7 @@ update_attr hash "${hash}"
old_vendor_hash="$(read_attr vendorHash)"
if [[ ${old_vendor_hash} != null ]]; then
echo_provider "calculating vendorHash"
vendorHash=$(generate_hash go-modules)
vendorHash=$(generate_hash goModules)
update_attr vendorHash "${vendorHash}"
fi

View file

@ -20,7 +20,7 @@ buildGoModule rec {
hash = "sha256-jurZvEtiaTjWeDkmCJDIFlTzR5EVglfoDxkFgOilo8s=";
};
# patching must be done in prebuild, so it is shared with go-modules
# patching must be done in prebuild, so it is shared with goModules
# see https://github.com/NixOS/nixpkgs/issues/208036
preBuild = ''
for file in `find -name Makefile -type f`; do

View file

@ -43,7 +43,7 @@ buildPythonApplication rec {
pname = "kitty-go-modules";
inherit src version;
vendorHash = "sha256-jk2EcYVuhV/UQfHAIfpnn8ZIZnwjA/o8YRXmpoC85Vc=";
}).go-modules;
}).goModules;
buildInputs = [
harfbuzz
@ -224,7 +224,6 @@ buildPythonApplication rec {
'';
passthru = {
go-modules = goModules; # allow for updateScript to handle vendorHash
tests.test = nixosTests.terminal-emulators.kitty;
updateScript = nix-update-script {};
};

View file

@ -88,7 +88,7 @@ buildGoModule rec {
--prefix PATH : ${lib.makeBinPath [ bash git gzip openssh ]}
'';
# $data is not available in go-modules.drv and preBuild isn't needed
# $data is not available in goModules.drv and preBuild isn't needed
overrideModAttrs = (_: {
postPatch = null;
preBuild = null;

View file

@ -26,6 +26,6 @@ buildGoModule rec {
homepage = "https://github.com/tillson/git-hound";
license = with licenses; [ mit ];
maintainers = with maintainers; [ fab ];
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.go-modules --check
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.goModules --check
};
}

View file

@ -3,7 +3,7 @@
}:
{
overrideModAttrs = (_: {
# No need to workaround -trimpath: it's not used in go-modules,
# No need to workaround -trimpath: it's not used in goModules,
# but do download `go generate`'s dependencies nonetheless.
preBuild = ''
go generate ./loaders

View file

@ -93,7 +93,7 @@ in
inherit pname version src;
# Override vendorHash with the output got from
# nix-prefetch -E "{ sha256 }: ((import ./. { }).apptainer.override { vendorHash = sha256; }).go-modules"
# nix-prefetch -E "{ sha256 }: ((import ./. { }).apptainer.override { vendorHash = sha256; }).goModules"
# or with `null` when using vendored source tarball.
inherit vendorHash deleteVendor proxyVendor;

View file

@ -18,7 +18,7 @@ let
};
# Update by running
# nix-prefetch -E "{ sha256 }: ((import ./. { }).apptainer.override { vendorHash = sha256; }).go-modules"
# nix-prefetch -E "{ sha256 }: ((import ./. { }).apptainer.override { vendorHash = sha256; }).goModules"
# at the root directory of the Nixpkgs repository
vendorHash = "sha256-PfFubgR/W1WBXIsRO+Kg7hA6ebeAcRiJlTlAZbnl19A=";
@ -49,7 +49,7 @@ let
};
# Update by running
# nix-prefetch -E "{ sha256 }: ((import ./. { }).singularity.override { vendorHash = sha256; }).go-modules"
# nix-prefetch -E "{ sha256 }: ((import ./. { }).singularity.override { vendorHash = sha256; }).goModules"
# at the root directory of the Nixpkgs repository
vendorHash = "sha256-mBhlH6LSmcJuc6HbU/3Q9ii7vJkW9jcikBWCl8oeMOk=";

View file

@ -6,7 +6,7 @@
, passthru ? { }
, patches ? [ ]
# A function to override the go-modules derivation
# A function to override the goModules derivation
, overrideModAttrs ? (_oldAttrs: { })
# path to go.mod and go.sum directory
@ -52,9 +52,9 @@ assert (args' ? vendorHash && args' ? vendorSha256) -> throw "both `vendorHash`
let
args = removeAttrs args' [ "overrideModAttrs" "vendorSha256" "vendorHash" ];
go-modules = if (vendorHash == null) then "" else
goModules = if (vendorHash == null) then "" else
(stdenv.mkDerivation {
name = "${name}-go-modules";
name = "${name}-goModules";
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ go git cacert ];
@ -163,10 +163,10 @@ let
cd "$modRoot"
'' + lib.optionalString (vendorHash != null) ''
${if proxyVendor then ''
export GOPROXY=file://${go-modules}
export GOPROXY=file://${goModules}
'' else ''
rm -rf vendor
cp -r --reflink=auto ${go-modules} vendor
cp -r --reflink=auto ${goModules} vendor
''}
'' + ''
@ -288,7 +288,7 @@ let
disallowedReferences = lib.optional (!allowGoReference) go;
passthru = passthru // { inherit go go-modules vendorHash; } // { inherit (args') vendorSha256; };
passthru = passthru // { inherit go goModules vendorHash; } // { inherit (args') vendorSha256; };
meta = {
# Add default meta information

View file

@ -20,6 +20,6 @@ buildGoModule rec {
homepage = "https://github.com/cswank/kcli";
license = licenses.mit;
maintainers = with maintainers; [ cswank ];
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.go-modules --check
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.goModules --check
};
}

View file

@ -80,6 +80,6 @@ clean_up
OLD_GO_VENDOR_HASH="$(instantiateClean authelia.vendorHash)"
echo "Old go vendor hash $OLD_GO_VENDOR_HASH"
replace "$OLD_GO_VENDOR_HASH" "$TMP_HASH" "$DRV_DIR/sources.nix"
NEW_GO_VENDOR_HASH="$(fetchNewSha authelia.go-modules)"
NEW_GO_VENDOR_HASH="$(fetchNewSha authelia.goModules)"
echo "New go vendor hash $NEW_GO_VENDOR_HASH"
replace "$TMP_HASH" "$NEW_GO_VENDOR_HASH" "$DRV_DIR/sources.nix"

View file

@ -37,7 +37,7 @@ buildGoModule {
vendorSha256 = "sha256-ENtTnDsz5WhRz1kiqnWQ5vyEpZtgi7ZeYvksffgW78k=";
# Override the go-modules fetcher derivation to apply
# Override the goModules fetcher derivation to apply
# upstream's patch of the crypto/x509 library.
modBuildPhase = ''
go mod init github.com/namecoin/x509-compressed

View file

@ -20,6 +20,6 @@ buildGoModule rec {
homepage = "https://github.com/CrunchyData/pg_featureserv";
license = licenses.asl20;
maintainers = with maintainers; [ sikmir ];
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.go-modules --check
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.goModules --check
};
}

View file

@ -35,6 +35,6 @@ buildGoModule rec {
homepage = "https://gobetween.io";
license = licenses.mit;
maintainers = with maintainers; [ tomberek ];
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.go-modules --check
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.goModules --check
};
}

View file

@ -13,7 +13,7 @@ fi
extractVendorHash() {
original="${1?original hash missing}"
result="$(nix-build -A memos.go-modules 2>&1 | tail -n3 | grep 'got:' | cut -d: -f2- | xargs echo || true)"
result="$(nix-build -A memos.goModules 2>&1 | tail -n3 | grep 'got:' | cut -d: -f2- | xargs echo || true)"
[ -z "$result" ] && { echo "$original"; } || { echo "$result"; }
}

View file

@ -30,6 +30,6 @@ buildGoModule rec {
homepage = "https://github.com/metalmatze/alertmanager-bot";
license = licenses.mit;
maintainers = with maintainers; [ mmahut ];
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.go-modules --check
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.goModules --check
};
}

View file

@ -16,7 +16,7 @@ replaceHash() {
}
extractVendorHash() {
original="${1?original hash missing}"
result="$(nix-build -A grafana.go-modules 2>&1 | tail -n3 | grep 'got:' | cut -d: -f2- | xargs echo || true)"
result="$(nix-build -A grafana.goModules 2>&1 | tail -n3 | grep 'got:' | cut -d: -f2- | xargs echo || true)"
[ -z "$result" ] && { echo "$original"; } || { echo "$result"; }
}

View file

@ -46,11 +46,11 @@ let
})
];
netfilter-go-modules = (buildGoModule {
netfilter-goModules = (buildGoModule {
inherit pname version src patches;
modRoot = "linux/netfilter";
vendorHash = "sha256-Cmo0wnl0z5r1paaEf1MhCPbInWeoMhGjnxCxGh0cyO8=";
}).go-modules;
}).goModules;
extensionBridgeDeps = rustPlatform.fetchCargoTarball {
inherit src patches;
@ -132,7 +132,7 @@ stdenv.mkDerivation {
substituteInPlace extension/CMakeLists.txt \
--replace '/etc' "$out/etc"
ln -s '${netfilter-go-modules}' linux/netfilter/vendor
ln -s '${netfilter-goModules}' linux/netfilter/vendor
pushd extension/bridge
cargoDepsCopy="$extensionBridgeDepsCopy" cargoSetupPostPatchHook

View file

@ -27,6 +27,6 @@ buildGoModule rec {
license = licenses.mit;
maintainers = with maintainers; [ infinisil ];
mainProgram = "shadowfox-updater";
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.go-modules --check
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.goModules --check
};
}

View file

@ -34,6 +34,6 @@ buildGoModule rec {
license = licenses.asl20;
maintainers = with maintainers; [ guibert ];
platforms = platforms.linux;
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.go-modules --check
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.goModules --check
};
}

View file

@ -18,6 +18,6 @@ buildGoModule rec {
description = "Interactive cli tool for HTTP inspection";
license = licenses.agpl3;
maintainers = with maintainers; [ pradeepchhetri ];
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.go-modules --check
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.goModules --check
};
}

View file

@ -26,6 +26,6 @@ buildGoModule rec {
homepage = "https://github.com/dsnezhkov/deepsea";
license = with licenses; [ asl20 ];
maintainers = with maintainers; [ fab ];
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.go-modules --check
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.goModules --check
};
}

View file

@ -22,6 +22,6 @@ buildGoModule rec {
homepage = "https://github.com/eth0izzle/shhgit";
license = with licenses; [ mit ];
maintainers = with maintainers; [ fab ];
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.go-modules --check
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.goModules --check
};
}

View file

@ -21,6 +21,6 @@ buildGoModule rec {
homepage = "https://github.com/kitabisa/ssb";
license = with licenses; [ asl20 ];
maintainers = with maintainers; [ fab ];
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.go-modules --check
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.goModules --check
};
}

View file

@ -32,6 +32,6 @@ buildGoModule rec {
homepage = "https://github.com/Wraparound/wrap";
license = licenses.gpl3Only;
maintainers = [ maintainers.austinbutler ];
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.go-modules --check
broken = true; # vendor isn't reproducible with go > 1.17: nix-build -A $name.goModules --check
};
}