Notice in the sha fields, using fakeHash. So when you do this, run home-manager switch and you will get an error about hash-mismatch. First error message gives sha256, run again and that will give you the vendorSha256.
There are probably a few variations on doing this, depending on the pkg. In this case the pkg is using buildGoModule. Here is another variation, to overlay asdf-vm.nix:
Thanks for posting your learnings in a searchable space. You’ve definitely helped me out.
In some cases, if you’re writing a nix.flake, I think you can get away with removing prev.lib.fakeHash from src.sha256 by instead declaring it as an input (so the hash ends up in flake.lock). vendorSha256, however, seems to be necessary.
Hi, I’m trying to get the latest version of devpod using the above overlay, but I’m running into issues
in my home.nix:
nixpkgs.overlays = [
(final: prev: {
devpod = prev.callPackage "${prev.path}/pkgs/development/tools/devpod" {
buildGoModule = args: prev.buildGoModule (args // {
version = "0.6.8";
pname = "devpod";
meta = with lib; {
description = "Codespaces but open-source, client-only and unopinionated: Works with any IDE and lets you use any cloud, kubernetes or just localhost docker";
mainProgram = "devpod";
homepage = "https://devpod.sh";
license = licenses.mpl20;
maintainers = with maintainers; [ maxbrunet ];
};
src = prev.fetchFromGitHub {
owner = "loft-sh";
repo = "devpod";
rev = "v0.6.8";
sha256 = prev.lib.fakeHash;
};
});
};
})
];
when i run home-manager switch --flake . i get the following error
warning: Git tree '/opt/repos/nix-config' is dirty
warning: Git tree '/opt/repos/nix-config' is dirty
warning: Git tree '/opt/repos/nix-config' is dirty
warning: Git tree '/opt/repos/nix-config' is dirty
error:
… while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:34:12:
33|
34| strict = derivationStrict drvAttrs;
| ^
35|
… while evaluating derivation 'home-manager-generation'
whose name attribute is located at /nix/store/khbvilmsrv4l69nwd52h27j1mp44a0xi-source/pkgs/stdenv/generic/make-derivation.nix:375:7
… while evaluating attribute 'buildCommand' of derivation 'home-manager-generation'
at /nix/store/khbvilmsrv4l69nwd52h27j1mp44a0xi-source/pkgs/build-support/trivial-builders/default.nix:59:17:
58| enableParallelBuilding = true;
59| inherit buildCommand name;
| ^
60| passAsFile = [ "buildCommand" ]
… while evaluating the option `home.activation.installPackages.data':
… while evaluating definitions from `/nix/store/khpgnlyxlq96qf1qibrw8b3f74vnqxgn-source/modules/home-environment.nix':
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: A definition for option `home.packages."[definition 1-entry 6]"' is not of type `package'. Definition values:
- In `/nix/store/rdy61m3cmwlhk5ayqpfv4gw4iw644k9n-source/home-manager/home.nix':
{
devpod = <derivation devpod-0.6.8>;
devpod-desktop = <derivation devpod-desktop-0.5.20>;
override = <function, args: {buildGoModule, copyDesktopItems, darwin, desktopToDarwinBundle, fetchFromGitHub, fetchYarnDeps, gtk3, installShellFiles, jq, lib, libayatana-appindicator, libsoup_2_4, makeDesktopItem, mkYarnPackage, openssl, pkg-config, rust, rustPlatform, stdenv, testers, webkitgtk_4_0}>;
overrideDerivation = <function>;