Activating a locally built pkg into my system env

I feel like I should be able to suss this out, but I can’t quite get my head around it.

I just created a derivation for a new pkg. I did this by cloning nixos and adding it to the repo locally. I have it building and installing. But it doesn’t execute properly because it’s tightly coupled to the versions of things that are in my system env (via configuration.nix).

It seems like some form of pinning is a potential answer to this. Can I just override nixpgs to be a local nixos directory?

Instead of having a local fork and apply changes there, have you considered using an overlay which you use from your configuration.nix?

Or directly use callPackage (import /path/to/your/default.nix) {} in your configs package list. (Actual syntax might slightly differ as this is from memory)

1 Like

Thanks.

Either of those sound less clumsy than what I’ve been considering. It’s would just be a temporary thing, so I can test the new pkg.

callPackage sounds straightforward. Could you elaborate on the use of an overlay?

Actually, let me dig into this. I may have a question though.

Thanks.

Well, initially, it seems that overlays will only work for an existing pkg, whereas this one is new. I’ll look into callPackage.

Overlays work perfectly fine for new packages as well.

I have not yet used one with configuratiin.nix, though the process should be similar as with home.nix. especially as nixpkgs.overlays exists in both places.

In my user config I have an overlay defined with some local packages, none of them is available in nixpkgs already as far as I remember.

https://gitlab.com/NobbZ/nix-home-manager-dotfiles/-/tree/master/nix%2FmyOverlay

1 Like

I was wrong about that, generally anyway. I found this post helpful:

Packaging a Rust project for Nix | eipi.xyz

[UPDATED: I had posted the wrong link]

I had the same problem the writer did. It did not automatically pick up my overlay via the environment variable. However, I prefer this anyway since it’s explicit.

diff --git a/configuration.nix b/configuration.nix
index 6289249..afa2422 100644
--- a/configuration.nix
+++ b/configuration.nix
@@ -5,6 +5,9 @@
 { config, pkgs, ... }:
 
 {
+  nixpkgs.overlays = [
+    (import ./overlays/ams.nix)
+  ];
   imports =
     [ # Include the results of the hardware scan.
       ./hardware-configuration.nix
@@ -207,6 +210,7 @@ menuentry "Windows 10 (on /dev/sda1)" --class windows --class os $menuentry_id_o
 
     # synths and instruments
     aeolus
+    ams
     axoloti
     # beast broken
     dirt
diff --git a/overlays/ams.nix b/overlays/ams.nix
new file mode 100644
index 0000000..b898763
--- /dev/null
+++ b/overlays/ams.nix
@@ -0,0 +1,4 @@
+self: super:
+{
+  ams = super.callPackage /home2/nixos/nixpkgs/pkgs/applications/audio/ams {};
+}

The above worked perfectly for me.