如何从 nix 环境中获取 default.nix?

问题描述 投票:0回答:1

首先我认为我已经理解:

nix-shell -p git

和做一样

nix-shell

如果在同一目录中有一个文件 default.nix 具有以下内容:

with import <nixpkgs> {};

stdenv.mkDerivation rec {   
       name = "name"; 
       env = buildEnv { name = name; paths = buildInputs; };   
       buildInputs = [git   ]; }

如果我是对的,我已经用第一种方法创建了一个环境, 我怎样才能得到一个 default.nix 文件,我可以重复使用它来重新创建相同的环境?

nix
1个回答
0
投票

这可能对你有用:

 nix-shell -E 'with import <nixpkgs> { }; runCommand "dummy" { buildInputs = [ git ]; } ""'

等同于:

nix-shell -p git
© www.soinside.com 2019 - 2024. All rights reserved.