Open samuela opened 8 months ago
Same here
Any progress?
Any progress?
Use direnv vscode extension instead :3 works for me
Would greatly appreciate if this project could be extended to support flakes as well. Flakes have done a great job at increasing Nix's accessibility!
Would like to avoid adding another tool to the mix to setup vscode.
What works for me:
I either keep a my old shell.nix
file around and use devShells.default = import ./shell.nix { inherit pkgs; };
in the flake.nix
file.
Or I create a shell.nix
file with (builtins.getFlake ("git+file://" + toString ./.)).devShells.${builtins.currentSystem}.default
as content.
And then just use the shell.nix as normal with the vscode extention. (Credits: https://discourse.nixos.org/t/how-to-fetch-flake-in-shell-nix/39587/2 and https://github.com/SlimeVR/SlimeVR-Server/blob/d9955d10e3f055491cea4d6a7e7edef0788235f2/shell.nix#L2)
My approach has been to use flake-compat
shell.nix
:
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
).shellNix
Any progress?
Use direnv vscode extension instead :3 works for me
@nyabinary Can you explain how to use it? I've tried creating an envrc with just "nix develop" inside. This has been kind of buggy. WHen I try to hook it to my shell it evaluates the flake and drops me into the devshell, but then it throws an error saying its taking too long. Once I press Ctrl+C it continues to work. I think the problem is that it basically waits for "nix develop" to finish, meaning for me to exit the shell. Could you post your envrc?
I gave a shot at the direnv
extension, works perfectly.
@HendrikHuebner here is how I managed.
Content of .envrc
(taken from here
#!/bin/sh
#If already set (e.g. in github actions); use that instead
if [ -z "$GITHUB_TOKEN" ]; then
nix run nixpkgs#gh auth status || nix run nixpkgs#gh auth login
GITHUB_TOKEN="$(nix run nixpkgs#gh auth token)"
export GITHUB_TOKEN
fi
NIX_CONFIG="access-tokens = github.com=$GITHUB_TOKEN"
export NIX_CONFIG
use flake
Because my flake use private repo.
If you have a basic flake, you can simply use .envrc
:
use flake
Describe the bug This bug manifests with similar symptoms as in https://github.com/arrterian/nix-env-selector/issues/56... specifically stuck in the "Applying environment..." state, but AFAICT has a different root cause and I am therefore opening a separate issue.
When selecting a
flake.nix
from the nix-env-selector drop-down, the erroris shown in the developer console, and the tray icon stays in the "Applying environment..." spinner forever.
To Reproduce Steps to reproduce the behavior:
Nix-Env: Select environment...
and selectflake.nix
from the drop down.Expected behavior The environment equivalent to
nix develop
to be applied.Screenshots n/a
Environment:
Additional context n/a