Don't know how to use VSCode Insiders nix configuration snippet

Hi, being a total NixOS noob, I have no idea where or how to put in this snippet mentioned in here in my /etc/nixos/configuration.nix.

I put it like so

 # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
      (vscode.override { isInsiders = true; }).overrideAttrs (oldAttrs: rec {
        src = (builtins.fetchTarball {
        url = "https://code.visualstudio.com/sha/download?build=insider&os=linux-x64";
        sha256 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
      });
      version = "latest";
      buildInputs = oldAttrs.buildInputs ++ [ pkgs.krb5 ];
      })

    uhk-udev-rules
    emacs
    vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
    wget
    aria
    ripgrep
...

but only got this

building Nix...
building the system configuration...
error: A definition for option `environment.systemPackages."[definition 1-entry 1]"' is not of type `package'. Definition values:
       - In `/etc/nixos/configuration.nix': <function>
(use '--show-trace' to show detailed location information)

And the trace was way too long to be useful, and wasn’t anywhere my Nix code at all.

Mhhm, doesn’t look wrong to me. It will probably tell you that the given sha256 "AAAAA..." doesn’t match the actual sha of the downloaded tarball, and you will have to replace "AAAA..." with the correct sha256 (it should tell you what the sha of the tarball actually was).

Apart from that, maybe try wrapping () around the whole expression?

I.e.:

with pkgs; [
      # from https://nixos.wiki/wiki/Visual_Studio_Code#Insiders_Build
      ((vscode.override { isInsiders = true; }).overrideAttrs (oldAttrs: rec {
        src = (builtins.fetchTarball {
          url = "https://code.visualstudio.com/sha/download?build=insider&os=linux-x64";
          sha256 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
        });
      version = "latest";
      buildInputs = oldAttrs.buildInputs ++ [ pkgs.krb5 ];
      }))

    uhk-udev-rules
    ...

Ah yeah, judging from the error message that should be it: It detects the first definition as a function, probably overrideAttrs, and detects the following argument list (oldAttrs: ... as an individual package. But that is not what you meant, you want both of them evaluated together, so the brackets around everything should help :slight_smile:

You could also do it like this:

environment.systemPackages = let
  # from https://nixos.wiki/wiki/Visual_Studio_Code#Insiders_Build
  code-insiders = (pkgs.vscode.override { isInsiders = true; }).overrideAttrs (oldAttrs: rec {
    src = (builtins.fetchTarball {
      url = "https://code.visualstudio.com/sha/download?build=insider&os=linux-x64";
      sha256 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
    });
    version = "latest";
    buildInputs = oldAttrs.buildInputs ++ [ pkgs.krb5 ];
  });
in (with pkgs; [
    code-insiders

    uhk-udev-rules
    ...
]);

Which makes it look a bit cleaner, by pulling the definition out into its own let-binding :slight_smile:

I just put the comments in there for clarity, I like keeping those notes around in my config, really a cool part of declaring your system through code: You can add comments :smiley:

Thanks! The second one I can understand better - but I moved back to Manjaro because I needed things to work asap. Going to try out Nix slowly just for individual projects this time.

3 Likes