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

allowUnfree broken? #99

Open
stereomato opened this issue Mar 1, 2025 · 19 comments
Open

allowUnfree broken? #99

stereomato opened this issue Mar 1, 2025 · 19 comments

Comments

@stereomato
Copy link

All of a sudden I get failures to update my system flake, complaining about how allowUnfree should be turned on to install some extensions. I've checked around and it's not a nixOS or home-manager issue, but it seems to be from this flake.

@deemp
Copy link
Collaborator

deemp commented Mar 1, 2025

@stereomato I've applied fixes from nixpkgs to some extensions in #96 and decided to keep the unfree extensions unfree.

- Unfree ([wiki](https://wiki.nixos.org/wiki/Unfree_software)) extensions from `nixpkgs` stay unfree here (see [Special extensions](#special-extensions)). If you want to use unfree extensions, try one of the following ways:
- Allow unfree packages ([manual](https://nixos.org/manual/nixpkgs/stable/#sec-allow-unfree)).
- Update the license of a particular extension `(<publisher>.<name>.override { meta.license = [ ]; })`.

@deemp
Copy link
Collaborator

deemp commented Mar 1, 2025

@stereomato how do you use allowUnfree? Can you provide a flake with a reproduction?

@codgician
Copy link

codgician commented Mar 1, 2025

UPDATE: Sorry just tried and below suggestions aren't working in latest commit.

@stereomato Instead of using .extensions directly, try applying .overlays.default to your own nixpkgs as overlay. This may help solve the issue.

When you use .extensions directly, the default nixpkgs without allowUnfree enabled would be used for evaluation, see:

https://github.com/nix-community/nix-vscode-extensions/blob/02d071ae1fadb1a63c6122d307ca5eb7e6b4feb9/flake.nix#L249C1-L253C54

@codgician
Copy link

codgician commented Mar 1, 2025

A quick bisect show that this issue could be introduced by 7576a6a.

Repro using nix repl:

pkgs = import <nixpkgs> { config.allowUnfree = true; }


# Last known good commit: 780a1d3
x = builtins.getFlake "github:nix-community/nix-vscode-extensions/780a1d35ccd6158ed2c7d10d87c02825e97b4c89" 

# First broken commit: 7576a6a
x' = builtins.getFlake "github:nix-community/nix-vscode-extensions/7576a6a5245fa147d02523fb6968f196cae4aeec"


# Unfree extension with LKG, which evaluates successfully
(x.overlays.default pkgs pkgs).vscode-marketplace.ms-vscode-remote.remote-ssh

# Unfree extension with 7576a6a, which fails evaluation
(x'.overlays.default pkgs pkgs).vscode-marketplace.ms-vscode-remote.remote-ssh

Image

@stereomato
Copy link
Author

Yeah, I've had to use NIXPKGS_ALLOW_UNFREE with nixos-rebuild because of that. So, I didn't know that there was another way of using this flake, I just used .extensions because it seemed to make sense.

@jcszymansk
Copy link

I think I got it, the overlay is overriding the user's pkgs and instead using flake's own.

Please test https://github.com/jcszymansk/nix-vscode-extensions/tree/unfree-fix, seems to work for me, if it's ok I can PR it (or owners just copy it if they want, it's one line anyway...)

@stereomato
Copy link
Author

i'll try it ASAP

@deemp
Copy link
Collaborator

deemp commented Mar 1, 2025

@jcszymansk thanks, applied this fix in 7efef14

@stereomato
Copy link
Author

Alright, applying the overlay the way @codgician told me, it works fine now!

@benbridts
Copy link

benbridts commented Mar 5, 2025

This fails for me again with commit 5b14dfc (but works with d1b0158).
I'm using flakes with this configuration:

nixpkgs.config.allowUnfree = true;

Exact error:

Package ‘vscode-extension-ms-vscode-remote-remote-containers-0.400.0’ in /nix/store/64lxq5kn85vglf3xhbh0zxjj8hin3m42-source/pkgs/applications/editors/vscode/extensions/default.nix:3645 has an unfree license (‘unfree’), refusing to evaluate.

@deemp
Copy link
Collaborator

deemp commented Mar 5, 2025

@codgician @benbridts @stereomato @jcszymansk can you reproduce the problem with c7a72aa?

@codgician
Copy link

@codgician @benbridts @stereomato @jcszymansk can you reproduce the problem with c7a72aa?

I can't reproduce the issue using package overlay in my flake with c7a72aa.

Image

@benbridts
Copy link

I still have the same issue with c7a72aa

I am not using any overlays, so my flake looks more like ( I trimmed a bunch):

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions";
    lix-module.url = "https://git.lix.systems/lix-project/nixos-module/archive/2.92.0.tar.gz";
    nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    lix-module.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs =
    inputs@{
      self,
      nix-darwin,
      nixpkgs,
      lix-module,
      home-manager,
      nix-vscode-extensions,
    }:
    let
      configuration = {
        nixpkgs.config.allowUnfree = true;
      };
    in
    {

      # $ darwin-rebuild build --flake .#laptop
      darwinConfigurations = {
        laptop = nix-darwin.lib.darwinSystem {
          specialArgs = { inherit inputs; };
          modules = [
            configuration
            ./hosts/laptop.nix
          ];
        };
      };
    };
}
#laptop.nix
{pkgs,inputs,  ...}:
let
  user = "ben";
  marketplace = inputs.nix-vscode-extensions.extensions.${pkgs.system}.vscode-marketplace;
in
{
  home-manager.users.${user} =
    { pkgs, ... }:
    {
      programs = {
        vscode = {
          profiles.default.extensions =
            (with pkgs.vscode-extensions; [
              ms-azuretools.vscode-docker
            ])
            ++ (with marketplace; [
              ms-vscode-remote.remote-containers
            ]);
        };
      };
    };
}

@tennox
Copy link

tennox commented Mar 5, 2025

@benbridts same here - but if you use the overlay it works:

{ config, pkgs, inputs, lib, ... }:
let
  pkgs-ext = import inputs.nixpkgs {
    inherit (pkgs) system;
    config.allowUnfree = true;
    overlays = [ inputs.nix-vscode-extensions.overlays.default ];
  };
in
{
  programs.vscode = {
    extensions =
      with pkgs-ext; (
        let o = open-vsx; m = vscode-marketplace; in [
          o.mhutchie.git-graph
        ]
      );
  };
}

@deemp
Copy link
Collaborator

deemp commented Mar 5, 2025

I am not using any overlays

@benbridts the extensions attribute in this repo uses nixpkgs without allowUnfree = true. Hence, unfree extensions refuse to build.

If you want to use unfree extensions, you should apply the default overlay to your nixpkgs. See wiki.

@benbridts
Copy link

I can confirm that using

let
  pkgs-ext = import inputs.nixpkgs {
    inherit (pkgs) system;
    config.allowUnfree = true;
    overlays = [ inputs.nix-vscode-extensions.overlays.default ];
  };
  marketplace = pkgs-ext.vscode-marketplace;
in
# [...]
{
  programs.vscode.profiles.default.extensions = with marketplace; [ms-vscode-remote.remote-containers];
}

works for me too

@donferi
Copy link

donferi commented Mar 10, 2025

My setup looks a bit different and I'm a bit lost on how to make it work, was using this:

  # When applied, the nix-vscode-extensions (declared in the flake inputs) will
  # be accessible through 'pkgs.vscode-extensions'
  vscode-extensions = final: _prev: {
    vscode-extensions = inputs.nix-vscode-extensions.extensions.${final.system}.vscode-marketplace;
  }

And installing extensions like:

{ pkgs, ... }:

with pkgs.vscode-extensions;
[
  asvetliakov.vscode-neovim

I just can't figure out how to allowUnfree with this setup, would love some guidance

@deemp
Copy link
Collaborator

deemp commented Mar 11, 2025

@apockill
Copy link

@donferi let me know if you figure this out. My nix noob brain is lost, I'm just getting rid of vscode for now 😓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants