2024-08-13 14:46:55 +02:00
|
|
|
{ config, lib, ... }:
|
|
|
|
|
|
|
|
# See also: ./nur-and-unstable.nix to allow unfree packages from "unstable".
|
|
|
|
# See also: ./base.nix for unfree firmware.
|
|
|
|
|
|
|
|
# This file adds the ability to whitelist unfree packages in different .nix config files.
|
2024-08-16 10:56:56 +02:00
|
|
|
# See https://github.com/NixOS/nixpkgs/issues/55674#issuecomment-1220216445 for why this is necessary.
|
2024-08-13 14:46:55 +02:00
|
|
|
# Example: Instead of
|
|
|
|
# nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
|
|
|
|
# "obsidian"
|
|
|
|
# ];
|
|
|
|
# add the following
|
|
|
|
# allowUnfree = [ "obsidian" ];
|
|
|
|
|
2024-08-16 10:56:56 +02:00
|
|
|
# Source:
|
|
|
|
# https://discourse.nixos.org/t/use-nixpkgs-config-allowunfreepredicate-in-multiple-nix-file/36590/2
|
|
|
|
# -> Implementation: https://codeberg.org/AndrewKvalheim/configuration/src/commit/11794e595144500a6c2be706e42ed698b1788bb8/packages/nixpkgs-issue-55674.nix
|
|
|
|
# -> Example: https://codeberg.org/AndrewKvalheim/configuration/src/commit/11794e595144500a6c2be706e42ed698b1788bb8/common/components/printer.system.nix#L7
|
|
|
|
|
|
|
|
# TODO: Once https://github.com/NixOS/nixpkgs/issues/55674 is merged, this is obsolete.
|
|
|
|
|
2024-08-13 14:46:55 +02:00
|
|
|
let
|
|
|
|
inherit (builtins) elem;
|
|
|
|
inherit (lib) getName mkOption;
|
|
|
|
inherit (lib.types) listOf str;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.allowUnfree = mkOption { type = listOf str; default = [ ]; };
|
|
|
|
config.nixpkgs.config.allowUnfreePredicate = p: elem (getName p) config.allowUnfree;
|
|
|
|
}
|