mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-08-25 17:55:21 +00:00
doc/dev-environments: add starter guide for dev environments
This commit is contained in:
49
doc/getting-started/dev-environments.md
Normal file
49
doc/getting-started/dev-environments.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# Dev environments {#dev-environments}
|
||||
|
||||
Create a `shell.nix` with the following:
|
||||
|
||||
```nix
|
||||
# shell.nix
|
||||
let
|
||||
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz";
|
||||
pkgs = import nixpkgs { };
|
||||
in
|
||||
pkgs.mkShell {
|
||||
packages = [ pkgs.python3 ];
|
||||
shellHook = ''
|
||||
echo "Welcome in my nix shell"
|
||||
'';
|
||||
}
|
||||
```
|
||||
|
||||
run
|
||||
|
||||
```sh
|
||||
nix-shell
|
||||
```
|
||||
|
||||
This activates your `shell.nix` and you should see:
|
||||
|
||||
```sh
|
||||
unpacking 'https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz' into the Git cache...
|
||||
Welcome in your nix shell
|
||||
```
|
||||
|
||||
python3 is available
|
||||
|
||||
```sh
|
||||
$ python3 --version
|
||||
```
|
||||
|
||||
To leave the shell
|
||||
|
||||
```bash
|
||||
ctrl+D
|
||||
```
|
||||
|
||||
:::{.note}
|
||||
You should use [pinned nixpkgs](https://nix.dev/guides/recipes/dependency-management.html).
|
||||
The example used `unstable` here for demonstration purposes only
|
||||
:::
|
||||
|
||||
For further information check out [nix-shell](https://nix.dev/manual/nix/stable/command-ref/nix-shell)
|
||||
6
doc/getting-started/getting-started.part.md
Normal file
6
doc/getting-started/getting-started.part.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# Getting started {#getting-started}
|
||||
|
||||
```{=include=} chapters
|
||||
first-package.chapter.md
|
||||
dev-environments.md
|
||||
```
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
```{=include=} chapters
|
||||
preface.chapter.md
|
||||
first-package.chapter.md
|
||||
```
|
||||
|
||||
```{=include=} parts
|
||||
getting-started/getting-started.part.md
|
||||
using-nixpkgs.md
|
||||
lib.md
|
||||
stdenv.md
|
||||
|
||||
@@ -105,6 +105,9 @@
|
||||
"cuda-writing-tests": [
|
||||
"index.html#cuda-writing-tests"
|
||||
],
|
||||
"dev-environments": [
|
||||
"index.html#dev-environments"
|
||||
],
|
||||
"ex-build-helpers-extendMkDerivation": [
|
||||
"index.html#ex-build-helpers-extendMkDerivation"
|
||||
],
|
||||
@@ -149,6 +152,9 @@
|
||||
"friction-graphics-wayland": [
|
||||
"index.html#friction-graphics-wayland"
|
||||
],
|
||||
"getting-started": [
|
||||
"index.html#getting-started"
|
||||
],
|
||||
"ghc-deprecation-policy": [
|
||||
"index.html#ghc-deprecation-policy"
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user