home: Deduplicate inheritance of nixos options

Fixes #17
pull/30/head
Simon Bruder 2021-01-07 18:21:46 +01:00
parent b586b7d2b5
commit dfc4bab334
Signed by: simon
GPG Key ID: 8D3C82F9F309F8EC
1 changed files with 15 additions and 17 deletions

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 = [
(import "${(import ../../nix/sources.nix).home-manager}/nixos")
@ -24,24 +35,11 @@
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";
};
gui.enable = inheritOption "sbruder.gui.enable";
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.";
};
allowAssets = inheritOption "sbruder.unfree.allowAssets";
allowSoftware = inheritOption "sbruder.unfree.allowSoftware";
};
};