home: Deduplicate inheritance of nixos options

Fixes #17
This commit is contained in:
Simon Bruder 2021-01-07 18:21:46 +01:00
parent b586b7d2b5
commit dfc4bab334
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC

View file

@ -1,4 +1,15 @@
{ config, pkgs, ... }: { config, options, pkgs, ... }:
let
# hacky way of inheriting a nixos option into home manager
inheritOption = name:
let
path = pkgs.lib.splitString "." name;
option = pkgs.lib.getAttrFromPath path options;
value = pkgs.lib.getAttrFromPath path config;
in
# setting `value` doesnt work (always is default value in other modules)
option // { default = value; };
in
{ {
imports = [ imports = [
(import "${(import ../../nix/sources.nix).home-manager}/nixos") (import "${(import ../../nix/sources.nix).home-manager}/nixos")
@ -24,24 +35,11 @@
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 = inheritOption "sbruder.gui.enable";
type = lib.types.bool;
default = config.sbruder.gui.enable;
description = "Whether to enable gui";
};
unfree = { unfree = {
allowAssets = lib.mkOption { allowAssets = inheritOption "sbruder.unfree.allowAssets";
default = config.sbruder.unfree.allowAssets; allowSoftware = inheritOption "sbruder.unfree.allowSoftware";
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.";
};
}; };
}; };