Nix (not NixOS): Altering configurations

I am attempting to update Nix in order to update certain settings. For example:

allowUnfree = true;

Which file(s) do I modify? Which command(s) do I execute to update the settings?

How can I create a configuration file that contains multiple packages?

Here is how you can do it in a single derivation

{ pkgs ? import <nixpkgs> { 
      config.allowUnfree = true; 
    } 
}:
pkgs.runCommand "hello" { } ''
  mkdir -p $out
  echo "echo hello world" > $out/hello
  chmod +x $out/hello 
''

Appreciate the response. The snippet above is inserted into which file(s)? Just to restate, this is for Nix not NixOS.

Added to the top of a default.nix/shell.nix file you are using to build with nix.

# ./default.nix
{ pkgs ? import <nixpkgs> {
      config.allowUnfree = true;
    }
}:

pkgs.python3.pkgs.buildPythonApplication {
  name = "git-identity";
  src = pkgs.lib.sourceByRegex ./. [
    "git-identity\.py"
    "setup\.py"
  ];
  propagatedBuildInputs = [];
}
1 Like

you can also add it to ~/.config/nix/nix.conf
https://nixos.wiki/wiki/FAQ/How_can_I_install_a_proprietary_or_unfree_package%3F

{
  # [...]
  allowUnfree = true;
}

The above works for non-NixOS.

2 Likes