Add options for unfree software and assets

This commit is contained in:
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; media-proxy.enable = true;
restic.enable = true; restic.enable = true;
ssd.enable = true; ssd.enable = true;
unfree.allowSoftware = true;
wireguard.home = { wireguard.home = {
enable = true; enable = true;
address = "10.80.0.4"; address = "10.80.0.4";

View file

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

View file

@ -30,6 +30,7 @@
./ssh.nix ./ssh.nix
./tools.nix ./tools.nix
./udev.nix ./udev.nix
./unfree.nix
./wireguard ./wireguard
]; ];
@ -97,15 +98,6 @@
systemd.services.nix-daemon.serviceConfig.CPUSchedulingPolicy = "batch"; systemd.services.nix-daemon.serviceConfig.CPUSchedulingPolicy = "batch";
nixpkgs.config = { 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 # Add unstable channel
packageOverrides = pkgs: { packageOverrides = pkgs: {
unstable = import (import ../nix/sources.nix).nixpkgs-unstable { 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.useGlobalPkgs = true;
home-manager.users.simon = { lib, pkgs, ... }: { home-manager.users.simon = { lib, pkgs, ... }: {
# FIXME: those options are duplicates from the system configuration
options.sbruder = { options.sbruder = {
gui.enable = lib.mkOption { gui.enable = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = config.sbruder.gui.enable; default = config.sbruder.gui.enable;
description = "Whether to enable gui"; 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 ]; imports = [ ./modules ];