nixpkgs.config: Add allowUnfreePackages option
Also make sure it merges correctly and verify with a test. This was added in nixpkgs some time ago and is quite a nice addition as it merges additively (in contrast to allowUnfreePredicate) thus allowing to localize allowUnfreePackage specifications to all the locations in your local config where unfree packages are added.
This commit is contained in:
parent
06648f4902
commit
a0a51c56f0
3 changed files with 51 additions and 2 deletions
45
tests/nixpkgs-config-allow-unfree.nix
Normal file
45
tests/nixpkgs-config-allow-unfree.nix
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# Check that nixpkgs.config.allowUnfreePackages is merged correctly
|
||||
# run with: nix-build release.nix -A tests.nixpkgs-config-allow-unfree
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
# Module 1: Define some unfree packages
|
||||
nixpkgs.config.allowUnfreePackages = [
|
||||
"vscode"
|
||||
"slack"
|
||||
];
|
||||
|
||||
# Module 2: Define more unfree packages (simulating multiple modules)
|
||||
# In a real scenario, this would be in a separate file
|
||||
imports = [
|
||||
(
|
||||
{ config, ... }:
|
||||
{
|
||||
nixpkgs.config.allowUnfreePackages = [
|
||||
"zoom"
|
||||
"discord"
|
||||
];
|
||||
}
|
||||
)
|
||||
];
|
||||
|
||||
test = ''
|
||||
echo checking allowUnfreePackages merging >&2
|
||||
|
||||
# Verify that all packages from both modules are present
|
||||
expected_packages=("discord" "slack" "vscode" "zoom")
|
||||
actual_packages=(${builtins.toString (builtins.sort builtins.lessThan config.nixpkgs.config.allowUnfreePackages)})
|
||||
|
||||
for pkg in "''${expected_packages[@]}"; do
|
||||
if [[ ! " ''${actual_packages[@]} " =~ " $pkg " ]]; then
|
||||
echo "ERROR: Expected package '$pkg' not found in allowUnfreePackages" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue