Skip to content

Commit

Permalink
Add nix-shell
Browse files Browse the repository at this point in the history
  • Loading branch information
yamaton committed Dec 1, 2023
1 parent dfe63a3 commit f54890d
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 5 deletions.
4 changes: 2 additions & 2 deletions general.json.gz
Git LFS file not shown
1 change: 1 addition & 0 deletions general.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ nim
ninja
nix
nix-build
nix-shell
nm
nmap
nmcli
Expand Down
2 changes: 1 addition & 1 deletion general/bash
Submodule bash updated 1 files
+13 −0 completions/nix-shell
2 changes: 1 addition & 1 deletion general/fish
1 change: 1 addition & 0 deletions general/json/nix-shell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"nix-shell","description":"start an interactive shell based on a Nix expression","usage":"nix-shell [--arg name value] [--argstr name value] [{--attr | -A} attrPath] [--command cmd] [--run cmd] [--exclude regexp] [--pure] [--keep name] {{--packages | -p} {packages | expressions} … | [path]}","options":[{"names":["--command"],"argument":"cmd","description":"In the environment of the derivation, run the shell command cmd. This command is executed in an interactive shell. (Use --run to use a non-interactive shell instead.) However, a call to exit is implicitly added to the command, so the shell will exit after running the command. To prevent this, add return at the end; e.g. --command \"echo Hello; return\" will print Hello and then drop you into the interactive shell. This can be useful for doing any additional initialisation."},{"names":["--run"],"argument":"cmd","description":"Like --command, but executes the command in a non-interactive shell. This means (among other things) that if you hit Ctrl-C while the command is running, the shell exits."},{"names":["--exclude"],"argument":"regexp","description":"Do not build any dependencies whose store path matches the regular expression regexp. This option may be specified multiple times."},{"names":["--pure"],"argument":"","description":"If this flag is specified, the environment is almost entirely cleared before the interactive shell is started, so you get an environment that more closely corresponds to the “real” Nix build. A few variables, in particular HOME, USER and DISPLAY, are retained."},{"names":["-i"],"argument":"interpreter","description":"The chained script interpreter to be invoked by nix-shell. Only applicable in #!-scripts (described below)."},{"names":["--keep"],"argument":"name","description":"When a --pure shell is started, keep the listed environment variables."},{"names":["--help"],"argument":"","description":"Prints out a summary of the command syntax and exits."},{"names":["--version"],"argument":"","description":"Prints out the Nix version number on standard output and exits."},{"names":["--verbose","-v"],"argument":"","description":"Increases the level of verbosity of diagnostic messages printed on standard error. For each Nix operation, the information printed on standard output is well-defined; any diagnostic information is printed on standard error, never on standard output."},{"names":["--quiet"],"argument":"","description":"Decreases the level of verbosity of diagnostic messages printed on standard error. This is the inverse option to -v / --verbose."},{"names":["--log-format"],"argument":"format","description":"This option can be used to change the output of the log format, with format being one of:"},{"names":["--no-build-output","-Q"],"argument":"","description":"By default, output written by builders to standard output and standard error is echoed to the Nix command’s standard error. This option suppresses this behaviour. Note that the builder’s standard output and error are always written to a log file in prefix/nix/var/log/nix."},{"names":["--max-jobs","-j"],"argument":"number","description":"Sets the maximum number of build jobs that Nix will perform in parallel to the specified number. Specify auto to use the number of CPUs in the system. The default is specified by the max-jobs configuration setting, which itself defaults to 1. A higher value is useful on SMP systems or to exploit I/O latency."},{"names":["--cores"],"argument":"","description":"Sets the value of the NIX_BUILD_CORES environment variable in the invocation of builders. Builders can use this variable at their discretion to control the maximum amount of parallelism. For instance, in Nixpkgs, if the derivation attribute enableParallelBuilding is set to true, the builder passes the -jN flag to GNU Make. It defaults to the value of the cores configuration setting, if set, or 1 otherwise. The value 0 means that the builder should use all available CPU cores in the system."},{"names":["--max-silent-time"],"argument":"","description":"Sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error. The default is specified by the max-silent-time configuration setting. 0 means no time-out."},{"names":["--timeout"],"argument":"","description":"Sets the maximum number of seconds that a builder can run. The default is specified by the timeout configuration setting. 0 means no timeout."},{"names":["--keep-going","-k"],"argument":"","description":"Keep going in case of failed builds, to the greatest extent possible. That is, if building an input of some derivation fails, Nix will still build the other inputs, but not the derivation itself. Without this option, Nix stops if any build fails (except for builds of substitutes), possibly killing builds in progress (in case of parallel or distributed builds)."},{"names":["--keep-failed","-K"],"argument":"","description":"Specifies that in case of a build failure, the temporary directory (usually in /tmp) in which the build takes place should not be deleted. The path of the build directory is printed as an informational message."},{"names":["--fallback"],"argument":"","description":"Whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation."},{"names":["--readonly-mode"],"argument":"","description":"When this option is used, no attempt is made to open the Nix database. Most Nix operations do need database access, so those operations will fail."},{"names":["--arg"],"argument":"name value","description":"This option is accepted by nix-env, nix-instantiate, nix-shell and nix-build. When evaluating Nix expressions, the expression evaluator will automatically try to call functions that it encounters. It can automatically call functions for which every argument has a default value (e.g., { argName ? defaultValue }: ...)."},{"names":["--argstr"],"argument":"name value","description":"This option is like --arg, only the value is not a Nix expression but a string. So instead of --arg system \\\"i686-linux\\\" (the outer quotes are to keep the shell happy) you can say --argstr system i686-linux."},{"names":["--attr","-A"],"argument":"attrPath","description":"Select an attribute from the top-level Nix expression being evaluated. (nix-env, nix-instantiate, nix-build and nix-shell only.) The attribute path attrPath is a sequence of attribute names separated by dots. For instance, given a top-level Nix expression e, the attribute path xorg.xorgserver would cause the expression e.xorg.xorgserver to be used. See nix-env --install for some concrete examples."},{"names":["--expr","-E"],"argument":"","description":"Interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions. (nix-instantiate, nix-build and nix-shell only.)"},{"names":["-I"],"argument":"path","description":"Add an entry to the Nix expression search path. This option may be given multiple times. Paths added through -I take precedence over NIX_PATH."},{"names":["--option"],"argument":"name value","description":"Set the Nix configuration option name to value. This overrides settings in the Nix configuration file (see nix.conf5)."},{"names":["--repair"],"argument":"","description":"Fix corrupted or missing store paths by redownloading or rebuilding them. Note that this is slow because it requires computing a cryptographic hash of the contents of every path in the closure of the build. Also note the warning under nix-store --repair-path."}],"version":"nix-shell (Nix) 2.19.2","tldr":"> Start an interactive shell based on a Nix expression.\n> See also: `tldr nix3 shell`.\n> More information: <https://nixos.org/manual/nix/stable/command-ref/nix-shell.html>.\n\n- Start with nix expression in `shell.nix` or `default.nix` in the current directory:\n\n`nix-shell`\n\n- Run shell command in non-interactive shell and exit:\n\n`nix-shell --run \"{{command}} {{argument1 argument2 ...}}\"`\n\n- Start with expression in `default.nix` in the current directory:\n\n`nix-shell {{default.nix}}`\n\n- Start with packages loaded from nixpkgs:\n\n`nix-shell --packages {{package1 package2 ...}}`\n\n- Start with packages loaded from specific nixpkgs revision:\n\n`nix-shell --packages {{package1 package2 ...}} -I nixpkgs={{https://github.com/NixOS/nixpkgs/archive/nixpkgs_revision.tar.gz}}`\n\n- Evaluate rest of file in specific interpreter, for use in `#!-scripts` (see <https://nixos.org/manual/nix/stable/#use-as-a-interpreter>):\n\n`nix-shell -i {{interpreter}} --packages {{package1 package2 ...}}`\n"}
148 changes: 148 additions & 0 deletions general/yaml/nix-shell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: nix-shell
description: start an interactive shell based on a Nix expression
usage: nix-shell [--arg name value] [--argstr name value] [{--attr | -A} attrPath] [--command cmd] [--run cmd] [--exclude regexp] [--pure] [--keep name] {{--packages | -p} {packages | expressions} … | [path]}
options:
- names:
- --command
argument: cmd
description: In the environment of the derivation, run the shell command cmd. This command is executed in an interactive shell. (Use --run to use a non-interactive shell instead.) However, a call to exit is implicitly added to the command, so the shell will exit after running the command. To prevent this, add return at the end; e.g. --command "echo Hello; return" will print Hello and then drop you into the interactive shell. This can be useful for doing any additional initialisation.
- names:
- --run
argument: cmd
description: Like --command, but executes the command in a non-interactive shell. This means (among other things) that if you hit Ctrl-C while the command is running, the shell exits.
- names:
- --exclude
argument: regexp
description: Do not build any dependencies whose store path matches the regular expression regexp. This option may be specified multiple times.
- names:
- --pure
argument: ""
description: If this flag is specified, the environment is almost entirely cleared before the interactive shell is started, so you get an environment that more closely corresponds to the “real” Nix build. A few variables, in particular HOME, USER and DISPLAY, are retained.
- names:
- -i
argument: interpreter
description: 'The chained script interpreter to be invoked by nix-shell. Only applicable in #!-scripts (described below).'
- names:
- --keep
argument: name
description: When a --pure shell is started, keep the listed environment variables.
- names:
- --help
argument: ""
description: Prints out a summary of the command syntax and exits.
- names:
- --version
argument: ""
description: Prints out the Nix version number on standard output and exits.
- names:
- --verbose
- -v
argument: ""
description: Increases the level of verbosity of diagnostic messages printed on standard error. For each Nix operation, the information printed on standard output is well-defined; any diagnostic information is printed on standard error, never on standard output.
- names:
- --quiet
argument: ""
description: Decreases the level of verbosity of diagnostic messages printed on standard error. This is the inverse option to -v / --verbose.
- names:
- --log-format
argument: format
description: 'This option can be used to change the output of the log format, with format being one of:'
- names:
- --no-build-output
- -Q
argument: ""
description: By default, output written by builders to standard output and standard error is echoed to the Nix command’s standard error. This option suppresses this behaviour. Note that the builder’s standard output and error are always written to a log file in prefix/nix/var/log/nix.
- names:
- --max-jobs
- -j
argument: number
description: Sets the maximum number of build jobs that Nix will perform in parallel to the specified number. Specify auto to use the number of CPUs in the system. The default is specified by the max-jobs configuration setting, which itself defaults to 1. A higher value is useful on SMP systems or to exploit I/O latency.
- names:
- --cores
argument: ""
description: Sets the value of the NIX_BUILD_CORES environment variable in the invocation of builders. Builders can use this variable at their discretion to control the maximum amount of parallelism. For instance, in Nixpkgs, if the derivation attribute enableParallelBuilding is set to true, the builder passes the -jN flag to GNU Make. It defaults to the value of the cores configuration setting, if set, or 1 otherwise. The value 0 means that the builder should use all available CPU cores in the system.
- names:
- --max-silent-time
argument: ""
description: Sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error. The default is specified by the max-silent-time configuration setting. 0 means no time-out.
- names:
- --timeout
argument: ""
description: Sets the maximum number of seconds that a builder can run. The default is specified by the timeout configuration setting. 0 means no timeout.
- names:
- --keep-going
- -k
argument: ""
description: Keep going in case of failed builds, to the greatest extent possible. That is, if building an input of some derivation fails, Nix will still build the other inputs, but not the derivation itself. Without this option, Nix stops if any build fails (except for builds of substitutes), possibly killing builds in progress (in case of parallel or distributed builds).
- names:
- --keep-failed
- -K
argument: ""
description: Specifies that in case of a build failure, the temporary directory (usually in /tmp) in which the build takes place should not be deleted. The path of the build directory is printed as an informational message.
- names:
- --fallback
argument: ""
description: Whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation.
- names:
- --readonly-mode
argument: ""
description: When this option is used, no attempt is made to open the Nix database. Most Nix operations do need database access, so those operations will fail.
- names:
- --arg
argument: name value
description: 'This option is accepted by nix-env, nix-instantiate, nix-shell and nix-build. When evaluating Nix expressions, the expression evaluator will automatically try to call functions that it encounters. It can automatically call functions for which every argument has a default value (e.g., { argName ? defaultValue }: ...).'
- names:
- --argstr
argument: name value
description: This option is like --arg, only the value is not a Nix expression but a string. So instead of --arg system \"i686-linux\" (the outer quotes are to keep the shell happy) you can say --argstr system i686-linux.
- names:
- --attr
- -A
argument: attrPath
description: Select an attribute from the top-level Nix expression being evaluated. (nix-env, nix-instantiate, nix-build and nix-shell only.) The attribute path attrPath is a sequence of attribute names separated by dots. For instance, given a top-level Nix expression e, the attribute path xorg.xorgserver would cause the expression e.xorg.xorgserver to be used. See nix-env --install for some concrete examples.
- names:
- --expr
- -E
argument: ""
description: Interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions. (nix-instantiate, nix-build and nix-shell only.)
- names:
- -I
argument: path
description: Add an entry to the Nix expression search path. This option may be given multiple times. Paths added through -I take precedence over NIX_PATH.
- names:
- --option
argument: name value
description: Set the Nix configuration option name to value. This overrides settings in the Nix configuration file (see nix.conf5).
- names:
- --repair
argument: ""
description: Fix corrupted or missing store paths by redownloading or rebuilding them. Note that this is slow because it requires computing a cryptographic hash of the contents of every path in the closure of the build. Also note the warning under nix-store --repair-path.
version: nix-shell (Nix) 2.19.2
tldr: |
> Start an interactive shell based on a Nix expression.
> See also: `tldr nix3 shell`.
> More information: <https://nixos.org/manual/nix/stable/command-ref/nix-shell.html>.
- Start with nix expression in `shell.nix` or `default.nix` in the current directory:
`nix-shell`
- Run shell command in non-interactive shell and exit:
`nix-shell --run "{{command}} {{argument1 argument2 ...}}"`
- Start with expression in `default.nix` in the current directory:
`nix-shell {{default.nix}}`
- Start with packages loaded from nixpkgs:
`nix-shell --packages {{package1 package2 ...}}`
- Start with packages loaded from specific nixpkgs revision:
`nix-shell --packages {{package1 package2 ...}} -I nixpkgs={{https://github.com/NixOS/nixpkgs/archive/nixpkgs_revision.tar.gz}}`
- Evaluate rest of file in specific interpreter, for use in `#!-scripts` (see <https://nixos.org/manual/nix/stable/#use-as-a-interpreter>):
`nix-shell -i {{interpreter}} --packages {{package1 package2 ...}}`
2 changes: 1 addition & 1 deletion general/zsh
Submodule zsh updated 1 files
+39 −0 completions/_nix-shell

0 comments on commit f54890d

Please sign in to comment.