mkShell: add builder (#30975)
This commit is contained in:
parent
02d361cea9
commit
adc5c9b83d
4 changed files with 72 additions and 0 deletions
|
@ -49,6 +49,10 @@ pkgs.stdenv.mkDerivation {
|
||||||
outputFile = "introduction.xml";
|
outputFile = "introduction.xml";
|
||||||
useChapters = true;
|
useChapters = true;
|
||||||
}
|
}
|
||||||
|
+ toDocbook {
|
||||||
|
inputFile = ./shell.md;
|
||||||
|
outputFile = "shell.xml";
|
||||||
|
}
|
||||||
+ toDocbook {
|
+ toDocbook {
|
||||||
inputFile = ./languages-frameworks/python.md;
|
inputFile = ./languages-frameworks/python.md;
|
||||||
outputFile = "./languages-frameworks/python.xml";
|
outputFile = "./languages-frameworks/python.xml";
|
||||||
|
|
20
doc/shell.md
Normal file
20
doc/shell.md
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
title: stdenv.mkShell
|
||||||
|
author: zimbatm
|
||||||
|
date: 2017-10-30
|
||||||
|
---
|
||||||
|
|
||||||
|
stdenv.mkShell is a special kind of derivation that is only useful when using
|
||||||
|
it combined with nix-shell. It will in fact fail to instantiate when invoked
|
||||||
|
with nix-build.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
|
pkgs.mkShell {
|
||||||
|
# this will make all the build inputs from hello and gnutar available to the shell environment
|
||||||
|
inputsFrom = with pkgs; [ hello gnutar ];
|
||||||
|
buildInputs = [ pkgs.gnumake ];
|
||||||
|
}
|
||||||
|
```
|
46
pkgs/build-support/mkshell/default.nix
Normal file
46
pkgs/build-support/mkshell/default.nix
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
{ lib, stdenv }:
|
||||||
|
|
||||||
|
# A special kind of derivation that is only meant to be consumed by the
|
||||||
|
# nix-shell.
|
||||||
|
{
|
||||||
|
inputsFrom ? [], # a list of derivations whose inputs will be made available to the environment
|
||||||
|
buildInputs ? [],
|
||||||
|
nativeBuildInputs ? [],
|
||||||
|
propagatedBuildInputs ? [],
|
||||||
|
propagatedNativeBuildInputs ? [],
|
||||||
|
...
|
||||||
|
}@attrs:
|
||||||
|
let
|
||||||
|
mergeInputs = name:
|
||||||
|
let
|
||||||
|
op = item: sum: sum ++ item."${name}" or [];
|
||||||
|
nul = [];
|
||||||
|
list = [attrs] ++ inputsFrom;
|
||||||
|
in
|
||||||
|
lib.foldr op nul list;
|
||||||
|
|
||||||
|
rest = builtins.removeAttrs attrs [
|
||||||
|
"inputsFrom"
|
||||||
|
"buildInputs"
|
||||||
|
"nativeBuildInputs"
|
||||||
|
"propagatedBuildInputs"
|
||||||
|
"propagatedNativeBuildInputs"
|
||||||
|
];
|
||||||
|
in
|
||||||
|
|
||||||
|
stdenv.mkDerivation ({
|
||||||
|
name = "nix-shell";
|
||||||
|
phases = ["nobuildPhase"];
|
||||||
|
|
||||||
|
buildInputs = mergeInputs "buildInputs";
|
||||||
|
nativeBuildInputs = mergeInputs "nativeBuildInputs";
|
||||||
|
propagatedBuildInputs = mergeInputs "propagatedBuildInputs";
|
||||||
|
propagatedNativeBuildInputs = mergeInputs "propagatedNativeBuildInputs";
|
||||||
|
|
||||||
|
nobuildPhase = ''
|
||||||
|
echo
|
||||||
|
echo "This derivation is not meant to be built, aborting";
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
'';
|
||||||
|
} // rest)
|
|
@ -311,6 +311,8 @@ with pkgs;
|
||||||
inherit kernel rootModules allowMissing;
|
inherit kernel rootModules allowMissing;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mkShell = callPackage ../build-supports/mkshell { };
|
||||||
|
|
||||||
nixBufferBuilders = import ../build-support/emacs/buffer.nix { inherit (pkgs) lib writeText; inherit (emacsPackagesNg) inherit-local; };
|
nixBufferBuilders = import ../build-support/emacs/buffer.nix { inherit (pkgs) lib writeText; inherit (emacsPackagesNg) inherit-local; };
|
||||||
|
|
||||||
pathsFromGraph = ../build-support/kernel/paths-from-graph.pl;
|
pathsFromGraph = ../build-support/kernel/paths-from-graph.pl;
|
||||||
|
|
Loading…
Reference in a new issue