Wrapped package throws not of type package error

Hi everyone!

I’ve been using NixOS with relative comfort with Home manager. Recently though, I found myself not learning much about NixOS so I decided to find alternatives to set up NixOS on my desktop and my laptop. I want to share the exact same packages for coding but make a couple of variation for each system e.g. adjusting tmux sizes to fit each device screen properly. For that reason I’m learning about wrappers which seem to be the right solution to this problem however I’m embarrassed to say that I haven’t even been able to wrap my first package (yep, complete beginner here) even though I followed this guide, watched this video did lot of experiments, read articles and tutorials.

This is my code:

configuration.nix

# some config
  users.users.wavesinaroom = {
    isNormalUser = true;
    extraGroups = [ "wheel" ];
    packages = with pkgs; [
      (import ../wrapped/hx/hx.nix)
      tmux
      helix
      lazygit
      glab
      w3m 
    ];
    shell = pkgs.nushell;
  };
# more config

../wrapped/hx/hx.nix

{pkgs,...}:
pkgs.symlinkJoin {
  name = "hello";
  paths = [ pkgs.hello ];
  buildInputs = [ pkgs.makeWrapper];
  postBuild = pkgs.writeShellScriptBin "hello ''
    exec ${pkgs.hello}/bin/hello -t
  ''";
}
 error: A definition for option `users.users.wavesinaroom.packages."[definition 1-entry 1]"' is not of type `package'

Can anyone point out what I’m doing wrong or missing here please?

I read that stdenv.mkDerivation is the right approach for making packages but it is not mentioned anywhere in the nix cookbook wrappers section, so I’m not sure if that’s actually helpful.

Would really be

(import ../wrapped/hx/hx.nix { inherit pkgs; })

Because the raw import is a function that you then need to pass pkgs as an argument to. However, I suggest you read this page and learn about callPackage, and never use the import function again.

Also, the official wiki is wiki.nixos.org, and youtubers are. hmmmm

Finally, since your goal isn’t really a hello-world wrapper, tell us what you actually need and we can advise.

2 Likes

Oh thanks a lot! inherit definitely helped although I got this error:

error: cannot coerce a function to a string: «lambda writeShellScriptBin @ «github:nixos/nixpkgs/9ae611a455b90cf061d8f332b977e387bda8e1ca?narHash=sha256-md8WlXOlfnIeHeOScMTTHFyf2d6iaTwPl2apR5EQ3P4%3D»/pkgs/build-support/trivial-builders/default.nix:246:11»

Nevermind this error, I know what I’m doing wrong

The hello wrapper was just a way to test my code without adding more complexity. To answer my question my goal is this:

I want to have wrap my code editor (helix) tmux, lazygit in individual packages to be shared between two devices: my desktop and my laptop. Main reason for doing that is to avoid dotfiles and modularize my config to track them more neatly with git.