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

Non-free nix packages (under Arch Linux) are failing to upgrade #389

Closed
lisandrocarmona opened this issue Mar 21, 2023 · 2 comments
Closed

Comments

@lisandrocarmona
Copy link

What did you expect to happen?

Topgrade upgrade nixpkgs installed in Arch Linux.

What actually happened?

Non-free nixpkgs are not being upgraded and the output error is:

Additional Details

  • Which operating system or Linux distribution are you using? Arch Linux
  • How did you install Topgrade? Via cargo.
  • Which version are you running? Topgrade 10.3.3
error: Package ‘geekbench-6.0.1’ in /nix/store/jlhl9fc6x7a54y23yxkx6822ymqzsp7a-source/pkgs/tools/misc/geekbench/6.nix:44 has an unfree license (‘unfree’), refusing to evaluate.

a) To temporarily allow unfree packages, you can use an environment variable
for a single invocation of the nix tools.

$ export NIXPKGS_ALLOW_UNFREE=1

Note: For `nix shell`, `nix build`, `nix develop` or any other Nix 2.4+
(Flake) command, `--impure` must be passed in order to read this
environment variable.

b) For `nixos-rebuild` you can set
{ nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

Alternatively you can configure a predicate to allow specific packages:
{ nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"geekbench"
];
}

c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
{ allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.

I've tried the following to address the issue without luck:

  1. export NIXPKGS_ALLOW_UNFREE=1 && topgrade
  2. Create a ~/.config/nixpkgs/config.nix file with { allowUnfree = true; } as its content.
  3. In topgrade.toml config file, tested all the following nix_arguments one by one:
    a) nix_arguments = "impure"
    b) nix_arguments = "--allowUnfree"
    c) nix_arguments = "--allow-unfree"

What can I do? Thanks for your support.

@SteveLauC
Copy link
Member

Hi, sorry for the late reply:)

Here is the code snippet to update Nix packages:

pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
let nix = require("nix")?;
let nix_channel = require("nix-channel")?;
let nix_env = require("nix-env")?;
// TODO: Is None possible here?
let profile_path = match home::home_dir() {
Some(home) => Path::new(&home).join(".nix-profile"),
None => Path::new("/nix/var/nix/profiles/per-user/default").into(),
};
debug!("nix profile: {:?}", profile_path);
let manifest_json_path = profile_path.join("manifest.json");
let output = Command::new(&nix_env).args(["--query", "nix"]).output_checked_utf8();
debug!("nix-env output: {:?}", output);
let should_self_upgrade = output.is_ok();
print_separator("Nix");
let multi_user = fs::metadata(&nix)?.uid() == 0;
debug!("Multi user nix: {}", multi_user);
#[cfg(target_os = "linux")]
{
use super::linux::Distribution;
if let Ok(Distribution::NixOS) = Distribution::detect() {
return Err(SkipStep(String::from("Nix on NixOS must be upgraded via nixos-rebuild switch")).into());
}
}
#[cfg(target_os = "macos")]
{
if let Ok(..) = require("darwin-rebuild") {
return Err(SkipStep(String::from(
"Nix-darwin on macOS must be upgraded via darwin-rebuild switch",
))
.into());
}
}
let run_type = ctx.run_type();
if should_self_upgrade {
if multi_user {
ctx.execute_elevated(&nix, true)?.arg("upgrade-nix").status_checked()?;
} else {
run_type.execute(&nix).arg("upgrade-nix").status_checked()?;
}
}
run_type.execute(nix_channel).arg("--update").status_checked()?;
if Path::new(&manifest_json_path).exists() {
run_type
.execute(&nix)
.arg("profile")
.arg("upgrade")
.arg(".*")
.status_checked()
} else {
run_type.execute(&nix_env).arg("--upgrade").status_checked()
}
}

basically, it is doing the following things:

$ nix-env --query nix      # If this cmd executes successfully, run the next cmd
$ nix upgrade-nix

$ nix-channel --update

$ nix profile upgrade .*   # or
$ nix-env --upgrade

Would you like to give the above commands a try to see if it can reproduce this issue? And for the possible solutions you have tried, would you like to give them another test with the above commands?

@lisandrocarmona
Copy link
Author

Now it's my turn to be sorry for the delay. For any reason, the issue disappeared and nixpkgs are upgrading again. Sorry for not being useful and posting the solution (if any) for the issue.

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

2 participants