Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdlib: add use_flake function #847

Merged
merged 1 commit into from
Nov 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions man/direnv-stdlib.1
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,19 @@ If you have a \fB\fCdefault.nix\fR or \fB\fCshell.nix\fR these will be used by d
.PP
See http://nixos.org/nix/manual/#sec-nix-shell

.SS \fB\fCuse flake [<installable>]\fR
.PP
Load the build environment of a derivation similar to \fB\fCnix develop\fR\&.

.PP
By default it will load the current folder flake.nix devShell attribute. Or
pass an "installable" like "nixpkgs#hello" to load all the build dependencies
of the hello package from the latest nixpkgs.

.PP
Note that the flakes feature is hidden behind an experimental flag, which you
will have to enable on your own. Flakes is not considered stable yet.

.SS \fB\fCuse guix [...]\fR
.PP
Load environment variables from \fB\fCguix environment\fR\&.
Expand Down
11 changes: 11 additions & 0 deletions man/direnv-stdlib.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ If you have a `default.nix` or `shell.nix` these will be used by default, but yo

See http://nixos.org/nix/manual/#sec-nix-shell

### `use flake [<installable>]`

Load the build environment of a derivation similar to `nix develop`.

By default it will load the current folder flake.nix devShell attribute. Or
pass an "installable" like "nixpkgs#hello" to load all the build dependencies
of the hello package from the latest nixpkgs.

Note that the flakes feature is hidden behind an experimental flag, which you
will have to enable on your own. Flakes is not considered stable yet.

### `use guix [...]`

Load environment variables from `guix environment`.
Expand Down
16 changes: 16 additions & 0 deletions stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,22 @@ const StdLib = "#!/usr/bin/env bash\n" +
" fi\n" +
"}\n" +
"\n" +
"# Usage: use_flake [<installable>]\n" +
"#\n" +
"# Load the build environment of a derivation similar to `nix develop`.\n" +
"#\n" +
"# By default it will load the current folder flake.nix devShell attribute. Or\n" +
"# pass an \"installable\" like \"nixpkgs#hello\" to load all the build\n" +
"# dependencies of the hello package from the latest nixpkgs.\n" +
"#\n" +
"# Note that the flakes feature is hidden behind an experimental flag, which\n" +
"# you will have to enable on your own. Flakes is not considered stable yet.\n" +
"use_flake() {\n" +
" watch_file flake.nix\n" +
" watch_file flake.lock\n" +
" eval \"$(nix print-dev-env --profile \"$(direnv_layout_dir)/flake-profile\" \"$@\")\"\n" +
"}\n" +
"\n" +
"# Usage: use_guix [...]\n" +
"#\n" +
"# Load environment variables from `guix environment`.\n" +
Expand Down
16 changes: 16 additions & 0 deletions stdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,22 @@ use_nix() {
fi
}

# Usage: use_flake [<installable>]
#
# Load the build environment of a derivation similar to `nix develop`.
#
# By default it will load the current folder flake.nix devShell attribute. Or
# pass an "installable" like "nixpkgs#hello" to load all the build
# dependencies of the hello package from the latest nixpkgs.
#
# Note that the flakes feature is hidden behind an experimental flag, which
# you will have to enable on your own. Flakes is not considered stable yet.
use_flake() {
watch_file flake.nix
watch_file flake.lock
eval "$(nix print-dev-env --profile "$(direnv_layout_dir)/flake-profile" "$@")"
}

# Usage: use_guix [...]
#
# Load environment variables from `guix environment`.
Expand Down