How to build a package locally off of nixpkgs
So I faced a similar situation today where I tried updating goose and I faced with a build issue when running nixos-rebuild switch
. I never contributed to nixpkgs so I thought let this be the first try.
For this I had to run this derivation locally, I tried copy pasting the default.nix directly into a local file and ran nix-build <filename>.nix
, we got some lib
not found error etc. After some digging found this so answer which helped. So just for development, I changed:
{ pkgs ? import <nixpkgs> { system = builtins.currentSystem; }
, lib ? pkgs.lib
, buildGoModule ? pkgs.buildGoModule
, fetchFromGitHub ? pkgs.fetchFromGitHub
, stdenv ? pkgs.stdenv
}:
# ...rest of the file
To:
{ pkgs ? import <nixpkgs> { system = builtins.currentSystem; }
, lib ? pkgs.lib
, buildGoModule ? pkgs.buildGoModule
, fetchFromGitHub ? pkgs.fetchFromGitHub
, stdenv ? pkgs.stdenv
}:
# ...rest of the file
And now nix build <file>.nix
works! (I added my patch later in the file which made it work :)
Along with this I learned that nix ppl for some reason want to run tests on builds, idk why they do this but they do. I don’t really agree to this atm but maybe someday when i’ll be wise i’ll bring myself to agree to it.
Anyway, glad it’s out of my way now. Here’s my basic ass patch if you want to take a look