Enable unfree packages with `nosys` flake

In a flake that uses flake-utils, unfree packages can be allowed with

let pkgs = import nixpkgs { inherit system; config.allowUnfree = true; ... };

In a flake which uses nosys instead of flake-utils, how would you do the equivalent?

The import of nixpkgs happens in the bowels of nosys and I can’t seem to find anywhere else where this setting can be injected in a way that works.

numtide’s nixpkgs-unfree could help here as a drop in method.

looking at the example in the read me, this may also work

# ./flake/outputs.nix
{
  self,
  nixpkgs, # <---- This `nixpkgs` has systems removed e.g. legacyPackages.zlib
  ...,
}: let
  # this is what was originally used
  # inherit (nixpkgs.legacyPackages) pkgs;

  # 
  pkgs = import nixpkgs {
    inherit (nixpkgs.legacyPackages) system;
    config.allowUnfree = true;
  };
in {
  # system dependant outputs
  devShells.default = self.devShells.dev;
  devShells.dev = pkgs.mkShell {
    buildInputs = with pkgs; [/* ... */];
  };
}

Hmm, this works, but I don’t understand how.

import takes a path to a file; surely the nixpkgs which is passed into this function (output.nix) has already been imported (the fact that we can inherit from it, seems to confirm this) so how can it be imported again?

There must be something that I’m missing about the capabilities of import and/or inherit.

An attrset that has an outPath attribute can be converted to a path. And flake inputs for example have an outPath attribute:

$ nix repl

nix-repl> pkgs = import { outPath = ~/src/nixpkgs; } { }

nix-repl> pkgs.hello
«derivation /nix/store/c3fhwyqcwakgfw51bnkgd73872f96ck0-hello-2.12.1.drv»
1 Like