Hi Nix community!
I’m trying to set up some dedicated devshells in my flake.nix file that manages my configuration based on the section output schema in the nix flake wiki entry. My goal is to create a Nushell custom command e.g. ide --rust that loads one of those devshells and loads a tmux layout to resemble an ide. How do I assign (if that’s the word) to devshells.<system>.<name>? Nix pills has a pretty good section on derivations but still I don’t understand how to use them in this case. I’m expected to give a .drv file from a nix expression I’ve already got for a devshell but I don’t understand how to get it. To put it simple:
config flake
{ self, ... }@inputs:
{
devShells."<system>"."<name>" = derivation; # <- How to get and pass .drv from a devshell here?
}
How can I get a .drv file from a dev shell? Should I use nix repl :b for that? Is there any nix command instead?
devshell
# How to get a .drv from this devshell for example?
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
# nativeBuildInputs is usually what you want -- tools you need to run
nativeBuildInputs = with pkgs.buildPackages; [ ruby_3_2 ];
}
If you have references or documentation I should check, please by all means. Getting help for troubleshooting is always cool and understanding why issue happen is even better 
The output of the pkgs.mkShell function is a derivation. You just need to evaluate the function that calls that function.
So, in your code:
{ self, nixpkgs, ... }@inputs:
{
devShells."<system>"."<name>" = import ./devshell { pkgs = nixpkgs.legacyPackages."<system>"; };
}
Where ./devshell is your existing file.
I think I shot myself on my foot by not giving actually what was going on on my side. I didn’t my question properly my bad sorry so I’ll do it again:
Same context given this is my code:
flake.nix
{
description = "Waves in a room";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
};
outputs = { self, nixpkgs, ...}@inputs:{
nixosConfigurations.laptop = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {inherit inputs;};
modules = [ ./laptop/configuration.nix ];
};
nixosConfigurations."desktop" = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
modules = [ ./wsl/configuration.nix ];
};
devShells.x86_64-linux.rust = import ./devshells/rust.nix;
};
}
rust.nix
{pkgs}:
pkgs.mkShell {
packages = with pkgs; [
cargo rustc rustfmt clippy rust-analyzer
];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
}
output
error: expected flake output attribute 'devShells.x86_64-linux.rust' to be a derivation or path but found a function: «lambda @ /home/wavesinaroom/waves_nixconfig/devshells/rust.nix:1:1»
~
import returns an lambda but I’m aware that mkShell returns a derivation. To me that’s confusing so I read Nix pills and found that I could get a derivation path with outPath but I didn’t get how to use it in this case scenario. I don’t need to pass pkgs to the function because I’ve got specialArgs = {inherit inputs}; but thanks anyway cause I didn’t give you my actual context sorry
Nevermind, my previous reply is just nonsense. Without { pkgs = nixpkgs.legacyPackages."<system>"; } ./devshells/rust.nix is just an expression so I’ll always get a lambda. I get it now 