General questions about packaging

Hello again,
I’ve already come up with questions in: Etc files do not get linked from store to /etc in my package - #7 by scrush

But I need to get more generic things straight at this point, so questions I got on my mind:

  1. Is there a way to call nix-build to the module and not to the package expression?
    Lets say my config tells hardware.sane.backends.brscan.enable = true; and also hands some config… how would I call my module manually with those informations?

  2. If I change my package/module, under what circumstances would nixos decide to rebuild it?

  • do I need to bump my version? Modules don’t have a version right?
  • do I need to set a --force flag somehow?
  1. is there some printf stuff for debugging that I could add to my expressions so I could checkin with intermediate informations during building the package?

Thank you!! :slight_smile:

and build what exactly?

nix would rebuild a derivation if anything changes in the resultant inputs to the derivation

https://nixos.org/manual/nixpkgs/unstable/#sec-functions-library-debug

oh boy, every start is a hard one, isnt it?
This is just one example of several that all failed, it took me about TWO hours to find the solution… :slight_smile: development is such a humbling experience

   error: syntax error, unexpected ID, expecting '.' or '='
      105|   pkgs.lib.debug.traceVal dontStrip "test";
         |                           ^

But thank you, got the debug.traceVal example working here.

About the other question I had previously… you came back with: “and build what exactly?”
Let me rephrase it:
I want to package a software and build a module to configure the software declaritively from nixos/config.nix → correct? we are on the same page? if not, that would indicate me I am mixing up some semantics.

i do end up with a expression that describes my package and another expression that describes a config module - i think…

So while I am dev’ing I would like to test the build again and again in a quick manner, instead of calling the lengthy (and chatty) process of nixos-rebuild test.
In other words: i want to call the build the same was nixos-rebuild does when I enable a package via config modules.

I would like to draft that with some pseudo code:
nix-build ./pkgs/my-printer-driver/ { hardware.config.sane.backends.brscan3.enable = true }
that should pull my package, build it and put configs from my input as if a declared that globally in my nixos/config.nix

Thanks in advance!

If you’re trying to test a NixOS module, you can create a NixOS VM test or even just create a separate test config which imports your moduleand build that (of course don’t deploy it)