devenv icon indicating copy to clipboard operation
devenv copied to clipboard

Guide for using with npins

Open balintbarna opened this issue 6 months ago • 4 comments

Please add a possibility for using devenv shells with npins. There are 2 supported ways of using devenv that I know of:

  1. using the devenv cli calling devenv shell which supports specifying inputs with devenv.yaml
  2. using flakes calling nix develop --impure after defining a devenv dev shell in the flake.

The issue with the first method is that I can't use the same input specification across my NixOS and home manager modules, it's only for devenv. The issue with the second method is that is requires using flakes, which is non-standard nix.

It would be great to have an officially supported way to use devenv with npins, something like:

# default.nix
let
  sources = import ./npins;
  pkgs = import sources.nixpkgs { ... };
  devenv = import sources.devenv { ... }; # maybe inject nixpkgs here?
in
{
  # activate with `nix-shell -A devshell`
  devshell = devenv.mkShell {
    # or somehow inject pkgs here
    imports = [ ./devenv.nix ];
  };
}

If this possibility already exists please document it. If the documentation already exists I apologise and kindly ask that you point me to where I can find it.

balintbarna avatar Aug 26 '25 09:08 balintbarna

For (1) see https://github.com/cachix/devenv/pull/2092

domenkozar avatar Aug 26 '25 15:08 domenkozar

@balintbarna supporting devenv and also flakes already takes a lot of our time - if someone writes guide for npins I'm happy to link to it!

domenkozar avatar Aug 28 '25 15:08 domenkozar

@domenkozar Someone tried here and failed https://www.reddit.com/r/NixOS/comments/1mvfceq/comment/naqq0gh/ It would be great if there was a mkShell function in devenv that can be called without using flakes and just pass in pkgs, inputs and modules, same as the flake function but works without flakes.

balintbarna avatar Aug 30 '25 13:08 balintbarna

@domenkozar I got devenv working with an npins based setup. I wrote a wrapper function which provides a very simple interface and consumes a standard devenv configuration file. It activates with nix-shell and doesn't require flakes or the devenv CLI, as it uses standard Nix.

I cheated a bit by setting self to ./., not sure if that would lead to issues but I haven't seen any yet. What do you think?

balintbarna avatar Oct 12 '25 13:10 balintbarna