Creating a shell.nix file that uses a local nixpkgs and has some extensive configuration

can someone help me write a shell.nix file for testing my PR

https://github.com/NixOS/nixpkgs/pull/194516

The problem is that I can't just install the package as

nix-env -f "./my-nixpkgs-repo" -iA nixos.fortuneExtensions.blag-fortune

This is because it adds the ability to extend fortune-mod based on how pass does it. I have this code in my normal NixOS configuration:

user.packages = with pkgs; [
  (pass.withExtensions (exts: [
    exts.pass-otp
    exts.pass-audit
    exts.pass-update
    exts.pass-genphrase
  ]))];

I want to do something like this for testing on my branch for the PR, I thought it would be easiest to develop on if this was done with a shell.nix file, but if I can do it with just some nix-env command that would also be great

user.packages = with pkgs; [
  (fortune.withExtensions (exts: [
    exts.blag-fortune
  ]))];

Does anyone know how I would do this?

Upvotes: 1

Views: 828

Answers (1)

Chris Stryczynski
Chris Stryczynski

Reputation: 34071

I'm not 100% certain on the below but I'm guessing you can create a shell.nix file like below:

{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  buildInputs = with pkgs; [
  (fortune.withExtensions (exts: [
    exts.blag-fortune
  ]))];
} 

And run nix-shell to enter an environment with the above built.

As is the above will error with error: attribute 'withExtensions' missing but I assume this is something you've configured else where in your nixos config.

Upvotes: 1

Related Questions