For a project, I have a shell.nix
as follows:
with import <nixpkgs> { };
stdenv.mkDerivation {
name = "env";
nativeBuildInputs = [
wails
];
buildInputs = [
gcc
gnumake
go
xorg.libX11
xvfb-run
];
shellHook = ''
export LD_LIBRARY_PATH="${lib.makeLibraryPath [ xorg.libX11 ]}"
'';
}
Some times I need to use an overlay for wails
while I wait for the latest version to make its way through nixpkgs review and CI/CD. I have a wails-overlay.nix
for that:
self: super: {
wails = super.buildGoModule rec {
pname = "wails";
version = "2.0.0-beta.36";
src = super.fetchFromGitHub {
owner = "wailsapp";
repo = "wails";
rev = "v${version}";
sha256 = "sha256-uAbVc1UDgSNJwk8R6zXXqZImo6J9TRs3zPNlWelXS/I=";
} + "/v2";
vendorSha256 = "sha256-rrwlFZQT7sHhUqtU4UzwEqZbjWd/1fudfj/xdTGFUmQ=";
proxyVendor = true;
subPackages = [ "cmd/wails" ];
# These packages are needed to build wails
# and will also need to be used when building a wails app.
nativeBuildInputs = [
super.pkg-config
super.makeWrapper
];
# Wails apps are built with Go, so we need to be able to
# add it in propagatedBuildInputs.
allowGoReference = true;
# Following packages are required when wails used as a builder.
propagatedBuildInputs = [
super.pkg-config
super.go
super.gcc
super.gtk3
super.webkitgtk
super.nodejs
super.upx
];
ldflags = [
"-s"
"-w"
];
# As Wails calls a compiler, certain libraries need to be made available.
postFixup = ''
wrapProgram $out/bin/wails \
--prefix PATH : ${super.lib.makeBinPath [ super.pkg-config super.go super.gcc super.nodejs super.upx ]} \
--prefix LD_LIBRARY_PATH : ${super.lib.makeLibraryPath [ super.gtk3 super.webkitgtk ]} \
--set PKG_CONFIG_PATH "$PKG_CONFIG_PATH" \
--set CGO_LDFLAGS "-L${super.lib.makeLibraryPath [ super.zlib ]}"
'';
doCheck = true;
meta = with super.lib; {
description = "Build applications using Go + HTML + CSS + JS";
homepage = "https://wails.io";
license = licenses.mit;
maintainers = with maintainers; [ ianmjones ];
platforms = platforms.linux;
};
};
}
I’m struggling to find a way of using that overlay from within that shell.nix
. In my machine’s configuration.nix
I have the following kind of thing:
nixpkgs.overlays = [
(import ./wails-overlay.nix)
];
When I try to use any variation of that in the shell.nix
I get various errors about converting sets to string, or errors that make it obvious that I can’t specify an overlays
attribute (with or without nixpkgs
prefix and other stabs in the dark I’ve made).
The goal is to be able to use this with direnv
when .envrc
simply contains use nix
.
The project is also set up to use commands such as nix-shell --pure --run 'make'
in CI, and so having the wails-overlay.nix
able to be imported via shell.nix
will hopefully work there too.
Ideally, once the latest version of wails
makes its way into nixpkgs I’d likely disable the overlay until the next time there’s a new version to test and I’d just re-enable the updated overlay in my project.
I’ve seen some posts that mention calling nix-shell
with an overlays
arg. Is that the only way to use an overlay with nix-shell, or is there a way to include an overlay file in shell.nix
?