home: Use nixosConfig instead of inheriting options

This commit is contained in:
Simon Bruder 2021-02-12 21:12:03 +01:00
parent 474cc7d0f7
commit 1a7ef37376
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC
13 changed files with 30 additions and 51 deletions

View file

@ -1,15 +1,4 @@
{ 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")
@ -34,16 +23,6 @@ in
home-manager.useGlobalPkgs = true;
home-manager.users.simon = { lib, pkgs, ... }: {
options.sbruder = {
full = inheritOption "sbruder.full";
gui.enable = inheritOption "sbruder.gui.enable";
games.enable = inheritOption "sbruder.games.enable";
unfree = {
allowAssets = inheritOption "sbruder.unfree.allowAssets";
allowSoftware = inheritOption "sbruder.unfree.allowSoftware";
};
};
imports = [ ./modules ];
config = {

View file

@ -1,4 +1,4 @@
{ config, ... }:
{ nixosConfig, ... }:
let
common = import ./common.nix;
solarized = common.colorschemes.solarized;
@ -46,7 +46,7 @@ let
in
{
programs.alacritty = {
enable = config.sbruder.gui.enable;
enable = nixosConfig.sbruder.gui.enable;
settings = {
font = {
normal = {

View file

@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }:
{ lib, nixosConfig, pkgs, ... }:
lib.mkIf config.sbruder.gui.enable {
lib.mkIf nixosConfig.sbruder.gui.enable {
home.packages = [
pkgs.anki
];

View file

@ -1,5 +1,5 @@
{ config, lib, pkgs, ... }:
lib.mkIf config.sbruder.games.enable {
{ lib, nixosConfig, pkgs, ... }:
lib.mkIf nixosConfig.sbruder.games.enable {
home.packages = [ ]
++ lib.optional config.sbruder.unfree.allowSoftware pkgs.unstable.osu-lazer-container;
++ lib.optional nixosConfig.sbruder.unfree.allowSoftware pkgs.unstable.osu-lazer-container;
}

View file

@ -1,8 +1,8 @@
{ config, pkgs, ... }:
{ nixosConfig, pkgs, ... }:
{
gtk = {
enable = config.sbruder.gui.enable;
enable = nixosConfig.sbruder.gui.enable;
font.name = "sans-serif 10";
theme = {
package = pkgs.gnome-themes-extra;

View file

@ -1,8 +1,8 @@
{ config, lib, pkgs, ... }:
{ config, lib, nixosConfig, pkgs, ... }:
# I only use mpd on gui systems. If I should ever need it on a headless system,
# I will add a separate option.
lib.mkIf config.sbruder.gui.enable {
lib.mkIf nixosConfig.sbruder.gui.enable {
services.mpd = {
enable = true;
musicDirectory = "~/Music";

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, nixosConfig, pkgs, ... }:
let
mpv-prescalers = pkgs.fetchFromGitHub {
owner = "bjin";
@ -64,7 +64,7 @@ let
in
{
programs.mpv = {
enable = config.sbruder.gui.enable;
enable = nixosConfig.sbruder.gui.enable;
config = {
# Main application font

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, nixosConfig, pkgs, ... }:
let
languageClientSettings = pkgs.writeText "LanguageClient.json" (builtins.toJSON {
rust.clippy_preference = "on";
@ -246,7 +246,7 @@ in
autocmd BufEnter *.tex syntax sync fromstart
'';
}
] ++ (lib.optionals config.sbruder.full [
] ++ (lib.optionals nixosConfig.sbruder.full [
{
plugin = LanguageClient-neovim;
config = ''

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ lib, nixosConfig, pkgs, ... }:
let
waifu2x-photo-models = pkgs.stdenvNoCC.mkDerivation {
name = "waifu2x-photo-models";
@ -51,7 +51,7 @@ in
# file format tools
imagemagick # image conversion
(p7zip.override { enableUnfree = config.sbruder.unfree.allowSoftware; }) # 7z cli (with optional rar support)
(p7zip.override { enableUnfree = nixosConfig.sbruder.unfree.allowSoftware; }) # 7z cli (with optional rar support)
pdftk # pdf multitool
sqlite-interactive # cli for sqlite databses
@ -134,7 +134,7 @@ in
# documents
mupdf # document (pdf) viewer and tools
poppler_utils # pdf manipulation tools
] ++ lib.optionals config.sbruder.gui.enable [
] ++ lib.optionals nixosConfig.sbruder.gui.enable [
# communication
claws-mail # email client that looks ugly but just works
firefox-wayland # the least bad browser
@ -177,7 +177,7 @@ in
wl-clipboard # not really gui, but cli tool to manage wayland clipboard
wxhexeditor # hex editor
xfce.thunar # graphical file manager
] ++ lib.optionals (config.sbruder.gui.enable && config.sbruder.full) [
] ++ lib.optionals (nixosConfig.sbruder.gui.enable && nixosConfig.sbruder.full) [
# communication
ungoogled-chromium # useful for exporting pages as pdf
@ -194,7 +194,7 @@ in
# office
jameica # application framework (used for hibiscus online banking)
pdfsam-basic # pdf multitool
] ++ lib.optionals (config.sbruder.gui.enable && !config.sbruder.full) [
] ++ lib.optionals (nixosConfig.sbruder.gui.enable && !nixosConfig.sbruder.full) [
# creative/design
gimp # without plugins
];

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, nixosConfig, pkgs, ... }:
let
common = import ./common.nix;
solarized = common.colorschemes.solarized;
@ -19,12 +19,12 @@ let
meta.license = lib.licenses.cc0;
};
wallpaper = if config.sbruder.unfree.allowAssets then wallpaperUnfree else wallpaperFree;
wallpaper = if nixosConfig.sbruder.unfree.allowAssets then wallpaperUnfree else wallpaperFree;
cfg = config.wayland.windowManager.sway.config;
thinsp = "";
in
lib.mkIf config.sbruder.gui.enable {
lib.mkIf nixosConfig.sbruder.gui.enable {
wayland.windowManager.sway = {
enable = true;
systemdIntegration = true;

View file

@ -1,6 +1,6 @@
{ config, lib, ... }:
{ lib, nixosConfig, ... }:
lib.mkIf config.sbruder.gui.enable {
lib.mkIf nixosConfig.sbruder.gui.enable {
home.file.".XCompose".text = ''
include "%L"

View file

@ -1,8 +1,8 @@
{ config, lib, ... }:
{ lib, nixosConfig, ... }:
{
xdg.mimeApps = {
enable = config.sbruder.gui.enable;
enable = nixosConfig.sbruder.gui.enable;
defaultApplications = {
"application/pdf" = "org.pwmt.zathura.desktop";
"image/png" = "mpv.desktop";
@ -11,7 +11,7 @@
};
# Some programs overwrite the mimeapps.list symlink with a normal file which
# makes home-manager activation fail
xdg.configFile = lib.mkIf config.sbruder.gui.enable {
xdg.configFile = lib.mkIf nixosConfig.sbruder.gui.enable {
"mimeapps.list".force = true;
};
}

View file

@ -1,4 +1,4 @@
{ config, ... }:
{ nixosConfig, ... }:
let
common = import ./common.nix;
solarized = common.colorschemes.solarized;
@ -45,7 +45,7 @@ let
in
{
programs.zathura = {
enable = config.sbruder.gui.enable;
enable = nixosConfig.sbruder.gui.enable;
options = {
selection-clipboard = "clipboard";
} // colorschemes.solarized-dark;