Or is this only possible by writing a custom shell.nix?
Where path-to-my-local-nixpkgs-repo is a directory with a default.nix file containing a valid Nix expression. This directory may hold one's personal collection of Nix packages or a local clone of the Nixpkgs repo. I think this is the part in the Nix manual where default.nix is introduced, but this SO thread seems to be better.
For example:
let
nixpkgs_commit = "f4593ab";
nixpkgs_sha256 = "01bmiqndp1czwjw87kp21dvxs0zwv7yypqlyp713584iwncxjv0r";
pinnedNixpkgsGithubURL = "https://github.com/NixOS/nixpkgs/archive/${nixpkgs_commit}.tar.gz";
fetchedPinnedTarball =
builtins.fetchTarball
{ name = "nixpkgs";
url = pinnedNixpkgsGithubURL;
sha256 = nixpkgs_sha256;
}
;
in
{ pkgs ? import fetchedPinnedTarball {} }:
pkgs.mkShell
{ buildInputs = [ pkgs.tor-browser-bundle-bin ];
}
One might argue that this question is off-topic here, because it asks about command line options, but the solution may only be the above Nix expression (or one provided with -E). Anyway, if my argument is flawed, please let me know. Thanks!
$ nix-shell -E 'with import path-to-my-local-nixpkgs-repo {}; mkShell { buildInputs = [ tor-browser-bundle-bin PKG2 PKGS3 ]; }'
Compared to simple nix-shell -p '(import path-to-my-local-nixpkgs-repo {}).tor-browser-bundle-bin' this has the benefit of presenting more than one package.
Also, I suggest to replace import path-to-my-local-nixpkgs-repo {} with builtins.filterSource (p: t: baseNameOf p != ".git") path-to-my-local-nixpkgs-repo to save space from copying .git (2 GiB full git clone) for no reason on every change.
$ nix-shell -E 'with import path-to-my-local-nixpkgs-clone/default.nix {}; runCommand "dummy" { buildInputs = [ tor-browser-bundle-bin ]; } ""'
(Credit goes to Stackoverflow thread. Thanks a lot @potong for doing this research!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With