1

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?

  • It's not clear to me what you are trying to achieve? Is it to come up with an implementation like `withExtensions`? What is the significance of shell.nix in this case? – Chris Stryczynski Oct 05 '22 at 15:45
  • (1/2) I want to have some way to build fortune with some amount of packages in fortuneExtensions without having to specify them in my nixos configuration and wihout having to rebuild the system, and so I can do that from a local nixpkgs and not from the one specified in my nixos configuration. A bit like `nix-env -f "/path/to/nixpkgs/repo"` but I also need to install fortune in a way where the extensions are loaded correctly. I thought that maybe it was not possible to specify ```nix user.packages = with pkgs; [ (fortune.withExtensions (exts: [ exts.blag-fortune ]))];``` – Christina Sørensen Oct 05 '22 at 16:01
  • (2/2) with `nix-env` so perhaps I would have to use a `shell.nix` file instead. – Christina Sørensen Oct 05 '22 at 16:03
  • If I understand correctly. Yes you can make a simple nix expression file that would build the same package then (to avoid coupling it with your nixos config). This answer should be helpful: https://stackoverflow.com/a/47378588/1663462 I believe you can just do a nix-shell – Chris Stryczynski Oct 05 '22 at 17:59

1 Answers1

1

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.

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286