Add options for unfree software and assets

pull/30/head
Simon Bruder 2021-01-03 16:28:35 +01:00
parent 5d616f4b64
commit 131d0cc1a5
Signed by: simon
GPG Key ID: 8D3C82F9F309F8EC
5 changed files with 49 additions and 9 deletions

View File

@ -15,6 +15,7 @@
media-proxy.enable = true;
restic.enable = true;
ssd.enable = true;
unfree.allowSoftware = true;
wireguard.home = {
enable = true;
address = "10.80.0.4";

View File

@ -20,6 +20,7 @@
];
};
ssd.enable = true;
unfree.allowSoftware = true;
wireguard.home = {
enable = true;
address = "10.80.0.5";

View File

@ -30,6 +30,7 @@
./ssh.nix
./tools.nix
./udev.nix
./unfree.nix
./wireguard
];
@ -97,15 +98,6 @@
systemd.services.nix-daemon.serviceConfig.CPUSchedulingPolicy = "batch";
nixpkgs.config = {
# Explicitly allow unfree packages (rule of thumb: assets ok, code not ok)
allowUnfreePredicate = (
pkg: builtins.elem (lib.getName pkg) [
"corefonts"
"vista-fonts"
"wallpaper-unfree" # defined in users/simon/modules/sway.nix
"p7zip" # exception: rar source code is not free, but available; p7zip with `enableUnfree` includes it
]
);
# Add unstable channel
packageOverrides = pkgs: {
unstable = import (import ../nix/sources.nix).nixpkgs-unstable {

33
modules/unfree.nix Normal file
View File

@ -0,0 +1,33 @@
{ config, lib, ... }:
let
cfg = config.sbruder.unfree;
in
{
# Options that affect multiple modules
options.sbruder = {
unfree = {
allowAssets = lib.mkOption {
default = true;
type = lib.types.bool;
description = "Allow restricted selection of unfree assets to be installed.";
};
allowSoftware = lib.mkOption {
default = false;
type = lib.types.bool;
description = "Allow restricted selection of unfree software to be installed.";
};
};
};
config = {
nixpkgs.config.allowUnfreePredicate = (pkg: builtins.elem (lib.getName pkg) (
lib.optionals cfg.allowAssets [
"corefonts"
"vista-fonts"
"wallpaper-unfree" # defined in users/simon/modules/sway.nix
] ++ lib.optionals cfg.allowSoftware [
"p7zip" # exception: rar source code is not free, but available; p7zip with `enableUnfree` includes it
]
));
};
}

View File

@ -24,12 +24,25 @@
home-manager.useGlobalPkgs = true;
home-manager.users.simon = { lib, pkgs, ... }: {
# FIXME: those options are duplicates from the system configuration
options.sbruder = {
gui.enable = lib.mkOption {
type = lib.types.bool;
default = config.sbruder.gui.enable;
description = "Whether to enable gui";
};
unfree = {
allowAssets = lib.mkOption {
default = config.sbruder.unfree.allowAssets;
type = lib.types.bool;
description = "Allow restricted selection of unfree assets to be installed.";
};
allowSoftware = lib.mkOption {
default = config.sbruder.unfree.allowSoftware;
type = lib.types.bool;
description = "Allow restricted selection of unfree software to be installed.";
};
};
};
imports = [ ./modules ];