DeterminateSystems / nuenv

A Nushell environment for Nix
https://determinate.systems
MIT License
203 stars 16 forks source link

`nix run` returns empty record #4

Closed siph closed 1 year ago

siph commented 1 year ago

Using the template at the bottom of the readme:

# This example is only for x86_64-linux; adjust for your own platform
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    nuenv.url = "github:DeterminateSystems/nuenv";
  };

  outputs = { self, nixpkgs, nuenv }: let
    pkgs = import nixpkgs {
      system = "x86_64-linux";
      overlays = [ nuenv.overlays.nuenv ];
    };
  in {
    packages.x86_64-linux.run-me = pkgs.nuenv.mkScript {
      name = "run-me";
      script = ''
        def blue [msg: string] { $"(ansi blue)($msg)(ansi reset)" }
        blue "Hello world"
      '';
    };
  };
}

Running both of these commands result in an empty record:

> nix run .#run-me
╭──────────────╮
│ empty record │
╰──────────────╯
> nix build .#run-me
> ./result/bin/run-me
╭──────────────╮
│ empty record │
╰──────────────╯

Passing the result into nushell works as expected:

> nu ./result/bin/run-me
Hello world

Nushell version: 0.77.1

lucperkins commented 1 year ago

This is a Nushell version issue. I just tried running nix flake update && nix run .#run-me and got the same error as you. I've pinned Nixpkgs to a specific revision in a change I just pushed to flake.nix. Using that same revision should resolve this. I'll see if there's a fix for this for more recent versions.

siph commented 1 year ago

Cool. As a workaround I'm just using nixpkgs from neunv:

pkgs = import nuenv.inputs.nixpkgs {
  overlays = [ nuenv.overlays.nuenv ];
  inherit system;
};