update modules and use modules mylib
This commit is contained in:
@ -34,7 +34,6 @@ rec {
|
|||||||
modules.flatpak = {
|
modules.flatpak = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
# TODO: Make these active by default and remove the links if disabled
|
|
||||||
fontFix = true;
|
fontFix = true;
|
||||||
iconFix = true;
|
iconFix = true;
|
||||||
autoUpdate = true;
|
autoUpdate = true;
|
||||||
|
@ -1,19 +1,27 @@
|
|||||||
{ inputs, pkgs, lib, ... }:
|
{ inputs, pkgs, lib, ... }:
|
||||||
|
|
||||||
let
|
rec {
|
||||||
|
mkBoolOpt = def: desc:
|
||||||
in {
|
lib.mkOption {
|
||||||
mkBoolOpt = { def, desc ? "" }:
|
|
||||||
{
|
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = def;
|
default = def;
|
||||||
description = desc;
|
description = desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
linkMutable = { src, dest, after }:
|
mkElse = pred: do:
|
||||||
lib.hm.dag.entryAfter [ "writeBoundary" ] ++ after ''
|
(lib.mkIf (!pred) do);
|
||||||
|
|
||||||
|
mkLink = src: dest:
|
||||||
|
''
|
||||||
if [ ! -L "${dest}" ]; then
|
if [ ! -L "${dest}" ]; then
|
||||||
ln -sf ${src} ${dest}
|
ln -sf ${src} ${dest}
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
mkUnlink = dest:
|
||||||
|
''
|
||||||
|
if [ -L "${dest}" ]; then
|
||||||
|
rm ${dest}
|
||||||
|
fi
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, mylib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
with mylib.modules;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.modules.audio;
|
cfg = config.modules.audio;
|
||||||
@ -8,38 +9,13 @@ in {
|
|||||||
imports = [ ];
|
imports = [ ];
|
||||||
|
|
||||||
options.modules.audio = {
|
options.modules.audio = {
|
||||||
enable = mkOption {
|
enable = mkBoolOpt false "Configure for realtime audio and enable a bunch of music production tools";
|
||||||
type = types.bool;
|
carla.enable = mkBoolOpt false "Enable Carla + guitar-specific stuff";
|
||||||
default = false;
|
bitwig.enable = mkBoolOpt false "Enable Bitwig Studio digital audio workstation";
|
||||||
description = "Configure for realtime audio and enable a bunch of music production tools";
|
|
||||||
};
|
|
||||||
|
|
||||||
carla.enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable Carla + guitar-specific stuff";
|
|
||||||
};
|
|
||||||
|
|
||||||
yabridge = {
|
yabridge = {
|
||||||
enable = mkOption {
|
enable = mkBoolOpt false "Enable yabridge + yabridgectl";
|
||||||
type = types.bool;
|
autoSync = mkBoolOpt false "Sync yabridge plugins on nixos-rebuild";
|
||||||
default = false;
|
|
||||||
description = "Enable yabridge + yabridgectl";
|
|
||||||
};
|
|
||||||
|
|
||||||
autoSync = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Sync yabridge plugins on nixos-rebuild";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
bitwig = {
|
|
||||||
enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable Bitwig Studio digital audio workstation";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extraPackages = mkOption {
|
extraPackages = mkOption {
|
||||||
@ -78,15 +54,14 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
home.activation = mkMerge [
|
home.activation = mkMerge [
|
||||||
|
# The module includes the default carla project with ArchetypePetrucci + ArchetypeGojira
|
||||||
(mkIf cfg.carla.enable {
|
(mkIf cfg.carla.enable {
|
||||||
|
linkCarlaConfig = hm.dag.entryAfter [ "writeBoundary" ]
|
||||||
# The module includes the default carla project with ArchetypePetrucci + ArchetypeGojira
|
(mkLink "${config.home.homeDirectory}/NixFlake/config/carla" "${config.home.homeDirectory}/.config/carla");
|
||||||
# TODO: I don't know if I should keep this
|
})
|
||||||
linkCarlaConfig = hm.dag.entryAfter [ "writeBoundary" ] ''
|
(mkElse cfg.carla.enable {
|
||||||
if [ ! -L "${config.home.homeDirectory}/.config/carla" ]; then
|
unlinkCarlaConfig = hm.dag.entryAfter [ "writeBoundary" ]
|
||||||
ln -sf ${config.home.homeDirectory}/NixFlake/config/carla ${config.home.homeDirectory}/.config/carla
|
(mkUnlink "${config.home.homeDirectory}/.config/carla");
|
||||||
fi
|
|
||||||
'';
|
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.yabridge.autoSync {
|
(mkIf cfg.yabridge.autoSync {
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
# https://nixos.org/manual/nixos/stable/index.html#sec-writing-modules
|
# https://nixos.org/manual/nixos/stable/index.html#sec-writing-modules
|
||||||
|
|
||||||
# This is a function with arguments
|
# This is a function with arguments
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, mylib, pkgs, ... }:
|
||||||
|
|
||||||
# We add stuff from lib to our namespace (mkOption...)
|
# We add stuff from lib to our namespace (mkOption...)
|
||||||
with lib;
|
with lib;
|
||||||
|
with mylib.modules;
|
||||||
|
|
||||||
let
|
let
|
||||||
# This is the current state of the option that this module defines
|
# This is the current state of the option that this module defines
|
||||||
@ -16,30 +17,12 @@ in {
|
|||||||
# Options is a vector of options this module defines
|
# Options is a vector of options this module defines
|
||||||
# This module defines only the "emacs" option and suboptions "enable" and "doom"
|
# This module defines only the "emacs" option and suboptions "enable" and "doom"
|
||||||
options.modules.emacs = {
|
options.modules.emacs = {
|
||||||
enable = mkOption {
|
enable = mkBoolOpt false "Enable the GNU Emacs editor";
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable the GNU Emacs editor";
|
|
||||||
};
|
|
||||||
|
|
||||||
doom = {
|
doom = {
|
||||||
enable = mkOption {
|
enable = mkBoolOpt false "Use the Doom Emacs framework";
|
||||||
type = types.bool;
|
autoSync = mkBoolOpt false "Sync Doom Emacs on nixos-rebuild";
|
||||||
default = false;
|
autoUpgrade = mkBoolOpt false "Upgrade Doom Emacs on nixos-rebuild";
|
||||||
description = "Use the Doom Emacs framework";
|
|
||||||
};
|
|
||||||
|
|
||||||
autoSync = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Sync Doom Emacs on nixos-rebuild";
|
|
||||||
};
|
|
||||||
|
|
||||||
autoUpgrade = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Automatically upgrade Doom Emacs on nixos-rebuild";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -108,22 +91,21 @@ in {
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
# With this approach we keep the config mutable as it is not copied and linked from store
|
# With this approach we keep the config mutable as it is not copied and linked from store
|
||||||
linkDoomConfig = hm.dag.entryAfter [ "writeBoundary" "installDoomEmacs" ] ''
|
linkDoomConfig = hm.dag.entryAfter [ "writeBoundary" "installDoomEmacs" ]
|
||||||
if [ ! -L "${config.home.homeDirectory}/.config/doom" ]; then
|
(mkLink "${config.home.homeDirectory}/NixFlake/config/doom" "${config.home.homeDirectory}/.config/doom");
|
||||||
ln -sf ${config.home.homeDirectory}/NixFlake/config/doom ${config.home.homeDirectory}/.config/doom
|
})
|
||||||
fi
|
(mkElse cfg.doom.enable {
|
||||||
'';
|
unlinkDoomConfig = hm.dag.entryAfter [ "writeBoundary" "installDoomEmacs" ]
|
||||||
|
(mkUnlink "${config.home.homeDirectory}/.config/doom");
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf (cfg.doom.enable && cfg.doom.autoSync) {
|
(mkIf (cfg.doom.enable && cfg.doom.autoSync) {
|
||||||
|
|
||||||
syncDoomEmacs = hm.dag.entryAfter [ "writeBoundary" "linkDoomConfig" ] ''
|
syncDoomEmacs = hm.dag.entryAfter [ "writeBoundary" "linkDoomConfig" ] ''
|
||||||
${config.home.homeDirectory}/.emacs.d/bin/doom sync
|
${config.home.homeDirectory}/.emacs.d/bin/doom sync
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf (cfg.doom.enable && cfg.doom.autoUpgrade) {
|
(mkIf (cfg.doom.enable && cfg.doom.autoUpgrade) {
|
||||||
|
|
||||||
upgradeDoomEmacs = hm.dag.entryAfter [ "writeBoundary" "linkDoomConfig" ] ''
|
upgradeDoomEmacs = hm.dag.entryAfter [ "writeBoundary" "linkDoomConfig" ] ''
|
||||||
${config.home.homeDirectory}/.emacs.d/bin/doom upgrade -!
|
${config.home.homeDirectory}/.emacs.d/bin/doom upgrade -!
|
||||||
'';
|
'';
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, mylib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
with mylib.modules;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.modules.flatpak;
|
cfg = config.modules.flatpak;
|
||||||
@ -8,53 +9,17 @@ in {
|
|||||||
imports = [ ];
|
imports = [ ];
|
||||||
|
|
||||||
options.modules.flatpak = {
|
options.modules.flatpak = {
|
||||||
enable = mkOption {
|
enable = mkBoolOpt false "Enable flatpak support";
|
||||||
type = types.bool;
|
fontFix = mkBoolOpt false "Link fonts to ~/.local/share/fonts so flatpak apps can find them";
|
||||||
default = false;
|
iconFix = mkBoolOpt false "Link icons to ~/.local/share/icons so flatpak apps can find them";
|
||||||
description = "Enable flatpak support";
|
autoUpdate = mkBoolOpt false "Update flatpak apps on nixos-rebuild";
|
||||||
};
|
autoPrune = mkBoolOpt false "Remove unused packages on nixos-rebuild";
|
||||||
|
|
||||||
fontFix = mkOption {
|
# TODO: Add library function to make this easier
|
||||||
type = types.bool;
|
# The flatpak name should be included and a list of all enabled apps should be available
|
||||||
default = false;
|
discord.enable = mkBoolOpt false "Enable Discord";
|
||||||
description = "Link fonts to ~/.local/share/fonts so flatpak apps can find them";
|
spotify.enable = mkBoolOpt false "Enable Spotify";
|
||||||
};
|
flatseal.enable = mkBoolOpt false "Enable Flatseal";
|
||||||
|
|
||||||
iconFix = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Link icons to ~/.local/share/icons so flatpak apps can find them";
|
|
||||||
};
|
|
||||||
|
|
||||||
autoUpdate = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Update flatpak apps on nixos-rebuild";
|
|
||||||
};
|
|
||||||
|
|
||||||
autoPrune = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Remove unused packages on nixos-rebuild";
|
|
||||||
};
|
|
||||||
|
|
||||||
discord.enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable Discord";
|
|
||||||
};
|
|
||||||
|
|
||||||
spotify.enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable Spotify";
|
|
||||||
};
|
|
||||||
|
|
||||||
flatseal.enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable Flatseal";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
@ -66,24 +31,26 @@ in {
|
|||||||
# ];
|
# ];
|
||||||
|
|
||||||
home.activation = mkMerge [
|
home.activation = mkMerge [
|
||||||
|
# We link like this to be able to address the absolute location, also the fonts won't get copied to store
|
||||||
|
# NOTE: This path contains all the fonts because fonts.fontDir.enable is true
|
||||||
(mkIf cfg.fontFix {
|
(mkIf cfg.fontFix {
|
||||||
# We link like this to be able to address the absolute location, also the fonts won't get copied to store
|
linkFontDir = lib.hm.dag.entryAfter [ "writeBoundary" ]
|
||||||
# NOTE: This path contains all the fonts because fonts.fontDir.enable is true
|
(mkLink "/run/current-system/sw/share/X11/fonts" "${config.home.homeDirectory}/.local/share/fonts");
|
||||||
linkFontDir = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
})
|
||||||
if [ ! -L "${config.home.homeDirectory}/.local/share/fonts" ]; then
|
(mkElse cfg.fontFix {
|
||||||
ln -sf /run/current-system/sw/share/X11/fonts ${config.home.homeDirectory}/.local/share/fonts
|
unlinkFontDir = lib.hm.dag.entryAfter [ "writeBoundary" ]
|
||||||
fi
|
(mkUnlink "${config.home.homeDirectory}/.local/share/fonts");
|
||||||
'';
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Fixes missing icons + cursor
|
||||||
|
# NOTE: This path works because we have homeManager.useUserPackages = true (everything is stored in /etc/profiles/)
|
||||||
(mkIf cfg.iconFix {
|
(mkIf cfg.iconFix {
|
||||||
# Fixes missing icons + cursor
|
linkIconDir = lib.hm.dag.entryAfter [ "writeBoundary" ]
|
||||||
# NOTE: This path works because we have homeManager.useUserPackages = true (everything is stored in /etc/profiles/)
|
(mkLink "/etc/profiles/per-user/christoph/share/icons" "${config.home.homeDirectory}/.local/share/icons");
|
||||||
linkIconDir = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
})
|
||||||
if [ ! -L "${config.home.homeDirectory}/.local/share/icons" ]; then
|
(mkElse cfg.iconFix {
|
||||||
ln -sf /etc/profiles/per-user/christoph/share/icons ${config.home.homeDirectory}/.local/share/icons
|
unlinkIconDir = lib.hm.dag.entryAfter [ "writeBoundary" ]
|
||||||
fi
|
(mkUnlink "${config.home.homeDirectory}/.local/share/icons");
|
||||||
'';
|
|
||||||
})
|
})
|
||||||
|
|
||||||
# TODO: I should find a smarter way than this to make it easy to add flatpak options
|
# TODO: I should find a smarter way than this to make it easy to add flatpak options
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, mylib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
with mylib.modules;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.modules.gaming;
|
cfg = config.modules.gaming;
|
||||||
|
Reference in New Issue
Block a user