├── .envrc
├── .github
├── dependabot.yml
├── settings.yml
└── workflows
│ └── nix.yml
├── .gitignore
├── .goreleaser.yml
├── .vscode
└── tasks.json
├── LICENSE
├── README.md
├── benchmark
├── README.md
├── devshell-nix.nix
├── devshell-toml.nix
├── devshell-toml.toml
└── nixpkgs-mkshell.nix
├── default.nix
├── devshell.toml
├── docs
├── .gitignore
├── book.toml
├── default.nix
├── src
│ ├── 99_todo.md
│ ├── SUMMARY.md
│ ├── ci.md
│ ├── env.md
│ ├── extending.md
│ ├── flake-app.md
│ ├── getting_started.md
│ ├── intro.md
│ └── modules_schema.md
└── theme
│ ├── index.hbs
│ ├── pagetoc.css
│ └── pagetoc.js
├── extra
├── git
│ └── hooks.nix
├── language
│ ├── c.nix
│ ├── go.nix
│ ├── hare.nix
│ ├── perl.nix
│ ├── ruby.nix
│ └── rust.nix
├── locale.nix
└── services
│ └── postgres.nix
├── flake-module.nix
├── flake.lock
├── flake.lock.nix
├── flake.nix
├── modules
├── back-compat.nix
├── commands.nix
├── default.nix
├── devshell.nix
├── env.nix
├── eval-args.nix
├── modules-docs.nix
├── modules.nix
└── services.nix
├── nix
├── ansi.nix
├── importTOML.nix
├── mkNakedShell.nix
├── nixpkgs.nix
├── source.nix
├── strOrPackage.nix
└── writeDefaultShellScript.nix
├── overlay.nix
├── renovate.json
├── shell.nix
├── templates
├── flake-parts
│ ├── .envrc
│ ├── .gitignore
│ ├── flake.lock
│ └── flake.nix
├── gettingStartedExample
│ ├── .envrc
│ ├── .gitignore
│ ├── devshell.toml
│ ├── flake.lock
│ ├── flake.nix
│ └── readme.md
└── toml
│ ├── .envrc
│ ├── .gitignore
│ ├── devshell.toml
│ ├── flake.lock
│ ├── flake.nix
│ └── shell.nix
└── tests
├── assert.sh
├── core
├── commands.nix
├── devshell.nix
├── env.nix
└── modules-docs.nix
├── default.nix
└── extra
├── git.hooks.nix
├── language.c.nix
├── language.hare.nix
├── language.perl.nix
├── language.rust.nix
├── locale.nix
└── services.postgres.nix
/.envrc:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # ^ added for shellcheck and file-type detection
3 |
4 | # Watch all of these files for change
5 | watch_dir modules
6 | watch_dir nix
7 | watch_file devshell.toml
8 |
9 | # Store the shell symlink in the direnv layout directory
10 | out_link="$(direnv_layout_dir)"/devshell
11 |
12 | # Build the devshell environment
13 | nix-build shell.nix --out-link "$out_link"
14 |
15 | # Load the devshell
16 | # shellcheck disable=SC1091
17 | source "$out_link/env.bash"
18 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "github-actions"
4 | directory: "/"
5 | schedule:
6 | interval: "weekly"
7 |
--------------------------------------------------------------------------------
/.github/settings.yml:
--------------------------------------------------------------------------------
1 | repository:
2 | # See https://developer.github.com/v3/repos/#edit for all available settings.
3 |
4 | # The name of the repository. Changing this will rename the repository
5 | name: devshell
6 |
7 | # A short description of the repository that will show up on GitHub
8 | description: Per project developer environments
9 |
10 | # A URL with more information about the repository
11 | homepage: "https://numtide.github.io/devshell/"
12 |
13 | # A comma-separated list of topics to set on the repository
14 | topics: "toml, nix, direnv"
15 |
16 | # Either `true` to make the repository private, or `false` to make it public.
17 | private: false
18 |
19 | # Either `true` to enable issues for this repository, `false` to disable them.
20 | has_issues: true
21 |
22 | # Either `true` to enable projects for this repository, or `false` to disable them.
23 | # If projects are disabled for the organization, passing `true` will cause an API error.
24 | has_projects: false
25 |
26 | # Either `true` to enable the wiki for this repository, `false` to disable it.
27 | has_wiki: true
28 |
29 | # Either `true` to enable downloads for this repository, `false` to disable them.
30 | has_downloads: false
31 |
32 | # Updates the default branch for this repository.
33 | default_branch: main
34 |
35 | # Either `true` to allow squash-merging pull requests, or `false` to prevent
36 | # squash-merging.
37 | allow_squash_merge: true
38 |
39 | # Either `true` to allow merging pull requests with a merge commit, or `false`
40 | # to prevent merging pull requests with merge commits.
41 | allow_merge_commit: true
42 |
43 | # Either `true` to allow rebase-merging pull requests, or `false` to prevent
44 | # rebase-merging.
45 | allow_rebase_merge: true
46 |
47 | # Either `true` to enable automatic deletion of branches on merge, or `false` to disable
48 | delete_branch_on_merge: true
49 |
50 | # Either `true` to enable automated security fixes, or `false` to disable
51 | # automated security fixes.
52 | enable_automated_security_fixes: true
53 |
54 | # Either `true` to enable vulnerability alerts, or `false` to disable
55 | # vulnerability alerts.
56 | enable_vulnerability_alerts: true
57 |
58 | # Labels: define labels for Issues and Pull Requests
59 | #
60 | labels:
61 | # NOTE: leave that up to the https://github.com/numtide/.github repo
62 | # - name: bug
63 | # color: CC0000
64 | # description: An issue with the system 🐛.
65 |
66 | # - name: feature
67 | # # If including a `#`, make sure to wrap it with quotes!
68 | # color: '#336699'
69 | # description: New functionality.
70 |
71 | # - name: Help Wanted
72 | # # Provide a new name to rename an existing label
73 | # new_name: first-timers-only
74 |
75 | # Milestones: define milestones for Issues and Pull Requests
76 | milestones:
77 | # - title: milestone-title
78 | # description: milestone-description
79 | # # The state of the milestone. Either `open` or `closed`
80 | # state: open
81 |
82 | # Collaborators: give specific users access to this repository.
83 | # See https://docs.github.com/en/rest/reference/repos#add-a-repository-collaborator for available options
84 | collaborators:
85 | # - username: xxx
86 | # Note: `permission` is only valid on organization-owned repositories.
87 | # The permission to grant the collaborator. Can be one of:
88 | # * `pull` - can pull, but not push to or administer this repository.
89 | # * `push` - can pull and push, but not administer this repository.
90 | # * `admin` - can pull, push and administer this repository.
91 | # * `maintain` - Recommended for project managers who need to manage the repository without access to sensitive or destructive actions.
92 | # * `triage` - Recommended for contributors who need to proactively manage issues and pull requests without write access.
93 | # permission: push
94 |
95 | # See https://docs.github.com/en/rest/reference/teams#add-or-update-team-repository-permissions for available options
96 | teams:
97 | - name: network
98 | # The permission to grant the team. Can be one of:
99 | # * `pull` - can pull, but not push to or administer this repository.
100 | # * `push` - can pull and push, but not administer this repository.
101 | # * `admin` - can pull, push and administer this repository.
102 | # * `maintain` - Recommended for project managers who need to manage the repository without access to sensitive or destructive actions.
103 | # * `triage` - Recommended for contributors who need to proactively manage issues and pull requests without write access.
104 | permission: maintain
105 |
106 | branches:
107 | - name: main
108 | # https://docs.github.com/en/rest/reference/repos#update-branch-protection
109 | # Branch Protection settings. Set to null to disable
110 | protection:
111 | # Required. Require at least one approving review on a pull request, before merging. Set to null to disable.
112 | required_pull_request_reviews:
113 | # # The number of approvals required. (1-6)
114 | # required_approving_review_count: 1
115 | # # Dismiss approved reviews automatically when a new commit is pushed.
116 | # dismiss_stale_reviews: true
117 | # # Blocks merge until code owners have reviewed.
118 | # require_code_owner_reviews: true
119 | # # Specify which users and teams can dismiss pull request reviews. Pass an empty dismissal_restrictions object to disable. User and team dismissal_restrictions are only available for organization-owned repositories. Omit this parameter for personal repositories.
120 | # dismissal_restrictions:
121 | # users: []
122 | # teams: []
123 | # Required. Require status checks to pass before merging. Set to null to disable
124 | required_status_checks:
125 | # Required. Require branches to be up to date before merging.
126 | strict: true
127 | # Required. The list of status checks to require in order to merge into this branch
128 | contexts: [ ]
129 | # Required. Enforce all configured restrictions for administrators. Set to true to enforce required status checks for repository administrators. Set to null to disable.
130 | enforce_admins: false
131 | # Disabled for bors to work
132 | required_linear_history: false
133 | # Required. Restrict who can push to this branch. Team and user restrictions are only available for organization-owned repositories. Set to null to disable.
134 | restrictions:
135 | apps: [ ]
136 | users: []
137 | teams: []
138 |
--------------------------------------------------------------------------------
/.github/workflows/nix.yml:
--------------------------------------------------------------------------------
1 | name: Nix
2 | on:
3 | push:
4 | branches:
5 | - main
6 | - staging
7 | - trying
8 | pull_request:
9 | workflow_dispatch:
10 | jobs:
11 | build:
12 | strategy:
13 | matrix:
14 | os: [ ubuntu-20.04, ubuntu-22.04, macos-11, macos-12 ]
15 | runs-on: ${{ matrix.os }}
16 | steps:
17 | - uses: actions/checkout@v4
18 | - uses: cachix/install-nix-action@v30
19 | - uses: cachix/cachix-action@v15
20 | with:
21 | name: numtide
22 | authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
23 | - run: |
24 | export PRJ_ROOT=$PWD
25 | $(./shell.nix)/entrypoint --pure bash -c "echo OK"
26 | - run: nix-shell --run "echo OK"
27 | - run: nix-build
28 | flakes:
29 | strategy:
30 | matrix:
31 | os: [ ubuntu-20.04, ubuntu-22.04, macos-11, macos-12 ]
32 | runs-on: ${{ matrix.os }}
33 | steps:
34 | - uses: actions/checkout@v4
35 | with:
36 | # Nix Flakes doesn't work on shallow clones
37 | fetch-depth: 0
38 | - uses: cachix/install-nix-action@v30
39 | - uses: cachix/cachix-action@v15
40 | with:
41 | name: numtide
42 | authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
43 | - run: nix flake check
44 | - name: Run devshell entry sanity checks
45 | run: |
46 | nix develop -c echo OK
47 | for tmpl in ./templates/*; do
48 | if ! [ -d "$tmpl" ]; then
49 | continue
50 | fi
51 | nix develop --override-input devshell . "$tmpl" -c echo OK
52 | done
53 | - name: Run nix flake archive
54 | run: nix flake archive
55 | docs:
56 | strategy:
57 | matrix:
58 | os: [ ubuntu-20.04 ]
59 | runs-on: ${{ matrix.os }}
60 | steps:
61 | - uses: actions/checkout@v4
62 | - uses: cachix/install-nix-action@v30
63 | - uses: cachix/cachix-action@v15
64 | with:
65 | name: numtide
66 | authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
67 | - run: |
68 | nix-build -A docs
69 | cp -r "$(readlink ./result)" book
70 | - name: Deploy to GitHub Pages
71 | if: github.ref == 'refs/heads/main'
72 | uses: crazy-max/ghaction-github-pages@v4
73 | with:
74 | target_branch: gh-pages
75 | build_dir: book
76 | env:
77 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # go
2 | /devshell/devshell
3 |
4 | # mdbook
5 | /result
6 | /book
7 |
8 | # goreleaser
9 | /dist
10 |
11 | # direnv
12 | /.direnv
13 |
--------------------------------------------------------------------------------
/.goreleaser.yml:
--------------------------------------------------------------------------------
1 | # Visit https://goreleaser.com for documentation on how to customize this
2 | # behavior.
3 | before:
4 | hooks:
5 | - bash -c "cd devshell && go mod download"
6 | builds:
7 | - env:
8 | - CGO_ENABLED=0
9 | mod_timestamp: '{{ .CommitTimestamp }}'
10 | dir: devshell
11 | goos:
12 | - darwin
13 | - freebsd
14 | - linux
15 | goarch:
16 | - '386'
17 | - amd64
18 | - arm
19 | - arm64
20 | ignore:
21 | - goos: darwin
22 | goarch: '386'
23 | signs:
24 | - artifacts: checksum
25 | args:
26 | # if you are using this is a GitHub action or some other automated pipeline, you
27 | # need to pass the batch flag to indicate its not interactive.
28 | - "--batch"
29 | - "--local-user"
30 | - "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
31 | - "--output"
32 | - "${signature}"
33 | - "--detach-sign"
34 | - "${artifact}"
35 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | // See https://go.microsoft.com/fwlink/?LinkId=733558
3 | // for the documentation about the tasks.json format
4 | "version": "2.0.0",
5 | "tasks": [
6 | {
7 | "label": "Build & Serve docs",
8 | "type": "shell",
9 | "command": "docs/serve.sh",
10 | "problemMatcher": []
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Numtide and contributors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # devshell - like virtualenv, but for all the languages
2 |
3 |
STATUS: unstable
4 |
5 | [](https://github.com/numtide/devshell) [](https://matrix.to/#/#devshell:numtide.com)
6 |
7 | The goal of this project is to simplify per-project developer environments.
8 |
9 | Imagine, a new employee joins the company, or somebody transfers teams, or
10 | somebody wants to contribute to one of your Open Source projects. It
11 | should take them 10 minutes to clone the repo and get all of the development
12 | dependencies.
13 |
14 | ## Documentation
15 |
16 | See [docs](https://numtide.github.io/devshell/) ([docs source](docs))
17 |
18 | ## Features
19 |
20 | ### Compatible
21 |
22 | Keep it compatible with:
23 |
24 | * nix-shell
25 | * direnv
26 | * nix flakes
27 |
28 | ### Clean environment
29 |
30 | `pkgs.stdenv.mkDerivation` and `pkgs.mkShell` build on top of the
31 | `pkgs.stdenv` which introduces all sort of dependencies. Each added package,
32 | like the `pkgs.go` in the "Story time!" section has the potential of adding
33 | new environment variables, which then need to be unset. The `stdenv` itself
34 | contains either GCC or Clang which makes it hard to select a specific C
35 | compiler.
36 |
37 | This is why `mkShell` builds its environment from a `builtins.derivation`.
38 |
39 | direnv loads will change from:
40 |
41 | ```sh
42 | direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +HOST_PATH +IN_NIX_SHELL +LD +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_BUILD_CORES +NIX_BUILD_TOP +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_INDENT_MAKE +NIX_LDFLAGS +NIX_STORE +NM +OBJCOPY +OBJDUMP +RANLIB +READELF +RUSTC +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +TEMP +TEMPDIR +TMP +TMPDIR +buildInputs +buildPhase +builder +builtDependencies +cargo_bins_jq_filter +cargo_build_options +cargo_options +cargo_release +cargo_test_options +cargoconfig +checkPhase +configureFlags +configurePhase +cratePaths +crate_sources +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +docPhase +dontAddDisableDepTrack +dontUseCmakeConfigure +installPhase +name +nativeBuildInputs +out +outputs +patches +preInstallPhases +propagatedBuildInputs +propagatedNativeBuildInputs +remapPathPrefix +shell +src +stdenv +strictDeps +system +version ~PATH
43 | ```
44 |
45 | to:
46 |
47 | ```sh
48 | direnv: export +DEVSHELL_DIR +PRJ_DATA_DIR +PRJ_ROOT +IN_NIX_SHELL +NIXPKGS_PATH ~PATH
49 | ```
50 |
51 | There are new environment variables useful to support the day-to-day
52 | activities:
53 |
54 | * `DEVSHELL_DIR`: contains all the programs.
55 | * `PRJ_ROOT`: points to the project root.
56 | * `PRJ_DATA_DIR`: points to `$PRJ_ROOT/.data` by default. Is used to store runtime data.
57 | * `NIXPKGS_PATH`: path to `nixpkgs` source.
58 |
59 | ### Common utilities
60 |
61 | The shell comes pre-loaded with some utility functions. I'm not 100% sure if
62 | those are useful yet:
63 |
64 | * `menu` - list all the programs available
65 |
66 | ### MOTD
67 |
68 | When entering a random project, it's useful to get a quick view of what
69 | commands are available.
70 |
71 | When running `nix-shell` or `nix develop`, `mkShell` prints a welcome message:
72 |
73 | ```sh
74 | 🔨 Welcome to devshell
75 |
76 | [[general commands]]
77 |
78 | hello - prints hello
79 | menu - prints this menu
80 |
81 | [formatters]
82 |
83 | nixpkgs-fmt - Nix code formatter for nixpkgs
84 |
85 | [linters]
86 |
87 | golangci-lint - golang linter
88 |
89 | [utilites]
90 |
91 | hub - github utility
92 |
93 | [devshell]$
94 | ```
95 |
96 | ### Configurable with a TOML file
97 |
98 | You might be passionate about Nix, but people on the team might be afraid of
99 | that non-mainstream technology. So let them write TOML instead. It should
100 | handle 80% of the use-cases and falling back on Nix is always possible.
101 |
102 | ### Bash completion by default
103 |
104 | Life is not complete otherwise. Huhu.
105 |
106 | Packages that contain bash completions will automatically be loaded by
107 | `mkShell` in `nix-shell` or `nix develop` modes.
108 |
109 | ### Capture development dependencies in CI
110 |
111 | With a CI + Binary cache setup, one often wants to be able to capture all the
112 | build inputs of a `shell.nix`. With `mkShell` capturing all of the
113 | development dependencies is as easy as:
114 |
115 | ```sh
116 | nix-build shell.nix | cachix push
117 | ```
118 |
119 | ### Runnable as a Nix application
120 |
121 | Devshells are runnable (via `nix run`). This makes it possible to run commands defined in your devshell without entering a `nix-shell` or `nix develop` session:
122 |
123 | ```sh
124 | nix run '.#' --
125 | ```
126 |
127 | This project itself exposes a Nix application; you can try it out with:
128 |
129 | ```sh
130 | nix run 'github:numtide/devshell' -- hello
131 | ```
132 |
133 | See [here](docs/src/flake-app.md) for more details.
134 |
135 | ## TODO
136 |
137 | A lot of things!
138 |
139 | * **Documentation**
140 | * Explain how all of this works and all the use-cases.
141 | * **Testing**
142 | * Write integration tests for all of the use-cases.
143 | * **Lazy dependencies**
144 | * This requires some coordination with the repository structure. To keep the
145 | dev closure small, it would be nice to be able to load some of the
146 | dependencies on demand.
147 | * **Doctor / nix version check**
148 | * Not everything can be nicely sandboxed. Is it possible to get a fast doctor
149 | script that checks that everything is in good shape?
150 | * **Support other shells**
151 | * What? Not everyone is using bash? Right now, support is already available in
152 | direnv mode.
153 |
154 | ## Contributing
155 |
156 | ### Docs
157 |
158 | 1. Change files in `docs/`
159 | 1. Run `nix run .#docs`
160 | 1. Open [`docs`](http://localhost:3000/index.html)
161 |
162 | ### Benchmark
163 |
164 | 1. See [benchmark/README.md](./benchmark/README.md)
165 | 1. Run `nix run .#bench`
166 |
167 | ## Commercial support
168 |
169 | Looking for help or customization?
170 |
171 | Get in touch with Numtide to get a quote. We make it easy for companies to
172 | work with Open Source projects:
173 |
--------------------------------------------------------------------------------
/benchmark/README.md:
--------------------------------------------------------------------------------
1 | # Benchmarking devshell evaluation
2 |
3 | devshell is built on top of nix, and the nixpkgs module system, which can take
4 | quite a while to evaluate.
5 |
6 | ## Hyperfine
7 |
8 | Command:
9 |
10 | ```console
11 | nix run .#bench
12 | ```
13 |
14 | Output:
15 |
16 | ```console
17 | Benchmark 1: nix-instantiate ../shell.nix
18 | Time (mean ± σ): 568.2 ms ± 18.0 ms [User: 486.2 ms, System: 81.1 ms]
19 | Range (min … max): 544.5 ms … 596.0 ms 10 runs
20 |
21 | Benchmark 2: nix-instantiate ./devshell-nix.nix
22 | Time (mean ± σ): 189.6 ms ± 11.8 ms [User: 150.1 ms, System: 38.6 ms]
23 | Range (min … max): 177.8 ms … 221.0 ms 13 runs
24 |
25 | Benchmark 3: nix-instantiate ./devshell-toml.nix
26 | Time (mean ± σ): 194.0 ms ± 7.4 ms [User: 155.1 ms, System: 38.8 ms]
27 | Range (min … max): 181.4 ms … 214.5 ms 15 runs
28 |
29 | Benchmark 4: nix-instantiate ./nixpkgs-mkshell.nix
30 | Time (mean ± σ): 148.9 ms ± 4.7 ms [User: 118.3 ms, System: 30.3 ms]
31 | Range (min … max): 143.7 ms … 164.6 ms 20 runs
32 |
33 | Summary
34 | nix-instantiate ./nixpkgs-mkshell.nix ran
35 | 1.27 ± 0.09 times faster than nix-instantiate ./devshell-nix.nix
36 | 1.30 ± 0.06 times faster than nix-instantiate ./devshell-toml.nix
37 | 3.82 ± 0.17 times faster than nix-instantiate ../shell.nix
38 | ```
39 |
40 | ## Nix stats
41 |
42 | ### repo shell
43 |
44 | Command:
45 |
46 | ```console
47 | NIX_SHOW_STATS=1 nix-instantiate ../shell.nix 2>&1
48 | ```
49 |
50 | Output:
51 |
52 | ```console
53 | warning: you did not specify '--add-root'; the result might be removed by the garbage collector
54 | /nix/store/6vha60nh201fd5m36nphysmsrvvk0zq0-devshell.drv
55 | {
56 | "cpuTime": 0.42238301038742065,
57 | "envs": {
58 | "bytes": 17234184,
59 | "elements": 879269,
60 | "number": 637502
61 | },
62 | "gc": {
63 | "heapSize": 402915328,
64 | "totalBytes": 116416656
65 | },
66 | "list": {
67 | "bytes": 2528832,
68 | "concats": 28933,
69 | "elements": 316104
70 | },
71 | "nrAvoided": 869773,
72 | "nrFunctionCalls": 574722,
73 | "nrLookups": 387457,
74 | "nrOpUpdateValuesCopied": 2237754,
75 | "nrOpUpdates": 54186,
76 | "nrPrimOpCalls": 405710,
77 | "nrThunks": 958406,
78 | "sets": {
79 | "bytes": 46573200,
80 | "elements": 2771910,
81 | "number": 138915
82 | },
83 | "sizes": {
84 | "Attr": 16,
85 | "Bindings": 16,
86 | "Env": 16,
87 | "Value": 24
88 | },
89 | "symbols": {
90 | "bytes": 551230,
91 | "number": 48261
92 | },
93 | "values": {
94 | "bytes": 28690080,
95 | "number": 1195420
96 | }
97 | }
98 | ```
99 |
100 | ### devshell-nix
101 |
102 | Command:
103 |
104 | ```console
105 | NIX_SHOW_STATS=1 nix-instantiate ./devshell-nix.nix 2>&1
106 | ```
107 |
108 | Output:
109 |
110 | ```console
111 | warning: you did not specify '--add-root'; the result might be removed by the garbage collector
112 | /nix/store/6zlkfp88d1ic0zyw49kb8srnqbwz5277-devshell.drv
113 | {
114 | "cpuTime": 0.17254799604415894,
115 | "envs": {
116 | "bytes": 3515536,
117 | "elements": 175074,
118 | "number": 132184
119 | },
120 | "gc": {
121 | "heapSize": 402915328,
122 | "totalBytes": 39903680
123 | },
124 | "list": {
125 | "bytes": 580176,
126 | "concats": 3499,
127 | "elements": 72522
128 | },
129 | "nrAvoided": 192068,
130 | "nrFunctionCalls": 116933,
131 | "nrLookups": 56485,
132 | "nrOpUpdateValuesCopied": 1160535,
133 | "nrOpUpdates": 7873,
134 | "nrPrimOpCalls": 99486,
135 | "nrThunks": 274189,
136 | "sets": {
137 | "bytes": 22358832,
138 | "elements": 1364423,
139 | "number": 33004
140 | },
141 | "sizes": {
142 | "Attr": 16,
143 | "Bindings": 16,
144 | "Env": 16,
145 | "Value": 24
146 | },
147 | "symbols": {
148 | "bytes": 222375,
149 | "number": 23097
150 | },
151 | "values": {
152 | "bytes": 8141064,
153 | "number": 339211
154 | }
155 | }
156 | ```
157 |
158 | ### devshell-toml
159 |
160 | Command:
161 |
162 | ```console
163 | NIX_SHOW_STATS=1 nix-instantiate ./devshell-toml.nix 2>&1
164 | ```
165 |
166 | Output:
167 |
168 | ```console
169 | warning: you did not specify '--add-root'; the result might be removed by the garbage collector
170 | /nix/store/6zlkfp88d1ic0zyw49kb8srnqbwz5277-devshell.drv
171 | {
172 | "cpuTime": 0.14970900118350983,
173 | "envs": {
174 | "bytes": 3515888,
175 | "elements": 175092,
176 | "number": 132197
177 | },
178 | "gc": {
179 | "heapSize": 402915328,
180 | "totalBytes": 39907952
181 | },
182 | "list": {
183 | "bytes": 580248,
184 | "concats": 3498,
185 | "elements": 72531
186 | },
187 | "nrAvoided": 192084,
188 | "nrFunctionCalls": 116941,
189 | "nrLookups": 56497,
190 | "nrOpUpdateValuesCopied": 1160541,
191 | "nrOpUpdates": 7874,
192 | "nrPrimOpCalls": 99494,
193 | "nrThunks": 274209,
194 | "sets": {
195 | "bytes": 22359328,
196 | "elements": 1364444,
197 | "number": 33014
198 | },
199 | "sizes": {
200 | "Attr": 16,
201 | "Bindings": 16,
202 | "Env": 16,
203 | "Value": 24
204 | },
205 | "symbols": {
206 | "bytes": 222404,
207 | "number": 23100
208 | },
209 | "values": {
210 | "bytes": 8141856,
211 | "number": 339244
212 | }
213 | }
214 | ```
215 |
216 | ### nixpkgs-mkshell
217 |
218 | Command:
219 |
220 | ```console
221 | NIX_SHOW_STATS=1 nix-instantiate ./nixpkgs-mkshell.nix 2>&1
222 | ```
223 |
224 | Output:
225 |
226 | ```console
227 | warning: you did not specify '--add-root'; the result might be removed by the garbage collector
228 | /nix/store/53c78xjnkv3f7c87cwly5hgys1kbdjqv-nix-shell.drv
229 | {
230 | "cpuTime": 0.11669100075960159,
231 | "envs": {
232 | "bytes": 2552672,
233 | "elements": 126138,
234 | "number": 96473
235 | },
236 | "gc": {
237 | "heapSize": 402915328,
238 | "totalBytes": 34785856te ../shell.nix 2>&1
239 | ```
240 | },
241 | "list": {
242 | "bytes": 457816,
243 | "concats": 1927,
244 | "elements": 57227
245 | },
246 | "nrAvoided": 148098,
247 | "nrFunctionCalls": 85099,
248 | "nrLookups": 35864,
249 | "nrOpUpdateValuesCopied": 1078888,
250 | "nrOpUpdates": 5237,
251 | "nrPrimOpCalls": 79444,
252 | "nrThunks": 230270,
253 | "sets": {
254 | "bytes": 20572560,
255 | "elements": 1261476,
256 | "number": 24309
257 | },
258 | "sizes": {
259 | "Attr": 16,
260 | "Bindings": 16,
261 | "Env": 16,
262 | "Value": 24
263 | },
264 | "symbols": {
265 | "bytes": 218655,
266 | "number": 22549
267 | },
268 | "values": {
269 | "bytes": 6839184,
270 | "number": 284966
271 | }
272 | }
273 | ```
274 |
--------------------------------------------------------------------------------
/benchmark/devshell-nix.nix:
--------------------------------------------------------------------------------
1 | {
2 | system ? builtins.currentSystem,
3 | }:
4 | let
5 | devshell = import ../. { inherit system; };
6 | in
7 | devshell.mkShell { }
8 |
--------------------------------------------------------------------------------
/benchmark/devshell-toml.nix:
--------------------------------------------------------------------------------
1 | {
2 | system ? builtins.currentSystem,
3 | }:
4 | let
5 | devshell = import ../. { inherit system; };
6 | in
7 | devshell.fromTOML ./devshell-toml.toml
8 |
--------------------------------------------------------------------------------
/benchmark/devshell-toml.toml:
--------------------------------------------------------------------------------
1 | # Empty TOML
2 | [devshell]
3 |
--------------------------------------------------------------------------------
/benchmark/nixpkgs-mkshell.nix:
--------------------------------------------------------------------------------
1 | {
2 | system ? builtins.currentSystem,
3 | }:
4 | let
5 | pkgs = import (import ../nix/nixpkgs.nix) { inherit system; };
6 | in
7 | pkgs.mkShell { }
8 |
--------------------------------------------------------------------------------
/default.nix:
--------------------------------------------------------------------------------
1 | {
2 | system ? builtins.currentSystem,
3 | inputs ? import ./flake.lock.nix { },
4 | nixpkgs ? import inputs.nixpkgs {
5 | inherit system;
6 | # Makes the config pure as well. See /top-level/impure.nix:
7 | config = { };
8 | overlays = [ ];
9 | },
10 | }:
11 | let
12 | # Build a list of all the files, imported as Nix code, from a directory.
13 | importTree =
14 | dir:
15 | let
16 | data = builtins.readDir dir;
17 | op =
18 | sum: name:
19 | let
20 | path = "${dir}/${name}";
21 | type = data.${name};
22 | in
23 | sum
24 | ++ (
25 | if type == "regular" then
26 | [ path ]
27 | # assume it's a directory
28 | else
29 | importTree path
30 | );
31 | in
32 | builtins.foldl' op [ ] (builtins.attrNames data);
33 | in
34 | rec {
35 | # Folder that contains all the extra modules
36 | extraModulesPath = toString ./extra;
37 |
38 | # Alias for backward compatibility.
39 | extraModulesDir = extraModulesPath;
40 |
41 | # Get the modules documentation from an empty evaluation
42 | modules-docs =
43 | (eval {
44 | configuration = {
45 | # Load all of the extra modules so they appear in the docs
46 | imports = importTree extraModulesPath;
47 | };
48 | }).config.modules-docs;
49 |
50 | # Docs
51 | docs = nixpkgs.callPackage ./docs { inherit modules-docs; };
52 |
53 | # Tests
54 | tests = import ./tests {
55 | inherit system;
56 | inputs = null;
57 | pkgs = nixpkgs;
58 | };
59 |
60 | # Evaluate the devshell module
61 | eval = import ./modules nixpkgs;
62 |
63 | importTOML = import ./nix/importTOML.nix;
64 |
65 | # Build the devshell from a TOML declaration.
66 | fromTOML = path: mkShell (importTOML path);
67 |
68 | # A utility to build a "naked" nix-shell environment that doesn't contain
69 | # all of the default environment variables. This is mostly for internal use.
70 | mkNakedShell = nixpkgs.callPackage ./nix/mkNakedShell.nix { };
71 |
72 | # A developer shell that works in all scenarios
73 | #
74 | # * nix-build
75 | # * nix-shell
76 | # * flake app
77 | # * direnv integration
78 | # * setup hook for derivation or hercules ci effect
79 | mkShell = configuration: (eval { inherit configuration; }).shell;
80 | }
81 |
--------------------------------------------------------------------------------
/devshell.toml:
--------------------------------------------------------------------------------
1 | imports = [
2 | "language.go"
3 | ]
4 |
5 | [devshell]
6 | # This is the name of your environment. It should usually map to the project
7 | # name.
8 | name = "devshell"
9 |
10 | # Message Of The Day (MOTD) is displayed when entering the environment with an
11 | # interactive shell. By default it will show the project name.
12 | #
13 | # motd = ""
14 |
15 | # Add packages from nixpkgs here. Use `nix search nixpkgs ` to find the
16 | # package that you need.
17 | #
18 | # NOTE: don't forget to put commas between items! :)
19 | packages = [
20 | "diffutils", # used by golangci-lint
21 | "goreleaser",
22 | "mdbook",
23 | "mdsh",
24 | "webfs",
25 | "hyperfine",
26 | ]
27 |
28 | # Expose all the dependencies from a package to the environment.
29 | packagesFrom = [
30 | "direnv"
31 | ]
32 |
33 | # Declare commands that are available in the environment.
34 | [[commands]]
35 | help = "prints hello"
36 | name = "hello"
37 | command = "echo hello"
38 |
39 | [[commands]]
40 | package = "nixpkgs-fmt"
41 | category = "formatters"
42 |
43 | [[commands]]
44 | help = "github utility"
45 | name = "hub"
46 | package = "gitAndTools.hub"
47 | category = "utilites"
48 |
49 | [[commands]]
50 | help = "golang linter"
51 | package = "golangci-lint"
52 | category = "linters"
53 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | book
--------------------------------------------------------------------------------
/docs/book.toml:
--------------------------------------------------------------------------------
1 | [book]
2 | authors = ["zimbatm"]
3 | language = "en"
4 | multilingual = false
5 | src = "src"
6 | title = "devshell"
7 |
8 | [output.html]
9 | # Show github links in top bar
10 | git-repository-url = "https://github.com/numtide/devshell"
11 | edit-url-template = "https://github.com/numtide/devshell/edit/main/docs/{path}"
12 | additional-css = ["theme/pagetoc.css"]
13 | additional-js = ["theme/pagetoc.js"]
--------------------------------------------------------------------------------
/docs/default.nix:
--------------------------------------------------------------------------------
1 | {
2 | mdbook,
3 | modules-docs,
4 | stdenv,
5 | lib,
6 | }:
7 | with lib;
8 | stdenv.mkDerivation {
9 | name = "devshell-docs";
10 | buildInputs = [ mdbook ];
11 | src =
12 | let
13 | fs = lib.fileset;
14 | in
15 | fs.toSource {
16 | root = ./.;
17 | fileset = fs.unions [
18 | (fs.fileFilter (file: file.hasExt "md") ./src)
19 | ./book.toml
20 | ./theme
21 | ];
22 | };
23 |
24 | buildPhase = ''
25 | cp ${modules-docs.markdown} src/modules_schema.md
26 | mdbook build
27 | '';
28 |
29 | installPhase = ''
30 | mv book $out
31 | '';
32 | }
33 |
--------------------------------------------------------------------------------
/docs/src/99_todo.md:
--------------------------------------------------------------------------------
1 | # TODO
2 |
3 | * How to add a new dependency
4 | * Using with CI
5 | * Extending devshell
6 | * Contributing
7 |
--------------------------------------------------------------------------------
/docs/src/SUMMARY.md:
--------------------------------------------------------------------------------
1 | # Summary
2 |
3 | - [Intro](./intro.md)
4 | - [Getting started](./getting_started.md)
5 | - [Continuous Integration setup](./ci.md)
6 | - [Extending devshell](./extending.md)
7 | - [devshell.toml schema](./modules_schema.md)
8 | - [env vars](./env.md)
9 | - [TODO](./99_todo.md)
10 |
11 |
--------------------------------------------------------------------------------
/docs/src/ci.md:
--------------------------------------------------------------------------------
1 | # Continuous Integration setup (CI)
2 |
3 | Traditionally, the CI build environment has to be kept in sync with the
4 | project. If the project needs `make` to build, the CI has to be configured to
5 | have it available. This can become quite tricky whenever a version requirement
6 | changes.
7 |
8 | With devshell, the only dependency is Nix. Once the devshell is built, all the
9 | dependencies are loaded into scope and automatically are in sync with the
10 | current code checkout.
11 |
12 | ## General approach
13 |
14 | The only dependency we need installed in the CI environment is Nix.
15 |
16 | Assuming that the `shell.nix` file exists, the general approach is to build it
17 | with nix to get back the entrypoint script. And then executed that script with
18 | the commands.
19 |
20 | For example, let's say that `make` is being used to build the project.
21 |
22 | The `devshell.toml` would have it as part of its commands:
23 | ```toml
24 | [[commands]]
25 | package = "gnumake"
26 | ```
27 |
28 | All the CI has to do, is this: `nix-shell --run "$(nix-build shell.nix)/entrypoint make"`.
29 |
30 | 1. `$(nix-build shell.nix)/entrypoint` outputs a path to the entrypoint script
31 | 1. `nix-shell --run` sets the required environment variables for the entrypoint script to work.
32 | 2. The entrypoint script is executed with `make` as an argument. It loads the
33 | environment.
34 | 3. Finally make is executed in the context of the project environment, with
35 | all the same dependencies as the developer's.
36 |
37 | ## Hercules CI
38 |
39 | [Hercules CI](https://hercules-ci.com) is a Nix-based continuous integration and deployment service.
40 |
41 | ### Build
42 |
43 | If you haven't packaged your project with Nix or if a check can't run in the Nix sandbox, you can run it as an [effect](https://docs.hercules-ci.com/hercules-ci/effects/).
44 |
45 | `ci.nix`
46 | ```
47 | let
48 | shell = import ./shell.nix {};
49 | pkgs = shell.pkgs;
50 | effectsSrc =
51 | builtins.fetchTarball "https://github.com/hercules-ci/hercules-ci-effects/archive/COMMIT_HASH.tar.gz";
52 | inherit (import effectsSrc { inherit pkgs; }) effects;
53 | in
54 | {
55 | inherit shell;
56 | build = effects.mkEffect {
57 | src = ./.;
58 | effectScript = ''
59 | go build
60 | '';
61 | inputs = [
62 | shell.hook
63 | ];
64 | };
65 | }
66 | ```
67 |
68 | Replace COMMIT_HASH by the latest git sha from [`hercules-ci-effects`](https://github.com/hercules-ci/hercules-ci-effects/commit/master),
69 | or, if you prefer, you can bring `effects` into scope [using another pinning method](https://docs.hercules-ci.com/hercules-ci-effects/guide/import-or-pin/).
70 |
71 | ### Run locally
72 |
73 | The [`hci` command](https://docs.hercules-ci.com/hercules-ci-agent/hci/) is available in `nixos-21.05` and `nixos-unstable`.
74 |
75 | `devshell.toml`
76 | ```
77 | [[commands]]
78 | package = "hci"
79 | ```
80 |
81 | Use [`hci effect run`](https://docs.hercules-ci.com/hercules-ci-agent/hci/). Following the previous example:
82 |
83 | ```console
84 | hci effect run build --no-token
85 | ```
86 |
87 | ### Shell only
88 |
89 | To build the shell itself on `x86_64-linux`:
90 |
91 | `ci.nix`
92 | ```
93 | {
94 | shell = import ./shell.nix {};
95 |
96 | # ... any extra Nix packages you want to build; perhaps
97 | # pkgs = import ./default.nix {} // { recurseForDerivations = true; };
98 | }
99 | ```
100 |
101 | ### `system`
102 |
103 | If you build for [multiple systems](https://docs.hercules-ci.com/hercules-ci/guides/multi-platform/), pass `system`:
104 |
105 | ```
106 | import ./shell.nix { inherit system; };
107 | ```
108 |
109 | ## GitHub Actions
110 |
111 | Add the following file to your project. Replace the ``
112 | part with whatever is needed to build the project.
113 |
114 | `.github/workflows/devshell.yml`
115 | ```yaml
116 | name: devshell
117 | on:
118 | push:
119 | branches:
120 | - master
121 | pull_request:
122 | workflow_dispatch:
123 | jobs:
124 | build:
125 | strategy:
126 | matrix:
127 | os: [ ubuntu-20.04, macos-latest ]
128 | runs-on: ${{ matrix.os }}
129 | steps:
130 | - uses: actions/checkout@v2
131 | - uses: cachix/install-nix-action@v12
132 | - uses: cachix/cachix-action@v8
133 | with:
134 | name: ""
135 | signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
136 | - run: |
137 | source "$(nix-build shell.nix)"
138 |
139 | ```
140 |
141 | ## TODO
142 |
143 | Add more CI-specific examples.
144 |
145 |
--------------------------------------------------------------------------------
/docs/src/env.md:
--------------------------------------------------------------------------------
1 | # Env vars
2 |
3 | This section describes a few environment variables that can influence the
4 | behaviour of devshell.
5 |
6 | ## `DEVSHELL_NO_MOTD=1`
7 |
8 | When that variable is set, devshell will not display the menu that is executed
9 | on entrypoint.
10 |
--------------------------------------------------------------------------------
/docs/src/extending.md:
--------------------------------------------------------------------------------
1 | # Extending devshell
2 |
3 | When the base modules that are provided by devshell are not enough, it is
4 | possible to extend it.
5 |
6 | ## Extra modules
7 |
8 | All the `devshell.toml` schema options that are `Declared in:` the `extra/`
9 | folder in the schema documentation are loaded on demand.
10 |
11 | In order to load an extra module, use the `` in the import section. For
12 | example to make the `locale` options available, import `locale`:
13 |
14 | `devshell.toml`:
15 | ```toml
16 | imports = ["locale"]
17 | ```
18 |
19 | Make sure to add this at the first statement in the file.
20 |
21 | Now that the module has been loaded, the `devshell.toml` understands the
22 | `locale` prefix:
23 |
24 | ```toml
25 | imports = ["locale"]
26 |
27 | [locale]
28 | lang = "en_US.UTF-8"
29 | ```
30 |
31 | From a nix flake you would import it like
32 |
33 | ```nix
34 | devshell.mkShell ({ extraModulesPath, ... }: {
35 | imports = ["${extraModulesPath}/locale.nix"];
36 | })
37 | ```
38 |
39 | ## Building your own modules
40 |
41 | Building your own modules requires to understand the Nix language. If
42 | this is too complicated, please reach out to the issue tracker and describe
43 | your use-case. We want to be able to support a wide variety of development
44 | scenario.
45 |
46 | In the same way as previously introduced, devshell will also load files that
47 | are relative to the `devshell.toml`. For example:
48 |
49 | ```toml
50 | imports = ["mymodule.nix"]
51 | ```
52 |
53 | Will load the `mymodule.nix` file in the project repository and extend the
54 | `devshell.toml` schema accordingly.
55 |
--------------------------------------------------------------------------------
/docs/src/flake-app.md:
--------------------------------------------------------------------------------
1 | # Using a devshell as a Nix package
2 |
3 | Devshells can be treated as executable packages. This allows running commands inside a devshell's environment without having to enter it first via `nix-shell` or `nix develop`.
4 |
5 | Each devshell in a flake can be executed using nix run:
6 | ```sh
7 | nix run '.#devShells..' --
8 | ```
9 |
10 | To simplify this command further, re-expose the devshell under `packages..`. This allows running it like this:
11 |
12 | ```sh
13 | nix run '.#' --
14 | ```
15 |
16 | For example, given the following `flake.nix`:
17 |
18 | ```nix
19 | {
20 | inputs.devshell.url = "github:numtide/devshell";
21 | inputs.flake-utils.url = "github:numtide/flake-utils";
22 |
23 | outputs = { self, flake-utils, devshell, nixpkgs }:
24 | flake-utils.lib.eachDefaultSystem (system: {
25 | packages.devshell = self.outputs.devShells.${system}.default;
26 |
27 | devShells.default =
28 | let
29 | pkgs = import nixpkgs {
30 | inherit system;
31 |
32 | overlays = [ devshell.overlays.default ];
33 | };
34 | in
35 | pkgs.devshell.mkShell ({ config, ... }: {
36 | commands = [
37 | {
38 | name = "greet";
39 | command = ''
40 | printf -- 'Hello, %s!\n' "''${1:-world}"
41 | '';
42 | }
43 | ];
44 | });
45 | });
46 | }
47 | ```
48 |
49 | You can execute your devshell's `greet` command like this:
50 |
51 | ```console
52 | $ nix run '.#devshell' -- greet myself
53 | Hello, myself!
54 | ```
55 |
56 | ## Setting `PRJ_ROOT`
57 |
58 | By default, the `PRJ_ROOT` environment variable is set to the value of the
59 | `PWD` environment variable. You can override this by defining `PRJ_ROOT` in
60 | `nix run`'s environment:
61 |
62 | ```sh
63 | PRJ_ROOT=/some/where/else nix run '.#' --
64 | ```
65 |
66 | You can also use the `--prj-root` option:
67 |
68 | ```sh
69 | nix run '.#' -- --prj-root /yet/another/path --
70 | ```
71 |
--------------------------------------------------------------------------------
/docs/src/getting_started.md:
--------------------------------------------------------------------------------
1 | # Getting started
2 |
3 | This project has a single dependency; Nix. It will be used to pull in all
4 | other dependencies. It can be installed by following the instructions
5 | over there: https://nixos.org/download.html#nix-quick-install
6 |
7 | Now that's done, got to your project root and create an empty `devshell.toml`.
8 |
9 | There are different ways to load that config depending on your preferences:
10 |
11 | ### Nix (non-flake)
12 |
13 | Add another file called `shell.nix` with the following content. This file will
14 | contain some nix code. Don't worry about the details.
15 |
16 | ```nix
17 | { system ? builtins.currentSystem }:
18 | let
19 | src = fetchTarball "https://github.com/numtide/devshell/archive/main.tar.gz";
20 | devshell = import src { inherit system; };
21 | in
22 | devshell.fromTOML ./devshell.toml
23 | ```
24 |
25 | > NOTE: it's probably a good idea to pin the dependency by replacing `main` with a git commit ID.
26 |
27 | Now you can enter the developer shell for the project:
28 |
29 | ```console
30 | $ nix-shell
31 | warning: you did not specify '--add-root'; the result might be removed by the garbage collector
32 | these 4 derivations will be built:
33 | /nix/store/nvbfq9h68r63k5jkfnbimny3b35sx0fs-devshell-bashrc.drv
34 | /nix/store/ppfyf9zv023an8477hcbjlj0rbyvmwq7-devshell.env.drv
35 | /nix/store/8027cgy3xcinb59aaynh899q953dnzms-devshell-bin.drv
36 | /nix/store/w33zl180ni880p18sls5ykih88zkmkqk-devshell.drv
37 | building '/nix/store/nvbfq9h68r63k5jkfnbimny3b35sx0fs-devshell-bashrc.drv'...
38 | building '/nix/store/ppfyf9zv023an8477hcbjlj0rbyvmwq7-devshell-env.drv'...
39 | created 1 symlinks in user environment
40 | building '/nix/store/8027cgy3xcinb59aaynh899q953dnzms-devshell-bin.drv'...
41 | building '/nix/store/w33zl180ni880p18sls5ykih88zkmkqk-devshell.drv'...
42 | warning: you did not specify '--add-root'; the result might be removed by the garbage collector
43 | 🔨 Welcome to devshell
44 |
45 | [general commands]
46 |
47 | menu - prints this menu
48 |
49 | [devshell]$
50 | ```
51 |
52 | ### Nix Flakes
53 | For users of nix flakes, a default template is provided to get you up and
54 | running.
55 |
56 | ```sh
57 | nix flake new -t "github:numtide/devshell" project/
58 |
59 | cd project/
60 |
61 | # enter the shell
62 | nix develop # or `direnv allow` if you want to use direnv
63 | ```
64 |
65 | Find `templates/gettingStartedExample` in this repository for a working example of the additional configuration below: `env`, `packages`, and `serviceGroups`.
66 |
67 | ## Adding environment variables
68 |
69 | Environment variables that are specific to the project can be added with the
70 | `[[env]]` declaration. Each environment variable is an entry in an array, and
71 | will be set in the order that they are declared.
72 |
73 | Eg:
74 |
75 | ```toml
76 | [[env]]
77 | name = "GO111MODULE"
78 | value = "on"
79 | ```
80 |
81 | There are different ways to set the environment variables. Look at the schema
82 | to find all the ways. But in short:
83 | * Use the `value` key to set a fixed env var.
84 | * Use the `eval` key to evaluate the value. This is useful when one env var
85 | depends on the value of another.
86 | * Use the `prefix` key to prepend a path to an environment variable that uses
87 | the path separator. Like `PATH`.
88 |
89 | ## Adding new commands
90 |
91 | Devshell also supports adding new commands to the environment. Those are
92 | displayed on devshell entry so that the user knows what commands are available
93 | to them.
94 |
95 | In order to bring in new dependencies, you can either add them to
96 | `devshell.packages` or as an entry in the `[[commands]]` list (see [TOML docs](https://toml.io/en/v1.0.0#array-of-tables)). Commands are also added to the
97 | menu so they might be preferable for discoverability.
98 |
99 | As an exercise, add the following snippet to your `devshell.toml`:
100 |
101 | ```toml
102 | [[commands]]
103 | package = "go"
104 | ```
105 |
106 | Then re-enter the shell with `nix-shell`/`nix develop`/`direnv reload`. You should see something like this:
107 |
108 | ```console
109 | $ nix-shell
110 | warning: you did not specify '--add-root'; the result might be removed by the garbage collector
111 | these 4 derivations will be built:
112 | /nix/store/nvbfq9h68r63k5jkfnbimny3b35sx0fs-devshell-bashrc.drv
113 | /nix/store/ppfyf9zv023an8477hcbjlj0rbyvmwq7-devshell.env.drv
114 | /nix/store/8027cgy3xcinb59aaynh899q953dnzms-devshell-bin.drv
115 | /nix/store/w33zl180ni880p18sls5ykih88zkmkqk-devshell.drv
116 | building '/nix/store/nvbfq9h68r63k5jkfnbimny3b35sx0fs-devshell-bashrc.drv'...
117 | building '/nix/store/ppfyf9zv023an8477hcbjlj0rbyvmwq7-devshell-env.drv'...
118 | created 1 symlinks in user environment
119 | building '/nix/store/8027cgy3xcinb59aaynh899q953dnzms-devshell-bin.drv'...
120 | building '/nix/store/w33zl180ni880p18sls5ykih88zkmkqk-devshell.drv'...
121 | warning: you did not specify '--add-root'; the result might be removed by the garbage collector
122 | 🔨 Welcome to devshell
123 |
124 | [general commands]
125 |
126 | menu - prints this menu
127 | go - The Go Programming language
128 |
129 | [devshell]$
130 | ```
131 |
132 | Now the `go` program is available in the environment and can be used to
133 | develop Go programs. This can easily be adapted to any language.
134 |
135 | Similarly, you could also add go to the packages list, in which case it would
136 | not appear in the menu:
137 |
138 | ```toml
139 | [devshell]
140 | packages = [
141 | "go"
142 | ]
143 | ```
144 |
145 | ### Finding packages
146 |
147 | Check out the [Nix package repository](https://search.nixos.org/packages).
148 |
149 | Note that it is also possible to **use specific versions** for some packages - e.g. for NodeJS, [search the repo](https://search.nixos.org/packages?type=packages&query=nodejs) & use like this:
150 | ```toml
151 | [[commands]]
152 | package = "nodejs-17_x" # https://search.nixos.org/packages?type=packages&query=nodejs
153 | name = "node"
154 | help = "NodeJS"
155 | ```
156 |
157 | Or another example:
158 | ```toml
159 | [devshell]
160 | packages = [
161 | "python27", # 2.7
162 | "python311", # 3.11
163 | ]
164 | ```
165 |
166 |
167 | ## Adding background services
168 |
169 | Many projects need background services to be running during development or to
170 | run tests (e.g. a database, caching server, webserver, ...). This is supported
171 | in devshell through the concept of service groups.
172 |
173 | A service group defines a collection of long-running processes that can be
174 | started and stopped.
175 |
176 | An example service group could be configured like this:
177 | ```toml
178 | [serviceGroups.database]
179 | description = "Runs a database in the backgroup"
180 | [serviceGroups.database.services.postgres]
181 | command = "postgres"
182 | [serviceGroups.database.services.memcached]
183 | command = "memcached"
184 | ```
185 |
186 | This will add two commands to the devshell: `database:start` and
187 | `database:stop`. `database:start` starts the defined services in the `database`
188 | group in the foreground and shows their output. `database:stop` can be executed
189 | in a different shell to stop the processes (or press Ctrl-C in the main shell).
190 |
191 | ## Wrapping up
192 |
193 | **devshell** is extensible in many different ways. In the next chapters we will
194 | discuss the various ways in which it can be adapted to your project's needs.
195 |
--------------------------------------------------------------------------------
/docs/src/intro.md:
--------------------------------------------------------------------------------
1 | # Introducing Devshell: like virtualenv, for every language
2 |
3 | **STATUS: unstable**
4 |
5 | It should not take more than 10 minutes from the time you clone a repo and can
6 | start contributing.
7 |
8 | Unfortunately, an unbounded amount of time is usually spent installing build
9 | dependencies on the system. If you are lucky, it's a pure $LANG project and
10 | all it takes is to install that language and its dedicated package manager. On
11 | bigger projects it's quite common to need more than one language to be
12 | installed. The side-effect of that is that it creates silos withing companies,
13 | and less contributors in the open-source world.
14 |
15 | It should be possible to run a single command that loads and makes those
16 | dependencies available to the developer.
17 |
18 | And it should keep the scope of these dependencies at the project level, just
19 | like virtualenv.
20 |
21 | These are the goals of this project.
22 |
--------------------------------------------------------------------------------
/docs/src/modules_schema.md:
--------------------------------------------------------------------------------
1 | ## Options
2 |
3 | ### `commands`
4 |
5 | Add commands to the environment.
6 |
7 | **Type**:
8 |
9 | ```console
10 | list of (submodule)
11 | ```
12 |
13 | **Default value**:
14 |
15 | ```nix
16 | [ ]
17 | ```
18 |
19 | **Example value**:
20 |
21 | ```nix
22 | [
23 | {
24 | help = "print hello";
25 | name = "hello";
26 | command = "echo hello";
27 | }
28 |
29 | {
30 | package = "nixpkgs-fmt";
31 | category = "formatter";
32 | }
33 | ]
34 | ```
35 |
36 | **Declared in**:
37 |
38 | - [modules/commands.nix](https://github.com/numtide/devshell/tree/main/modules/commands.nix)
39 |
40 | ### `commands.*.package`
41 |
42 | Used to bring in a specific package. This package will be added to the
43 | environment.
44 |
45 | **Type**:
46 |
47 | ```console
48 | null or (package or string convertible to it)
49 | ```
50 |
51 | **Default value**:
52 |
53 | ```nix
54 | null
55 | ```
56 |
57 | **Declared in**:
58 |
59 | - [modules/commands.nix](https://github.com/numtide/devshell/tree/main/modules/commands.nix)
60 |
61 | ### `commands.*.category`
62 |
63 | Set a free text category under which this command is grouped
64 | and shown in the help menu.
65 |
66 | **Type**:
67 |
68 | ```console
69 | string
70 | ```
71 |
72 | **Default value**:
73 |
74 | ```nix
75 | "[general commands]"
76 | ```
77 |
78 | **Declared in**:
79 |
80 | - [modules/commands.nix](https://github.com/numtide/devshell/tree/main/modules/commands.nix)
81 |
82 | ### `commands.*.command`
83 |
84 | If defined, it will add a script with the name of the command, and the
85 | content of this value.
86 |
87 | By default it generates a bash script, unless a different shebang is
88 | provided.
89 |
90 | **Type**:
91 |
92 | ```console
93 | null or string
94 | ```
95 |
96 | **Default value**:
97 |
98 | ```nix
99 | null
100 | ```
101 |
102 | **Example value**:
103 |
104 | ```nix
105 | ''
106 | #!/usr/bin/env python
107 | print("Hello")
108 | ''
109 | ```
110 |
111 | **Declared in**:
112 |
113 | - [modules/commands.nix](https://github.com/numtide/devshell/tree/main/modules/commands.nix)
114 |
115 | ### `commands.*.help`
116 |
117 | Describes what the command does in one line of text.
118 |
119 | **Type**:
120 |
121 | ```console
122 | null or string
123 | ```
124 |
125 | **Default value**:
126 |
127 | ```nix
128 | null
129 | ```
130 |
131 | **Declared in**:
132 |
133 | - [modules/commands.nix](https://github.com/numtide/devshell/tree/main/modules/commands.nix)
134 |
135 | ### `commands.*.name`
136 |
137 | Name of this command. Defaults to attribute name in commands.
138 |
139 | **Type**:
140 |
141 | ```console
142 | null or string
143 | ```
144 |
145 | **Default value**:
146 |
147 | ```nix
148 | null
149 | ```
150 |
151 | **Declared in**:
152 |
153 | - [modules/commands.nix](https://github.com/numtide/devshell/tree/main/modules/commands.nix)
154 |
155 | ### `devshell.packages`
156 |
157 | The set of packages to appear in the project environment.
158 |
159 | Those packages come from and can be
160 | searched by going to
161 |
162 | **Type**:
163 |
164 | ```console
165 | list of (package or string convertible to it)
166 | ```
167 |
168 | **Default value**:
169 |
170 | ```nix
171 | [ ]
172 | ```
173 |
174 | **Declared in**:
175 |
176 | - [modules/devshell.nix](https://github.com/numtide/devshell/tree/main/modules/devshell.nix)
177 |
178 | ### `devshell.packagesFrom`
179 |
180 | Add all the build dependencies from the listed packages to the
181 | environment.
182 |
183 | **Type**:
184 |
185 | ```console
186 | list of (package or string convertible to it)
187 | ```
188 |
189 | **Default value**:
190 |
191 | ```nix
192 | [ ]
193 | ```
194 |
195 | **Declared in**:
196 |
197 | - [modules/devshell.nix](https://github.com/numtide/devshell/tree/main/modules/devshell.nix)
198 |
199 | ### `devshell.interactive..deps`
200 |
201 | A list of other steps that this one depends on.
202 |
203 | **Type**:
204 |
205 | ```console
206 | list of string
207 | ```
208 |
209 | **Default value**:
210 |
211 | ```nix
212 | [ ]
213 | ```
214 |
215 | **Declared in**:
216 |
217 | - [modules/devshell.nix](https://github.com/numtide/devshell/tree/main/modules/devshell.nix)
218 |
219 | ### `devshell.interactive..text`
220 |
221 | Script to run.
222 |
223 | **Type**:
224 |
225 | ```console
226 | string
227 | ```
228 |
229 | **Declared in**:
230 |
231 | - [modules/devshell.nix](https://github.com/numtide/devshell/tree/main/modules/devshell.nix)
232 |
233 | ### `devshell.load_profiles`
234 |
235 | Whether to enable load etc/profiles.d/*.sh in the shell.
236 | **Type**:
237 |
238 | ```console
239 | boolean
240 | ```
241 |
242 | **Default value**:
243 |
244 | ```nix
245 | false
246 | ```
247 |
248 | **Example value**:
249 |
250 | ```nix
251 | true
252 | ```
253 |
254 | **Declared in**:
255 |
256 | - [modules/devshell.nix](https://github.com/numtide/devshell/tree/main/modules/devshell.nix)
257 |
258 | ### `devshell.meta`
259 |
260 | Metadata, such as 'meta.description'. Can be useful as metadata for downstream tooling.
261 |
262 | **Type**:
263 |
264 | ```console
265 | attribute set of anything
266 | ```
267 |
268 | **Default value**:
269 |
270 | ```nix
271 | { }
272 | ```
273 |
274 | **Declared in**:
275 |
276 | - [modules/devshell.nix](https://github.com/numtide/devshell/tree/main/modules/devshell.nix)
277 |
278 | ### `devshell.motd`
279 |
280 | Message Of The Day.
281 |
282 | This is the welcome message that is being printed when the user opens
283 | the shell.
284 |
285 | You may use any valid ansi color from the 8-bit ansi color table. For example, to use a green color you would use something like {106}. You may also use {bold}, {italic}, {underline}. Use {reset} to turn off all attributes.
286 |
287 | **Type**:
288 |
289 | ```console
290 | string
291 | ```
292 |
293 | **Default value**:
294 |
295 | ```nix
296 | ''
297 | {202}🔨 Welcome to devshell{reset}
298 | $(type -p menu &>/dev/null && menu)
299 | ''
300 | ```
301 |
302 | **Declared in**:
303 |
304 | - [modules/devshell.nix](https://github.com/numtide/devshell/tree/main/modules/devshell.nix)
305 |
306 | ### `devshell.name`
307 |
308 | Name of the shell environment. It usually maps to the project name.
309 |
310 | **Type**:
311 |
312 | ```console
313 | string
314 | ```
315 |
316 | **Default value**:
317 |
318 | ```nix
319 | "devshell"
320 | ```
321 |
322 | **Declared in**:
323 |
324 | - [modules/devshell.nix](https://github.com/numtide/devshell/tree/main/modules/devshell.nix)
325 |
326 | ### `devshell.prj_root_fallback`
327 |
328 | If IN_NIX_SHELL is nonempty, or DIRENV_IN_ENVRC is set to '1', then
329 | PRJ_ROOT is set to the value of PWD.
330 |
331 | This option specifies the path to use as the value of PRJ_ROOT in case
332 | IN_NIX_SHELL is empty or unset and DIRENV_IN_ENVRC is any value other
333 | than '1'.
334 |
335 | Set this to null to force PRJ_ROOT to be defined at runtime (except if
336 | IN_NIX_SHELL or DIRENV_IN_ENVRC are defined as described above).
337 |
338 | Otherwise, you can set this to a string representing the desired
339 | default path, or to a submodule of the same type valid in the 'env'
340 | options list (except that the 'name' field is ignored).
341 |
342 | **Type**:
343 |
344 | ```console
345 | null or ((submodule) or non-empty string convertible to it)
346 | ```
347 |
348 | **Default value**:
349 |
350 | ```nix
351 | {
352 | eval = "$PWD";
353 | }
354 | ```
355 |
356 | **Example value**:
357 |
358 | ```nix
359 | {
360 | # Use the top-level directory of the working tree
361 | eval = "$(git rev-parse --show-toplevel)";
362 | };
363 | ```
364 |
365 | **Declared in**:
366 |
367 | - [modules/devshell.nix](https://github.com/numtide/devshell/tree/main/modules/devshell.nix)
368 |
369 | ### `devshell.prj_root_fallback.eval`
370 |
371 | Like value but not evaluated by Bash. This allows to inject other
372 | variable names or even commands using the `$()` notation.
373 |
374 | **Type**:
375 |
376 | ```console
377 | null or string
378 | ```
379 |
380 | **Default value**:
381 |
382 | ```nix
383 | null
384 | ```
385 |
386 | **Example value**:
387 |
388 | ```nix
389 | "$OTHER_VAR"
390 | ```
391 |
392 | **Declared in**:
393 |
394 | - [modules/env.nix](https://github.com/numtide/devshell/tree/main/modules/env.nix)
395 |
396 | ### `devshell.prj_root_fallback.name`
397 |
398 | Name of the environment variable
399 | **Type**:
400 |
401 | ```console
402 | string
403 | ```
404 |
405 | **Declared in**:
406 |
407 | - [modules/env.nix](https://github.com/numtide/devshell/tree/main/modules/env.nix)
408 |
409 | ### `devshell.prj_root_fallback.prefix`
410 |
411 | Prepend to PATH-like environment variables.
412 |
413 | For example name = "PATH"; prefix = "bin"; will expand the path of
414 | ./bin and prepend it to the PATH, separated by ':'.
415 |
416 | **Type**:
417 |
418 | ```console
419 | null or string
420 | ```
421 |
422 | **Default value**:
423 |
424 | ```nix
425 | null
426 | ```
427 |
428 | **Example value**:
429 |
430 | ```nix
431 | "bin"
432 | ```
433 |
434 | **Declared in**:
435 |
436 | - [modules/env.nix](https://github.com/numtide/devshell/tree/main/modules/env.nix)
437 |
438 | ### `devshell.prj_root_fallback.unset`
439 |
440 | Whether to enable unsets the variable.
441 | **Type**:
442 |
443 | ```console
444 | boolean
445 | ```
446 |
447 | **Default value**:
448 |
449 | ```nix
450 | false
451 | ```
452 |
453 | **Example value**:
454 |
455 | ```nix
456 | true
457 | ```
458 |
459 | **Declared in**:
460 |
461 | - [modules/env.nix](https://github.com/numtide/devshell/tree/main/modules/env.nix)
462 |
463 | ### `devshell.prj_root_fallback.value`
464 |
465 | Shell-escaped value to set
466 | **Type**:
467 |
468 | ```console
469 | null or string or signed integer or boolean or package
470 | ```
471 |
472 | **Default value**:
473 |
474 | ```nix
475 | null
476 | ```
477 |
478 | **Declared in**:
479 |
480 | - [modules/env.nix](https://github.com/numtide/devshell/tree/main/modules/env.nix)
481 |
482 | ### `devshell.startup..deps`
483 |
484 | A list of other steps that this one depends on.
485 |
486 | **Type**:
487 |
488 | ```console
489 | list of string
490 | ```
491 |
492 | **Default value**:
493 |
494 | ```nix
495 | [ ]
496 | ```
497 |
498 | **Declared in**:
499 |
500 | - [modules/devshell.nix](https://github.com/numtide/devshell/tree/main/modules/devshell.nix)
501 |
502 | ### `devshell.startup..text`
503 |
504 | Script to run.
505 |
506 | **Type**:
507 |
508 | ```console
509 | string
510 | ```
511 |
512 | **Declared in**:
513 |
514 | - [modules/devshell.nix](https://github.com/numtide/devshell/tree/main/modules/devshell.nix)
515 |
516 | ### `env`
517 |
518 | Add environment variables to the shell.
519 |
520 | **Type**:
521 |
522 | ```console
523 | list of (submodule)
524 | ```
525 |
526 | **Default value**:
527 |
528 | ```nix
529 | [ ]
530 | ```
531 |
532 | **Example value**:
533 |
534 | ```nix
535 | [
536 | {
537 | name = "HTTP_PORT";
538 | value = 8080;
539 | }
540 | {
541 | name = "PATH";
542 | prefix = "bin";
543 | }
544 | {
545 | name = "XDG_CACHE_DIR";
546 | eval = "$PRJ_ROOT/.cache";
547 | }
548 | {
549 | name = "CARGO_HOME";
550 | unset = true;
551 | }
552 | ]
553 | ```
554 |
555 | **Declared in**:
556 |
557 | - [modules/env.nix](https://github.com/numtide/devshell/tree/main/modules/env.nix)
558 |
559 | ### `env.*.eval`
560 |
561 | Like value but not evaluated by Bash. This allows to inject other
562 | variable names or even commands using the `$()` notation.
563 |
564 | **Type**:
565 |
566 | ```console
567 | null or string
568 | ```
569 |
570 | **Default value**:
571 |
572 | ```nix
573 | null
574 | ```
575 |
576 | **Example value**:
577 |
578 | ```nix
579 | "$OTHER_VAR"
580 | ```
581 |
582 | **Declared in**:
583 |
584 | - [modules/env.nix](https://github.com/numtide/devshell/tree/main/modules/env.nix)
585 |
586 | ### `env.*.name`
587 |
588 | Name of the environment variable
589 | **Type**:
590 |
591 | ```console
592 | string
593 | ```
594 |
595 | **Declared in**:
596 |
597 | - [modules/env.nix](https://github.com/numtide/devshell/tree/main/modules/env.nix)
598 |
599 | ### `env.*.prefix`
600 |
601 | Prepend to PATH-like environment variables.
602 |
603 | For example name = "PATH"; prefix = "bin"; will expand the path of
604 | ./bin and prepend it to the PATH, separated by ':'.
605 |
606 | **Type**:
607 |
608 | ```console
609 | null or string
610 | ```
611 |
612 | **Default value**:
613 |
614 | ```nix
615 | null
616 | ```
617 |
618 | **Example value**:
619 |
620 | ```nix
621 | "bin"
622 | ```
623 |
624 | **Declared in**:
625 |
626 | - [modules/env.nix](https://github.com/numtide/devshell/tree/main/modules/env.nix)
627 |
628 | ### `env.*.unset`
629 |
630 | Whether to enable unsets the variable.
631 | **Type**:
632 |
633 | ```console
634 | boolean
635 | ```
636 |
637 | **Default value**:
638 |
639 | ```nix
640 | false
641 | ```
642 |
643 | **Example value**:
644 |
645 | ```nix
646 | true
647 | ```
648 |
649 | **Declared in**:
650 |
651 | - [modules/env.nix](https://github.com/numtide/devshell/tree/main/modules/env.nix)
652 |
653 | ### `env.*.value`
654 |
655 | Shell-escaped value to set
656 | **Type**:
657 |
658 | ```console
659 | null or string or signed integer or boolean or package
660 | ```
661 |
662 | **Default value**:
663 |
664 | ```nix
665 | null
666 | ```
667 |
668 | **Declared in**:
669 |
670 | - [modules/env.nix](https://github.com/numtide/devshell/tree/main/modules/env.nix)
671 |
672 | ### `extra.locale.package`
673 |
674 | Set the glibc locale package that will be used on Linux
675 | **Type**:
676 |
677 | ```console
678 | package
679 | ```
680 |
681 | **Default value**:
682 |
683 | ```nix
684 | "pkgs.glibcLocales"
685 | ```
686 |
687 | **Declared in**:
688 |
689 | - [extra/locale.nix](https://github.com/numtide/devshell/tree/main/extra/locale.nix)
690 |
691 | ### `extra.locale.lang`
692 |
693 | Set the language of the project
694 | **Type**:
695 |
696 | ```console
697 | null or string
698 | ```
699 |
700 | **Default value**:
701 |
702 | ```nix
703 | null
704 | ```
705 |
706 | **Example value**:
707 |
708 | ```nix
709 | "en_GB.UTF-8"
710 | ```
711 |
712 | **Declared in**:
713 |
714 | - [extra/locale.nix](https://github.com/numtide/devshell/tree/main/extra/locale.nix)
715 |
716 | ### `git.hooks.enable`
717 |
718 | Whether to enable install .git/hooks on shell entry.
719 | **Type**:
720 |
721 | ```console
722 | boolean
723 | ```
724 |
725 | **Default value**:
726 |
727 | ```nix
728 | false
729 | ```
730 |
731 | **Example value**:
732 |
733 | ```nix
734 | true
735 | ```
736 |
737 | **Declared in**:
738 |
739 | - [extra/git/hooks.nix](https://github.com/numtide/devshell/tree/main/extra/git/hooks.nix)
740 |
741 | ### `git.hooks.applypatch-msg.text`
742 |
743 | Text of the script to install
744 | **Type**:
745 |
746 | ```console
747 | string
748 | ```
749 |
750 | **Default value**:
751 |
752 | ```nix
753 | ""
754 | ```
755 |
756 | **Declared in**:
757 |
758 | - [extra/git/hooks.nix](https://github.com/numtide/devshell/tree/main/extra/git/hooks.nix)
759 |
760 | ### `git.hooks.commit-msg.text`
761 |
762 | Text of the script to install
763 | **Type**:
764 |
765 | ```console
766 | string
767 | ```
768 |
769 | **Default value**:
770 |
771 | ```nix
772 | ""
773 | ```
774 |
775 | **Declared in**:
776 |
777 | - [extra/git/hooks.nix](https://github.com/numtide/devshell/tree/main/extra/git/hooks.nix)
778 |
779 | ### `git.hooks.fsmonitor-watchman.text`
780 |
781 | Text of the script to install
782 | **Type**:
783 |
784 | ```console
785 | string
786 | ```
787 |
788 | **Default value**:
789 |
790 | ```nix
791 | ""
792 | ```
793 |
794 | **Declared in**:
795 |
796 | - [extra/git/hooks.nix](https://github.com/numtide/devshell/tree/main/extra/git/hooks.nix)
797 |
798 | ### `git.hooks.post-update.text`
799 |
800 | Text of the script to install
801 | **Type**:
802 |
803 | ```console
804 | string
805 | ```
806 |
807 | **Default value**:
808 |
809 | ```nix
810 | ""
811 | ```
812 |
813 | **Declared in**:
814 |
815 | - [extra/git/hooks.nix](https://github.com/numtide/devshell/tree/main/extra/git/hooks.nix)
816 |
817 | ### `git.hooks.pre-applypatch.text`
818 |
819 | Text of the script to install
820 | **Type**:
821 |
822 | ```console
823 | string
824 | ```
825 |
826 | **Default value**:
827 |
828 | ```nix
829 | ""
830 | ```
831 |
832 | **Declared in**:
833 |
834 | - [extra/git/hooks.nix](https://github.com/numtide/devshell/tree/main/extra/git/hooks.nix)
835 |
836 | ### `git.hooks.pre-commit.text`
837 |
838 | Text of the script to install
839 | **Type**:
840 |
841 | ```console
842 | string
843 | ```
844 |
845 | **Default value**:
846 |
847 | ```nix
848 | ""
849 | ```
850 |
851 | **Declared in**:
852 |
853 | - [extra/git/hooks.nix](https://github.com/numtide/devshell/tree/main/extra/git/hooks.nix)
854 |
855 | ### `git.hooks.pre-merge-commit.text`
856 |
857 | Text of the script to install
858 | **Type**:
859 |
860 | ```console
861 | string
862 | ```
863 |
864 | **Default value**:
865 |
866 | ```nix
867 | ""
868 | ```
869 |
870 | **Declared in**:
871 |
872 | - [extra/git/hooks.nix](https://github.com/numtide/devshell/tree/main/extra/git/hooks.nix)
873 |
874 | ### `git.hooks.pre-push.text`
875 |
876 | Text of the script to install
877 | **Type**:
878 |
879 | ```console
880 | string
881 | ```
882 |
883 | **Default value**:
884 |
885 | ```nix
886 | ""
887 | ```
888 |
889 | **Declared in**:
890 |
891 | - [extra/git/hooks.nix](https://github.com/numtide/devshell/tree/main/extra/git/hooks.nix)
892 |
893 | ### `git.hooks.pre-rebase.text`
894 |
895 | Text of the script to install
896 | **Type**:
897 |
898 | ```console
899 | string
900 | ```
901 |
902 | **Default value**:
903 |
904 | ```nix
905 | ""
906 | ```
907 |
908 | **Declared in**:
909 |
910 | - [extra/git/hooks.nix](https://github.com/numtide/devshell/tree/main/extra/git/hooks.nix)
911 |
912 | ### `git.hooks.prepare-commit-msg.text`
913 |
914 | Text of the script to install
915 | **Type**:
916 |
917 | ```console
918 | string
919 | ```
920 |
921 | **Default value**:
922 |
923 | ```nix
924 | ""
925 | ```
926 |
927 | **Declared in**:
928 |
929 | - [extra/git/hooks.nix](https://github.com/numtide/devshell/tree/main/extra/git/hooks.nix)
930 |
931 | ### `language.c.compiler`
932 |
933 | Which C compiler to use
934 | **Type**:
935 |
936 | ```console
937 | package or string convertible to it
938 | ```
939 |
940 | **Default value**:
941 |
942 | ```nix
943 | "pkgs.clang"
944 | ```
945 |
946 | **Declared in**:
947 |
948 | - [extra/language/c.nix](https://github.com/numtide/devshell/tree/main/extra/language/c.nix)
949 |
950 | ### `language.c.includes`
951 |
952 | C dependencies from nixpkgs
953 | **Type**:
954 |
955 | ```console
956 | list of (package or string convertible to it)
957 | ```
958 |
959 | **Default value**:
960 |
961 | ```nix
962 | [ ]
963 | ```
964 |
965 | **Declared in**:
966 |
967 | - [extra/language/c.nix](https://github.com/numtide/devshell/tree/main/extra/language/c.nix)
968 |
969 | ### `language.c.libraries`
970 |
971 | Use this when another language dependens on a dynamic library
972 | **Type**:
973 |
974 | ```console
975 | list of (package or string convertible to it)
976 | ```
977 |
978 | **Default value**:
979 |
980 | ```nix
981 | [ ]
982 | ```
983 |
984 | **Declared in**:
985 |
986 | - [extra/language/c.nix](https://github.com/numtide/devshell/tree/main/extra/language/c.nix)
987 |
988 | ### `language.go.package`
989 |
990 | Which go package to use
991 | **Type**:
992 |
993 | ```console
994 | package or string convertible to it
995 | ```
996 |
997 | **Default value**:
998 |
999 | ```nix
1000 |
1001 | ```
1002 |
1003 | **Example value**:
1004 |
1005 | ```nix
1006 | pkgs.go
1007 | ```
1008 |
1009 | **Declared in**:
1010 |
1011 | - [extra/language/go.nix](https://github.com/numtide/devshell/tree/main/extra/language/go.nix)
1012 |
1013 | ### `language.go.GO111MODULE`
1014 |
1015 | Enable Go modules
1016 | **Type**:
1017 |
1018 | ```console
1019 | one of "on", "off", "auto"
1020 | ```
1021 |
1022 | **Default value**:
1023 |
1024 | ```nix
1025 | "on"
1026 | ```
1027 |
1028 | **Declared in**:
1029 |
1030 | - [extra/language/go.nix](https://github.com/numtide/devshell/tree/main/extra/language/go.nix)
1031 |
1032 | ### `language.perl.package`
1033 |
1034 | Which Perl package to use
1035 | **Type**:
1036 |
1037 | ```console
1038 | package or string convertible to it
1039 | ```
1040 |
1041 | **Default value**:
1042 |
1043 | ```nix
1044 |
1045 | ```
1046 |
1047 | **Example value**:
1048 |
1049 | ```nix
1050 | pkgs.perl538
1051 | ```
1052 |
1053 | **Declared in**:
1054 |
1055 | - [extra/language/perl.nix](https://github.com/numtide/devshell/tree/main/extra/language/perl.nix)
1056 |
1057 | ### `language.perl.extraPackages`
1058 |
1059 | List of extra packages (coming from perl5XXPackages) to add
1060 | **Type**:
1061 |
1062 | ```console
1063 | list of (package or string convertible to it)
1064 | ```
1065 |
1066 | **Default value**:
1067 |
1068 | ```nix
1069 | [ ]
1070 | ```
1071 |
1072 | **Example value**:
1073 |
1074 | ```nix
1075 | [ perl538Packages.FileNext ]
1076 | ```
1077 |
1078 | **Declared in**:
1079 |
1080 | - [extra/language/perl.nix](https://github.com/numtide/devshell/tree/main/extra/language/perl.nix)
1081 |
1082 | ### `language.perl.libraryPaths`
1083 |
1084 | List of paths to add to PERL5LIB
1085 | **Type**:
1086 |
1087 | ```console
1088 | list of string
1089 | ```
1090 |
1091 | **Default value**:
1092 |
1093 | ```nix
1094 | [ ]
1095 | ```
1096 |
1097 | **Example value**:
1098 |
1099 | ```nix
1100 | [ ./lib ]
1101 | ```
1102 |
1103 | **Declared in**:
1104 |
1105 | - [extra/language/perl.nix](https://github.com/numtide/devshell/tree/main/extra/language/perl.nix)
1106 |
1107 | ### `language.ruby.package`
1108 |
1109 | Ruby version used by your project
1110 | **Type**:
1111 |
1112 | ```console
1113 | package or string convertible to it
1114 | ```
1115 |
1116 | **Default value**:
1117 |
1118 | ```nix
1119 | "pkgs.ruby_3_2"
1120 | ```
1121 |
1122 | **Declared in**:
1123 |
1124 | - [extra/language/ruby.nix](https://github.com/numtide/devshell/tree/main/extra/language/ruby.nix)
1125 |
1126 | ### `language.ruby.nativeDeps`
1127 |
1128 | Use this when your gems depend on a dynamic library
1129 | **Type**:
1130 |
1131 | ```console
1132 | list of (package or string convertible to it)
1133 | ```
1134 |
1135 | **Default value**:
1136 |
1137 | ```nix
1138 | [ ]
1139 | ```
1140 |
1141 | **Declared in**:
1142 |
1143 | - [extra/language/ruby.nix](https://github.com/numtide/devshell/tree/main/extra/language/ruby.nix)
1144 |
1145 | ### `language.rust.enableDefaultToolchain`
1146 |
1147 | Enable the default rust toolchain coming from nixpkgs
1148 | **Type**:
1149 |
1150 | ```console
1151 | boolean
1152 | ```
1153 |
1154 | **Default value**:
1155 |
1156 | ```nix
1157 | "true"
1158 | ```
1159 |
1160 | **Declared in**:
1161 |
1162 | - [extra/language/rust.nix](https://github.com/numtide/devshell/tree/main/extra/language/rust.nix)
1163 |
1164 | ### `language.rust.packageSet`
1165 |
1166 | Which rust package set to use
1167 | **Type**:
1168 |
1169 | ```console
1170 | attribute set
1171 | ```
1172 |
1173 | **Default value**:
1174 |
1175 | ```nix
1176 | "pkgs.rustPlatform"
1177 | ```
1178 |
1179 | **Declared in**:
1180 |
1181 | - [extra/language/rust.nix](https://github.com/numtide/devshell/tree/main/extra/language/rust.nix)
1182 |
1183 | ### `language.rust.tools`
1184 |
1185 | Which rust tools to pull from the platform package set
1186 | **Type**:
1187 |
1188 | ```console
1189 | list of string
1190 | ```
1191 |
1192 | **Default value**:
1193 |
1194 | ```nix
1195 | [
1196 | "rustc"
1197 | "cargo"
1198 | "clippy"
1199 | "rustfmt"
1200 | ]
1201 | ```
1202 |
1203 | **Declared in**:
1204 |
1205 | - [extra/language/rust.nix](https://github.com/numtide/devshell/tree/main/extra/language/rust.nix)
1206 |
1207 | ### `serviceGroups`
1208 |
1209 | Add services to the environment. Services can be used to group long-running processes.
1210 |
1211 | **Type**:
1212 |
1213 | ```console
1214 | attribute set of (submodule)
1215 | ```
1216 |
1217 | **Default value**:
1218 |
1219 | ```nix
1220 | { }
1221 | ```
1222 |
1223 | **Declared in**:
1224 |
1225 | - [modules/services.nix](https://github.com/numtide/devshell/tree/main/modules/services.nix)
1226 |
1227 | ### `serviceGroups..description`
1228 |
1229 | Short description of the service group, shown in generated commands
1230 |
1231 | **Type**:
1232 |
1233 | ```console
1234 | null or string
1235 | ```
1236 |
1237 | **Default value**:
1238 |
1239 | ```nix
1240 | null
1241 | ```
1242 |
1243 | **Declared in**:
1244 |
1245 | - [modules/services.nix](https://github.com/numtide/devshell/tree/main/modules/services.nix)
1246 |
1247 | ### `serviceGroups..name`
1248 |
1249 | Name of the service group. Defaults to attribute name in groups.
1250 |
1251 | **Type**:
1252 |
1253 | ```console
1254 | null or string
1255 | ```
1256 |
1257 | **Default value**:
1258 |
1259 | ```nix
1260 | null
1261 | ```
1262 |
1263 | **Declared in**:
1264 |
1265 | - [modules/services.nix](https://github.com/numtide/devshell/tree/main/modules/services.nix)
1266 |
1267 | ### `serviceGroups..services`
1268 |
1269 | Attrset of services that should be run in this group.
1270 |
1271 | **Type**:
1272 |
1273 | ```console
1274 | attribute set of (submodule)
1275 | ```
1276 |
1277 | **Default value**:
1278 |
1279 | ```nix
1280 | { }
1281 | ```
1282 |
1283 | **Declared in**:
1284 |
1285 | - [modules/services.nix](https://github.com/numtide/devshell/tree/main/modules/services.nix)
1286 |
1287 | ### `serviceGroups..services..command`
1288 |
1289 | Command to execute.
1290 |
1291 | **Type**:
1292 |
1293 | ```console
1294 | string
1295 | ```
1296 |
1297 | **Declared in**:
1298 |
1299 | - [modules/services.nix](https://github.com/numtide/devshell/tree/main/modules/services.nix)
1300 |
1301 | ### `serviceGroups..services..name`
1302 |
1303 | Name of this service. Defaults to attribute name in group services.
1304 |
1305 | **Type**:
1306 |
1307 | ```console
1308 | null or string
1309 | ```
1310 |
1311 | **Default value**:
1312 |
1313 | ```nix
1314 | null
1315 | ```
1316 |
1317 | **Declared in**:
1318 |
1319 | - [modules/services.nix](https://github.com/numtide/devshell/tree/main/modules/services.nix)
1320 |
1321 | ### `services.postgres.package`
1322 |
1323 | Which version of postgres to use
1324 | **Type**:
1325 |
1326 | ```console
1327 | package or string convertible to it
1328 | ```
1329 |
1330 | **Default value**:
1331 |
1332 | ```nix
1333 | "pkgs.postgresql"
1334 | ```
1335 |
1336 | **Declared in**:
1337 |
1338 | - [extra/services/postgres.nix](https://github.com/numtide/devshell/tree/main/extra/services/postgres.nix)
1339 |
1340 | ### `services.postgres.createUserDB`
1341 |
1342 | Create a database named like current user on startup.
1343 | This option only makes sense when `setupPostgresOnStartup` is true.
1344 |
1345 | **Type**:
1346 |
1347 | ```console
1348 | boolean
1349 | ```
1350 |
1351 | **Default value**:
1352 |
1353 | ```nix
1354 | true
1355 | ```
1356 |
1357 | **Declared in**:
1358 |
1359 | - [extra/services/postgres.nix](https://github.com/numtide/devshell/tree/main/extra/services/postgres.nix)
1360 |
1361 | ### `services.postgres.initdbArgs`
1362 |
1363 | Additional arguments passed to `initdb` during data dir
1364 | initialisation.
1365 |
1366 | **Type**:
1367 |
1368 | ```console
1369 | list of string
1370 | ```
1371 |
1372 | **Default value**:
1373 |
1374 | ```nix
1375 | [
1376 | "--no-locale"
1377 | ]
1378 | ```
1379 |
1380 | **Example value**:
1381 |
1382 | ```nix
1383 | [
1384 | "--data-checksums"
1385 | "--allow-group-access"
1386 | ]
1387 | ```
1388 |
1389 | **Declared in**:
1390 |
1391 | - [extra/services/postgres.nix](https://github.com/numtide/devshell/tree/main/extra/services/postgres.nix)
1392 |
1393 | ### `services.postgres.setupPostgresOnStartup`
1394 |
1395 | Whether to enable call setup-postgres on startup.
1396 | **Type**:
1397 |
1398 | ```console
1399 | boolean
1400 | ```
1401 |
1402 | **Default value**:
1403 |
1404 | ```nix
1405 | false
1406 | ```
1407 |
1408 | **Example value**:
1409 |
1410 | ```nix
1411 | true
1412 | ```
1413 |
1414 | **Declared in**:
1415 |
1416 | - [extra/services/postgres.nix](https://github.com/numtide/devshell/tree/main/extra/services/postgres.nix)
1417 |
1418 | ## Extra options
1419 |
1420 | ### `_module.args`
1421 |
1422 | Additional arguments passed to each module in addition to ones
1423 | like `lib`, `config`,
1424 | and `pkgs`, `modulesPath`.
1425 |
1426 | This option is also available to all submodules. Submodules do not
1427 | inherit args from their parent module, nor do they provide args to
1428 | their parent module or sibling submodules. The sole exception to
1429 | this is the argument `name` which is provided by
1430 | parent modules to a submodule and contains the attribute name
1431 | the submodule is bound to, or a unique generated name if it is
1432 | not bound to an attribute.
1433 |
1434 | Some arguments are already passed by default, of which the
1435 | following *cannot* be changed with this option:
1436 | - {var}`lib`: The nixpkgs library.
1437 | - {var}`config`: The results of all options after merging the values from all modules together.
1438 | - {var}`options`: The options declared in all modules.
1439 | - {var}`specialArgs`: The `specialArgs` argument passed to `evalModules`.
1440 | - All attributes of {var}`specialArgs`
1441 |
1442 | Whereas option values can generally depend on other option values
1443 | thanks to laziness, this does not apply to `imports`, which
1444 | must be computed statically before anything else.
1445 |
1446 | For this reason, callers of the module system can provide `specialArgs`
1447 | which are available during import resolution.
1448 |
1449 | For NixOS, `specialArgs` includes
1450 | {var}`modulesPath`, which allows you to import
1451 | extra modules from the nixpkgs package tree without having to
1452 | somehow make the module aware of the location of the
1453 | `nixpkgs` or NixOS directories.
1454 | ```
1455 | { modulesPath, ... }: {
1456 | imports = [
1457 | (modulesPath + "/profiles/minimal.nix")
1458 | ];
1459 | }
1460 | ```
1461 |
1462 | For NixOS, the default value for this option includes at least this argument:
1463 | - {var}`pkgs`: The nixpkgs package set according to
1464 | the {option}`nixpkgs.pkgs` option.
1465 |
1466 | **Type**:
1467 |
1468 | ```console
1469 | lazy attribute set of raw value
1470 | ```
1471 |
1472 | **Declared in**:
1473 |
1474 | - [lib/modules.nix]()
1475 |
--------------------------------------------------------------------------------
/docs/theme/index.hbs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | {{ title }}
7 | {{#if is_print }}
8 |
9 | {{/if}}
10 | {{#if base_url}}
11 |
12 | {{/if}}
13 |
14 |
15 |
16 | {{> head}}
17 |
18 |
19 |
20 |
21 |
22 | {{#if favicon_svg}}
23 |
24 | {{/if}}
25 | {{#if favicon_png}}
26 |
27 | {{/if}}
28 |
29 |
30 |
31 | {{#if print_enable}}
32 |
33 | {{/if}}
34 |
35 |
36 |
37 | {{#if copy_fonts}}
38 |
39 | {{/if}}
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | {{#each additional_css}}
48 |
49 | {{/each}}
50 |
51 | {{#if mathjax_support}}
52 |
53 |
54 | {{/if}}
55 |
56 |
57 |