diff --git a/flake.nix b/flake.nix index e95daf9..2146bb9 100755 --- a/flake.nix +++ b/flake.nix @@ -68,6 +68,16 @@ # Home manager home-manager.nixosModules.home-manager ./home-manager + { + ty-home-manager-options = { + plasma.enable = true; + beets.enable = true; + firefox.enable = true; + thunderbird.enable = true; + rescrobbled.enable = true; + vscode.enable = true; + }; + } ]; specialArgs = { @@ -84,28 +94,25 @@ # Better command-not-found nix-index-database.nixosModules.nix-index { programs.nix-index-database.comma.enable = true; } + + # Home manager + home-manager.nixosModules.home-manager + ./home-manager + { + ty-home-manager-options = { + plasma.enable = false; + beets.enable = false; + firefox.enable = false; + thunderbird.enable = false; + rescrobbled.enable = false; + vscode.enable = false; + }; + } ]; specialArgs = { inherit inputs system secrets; }; }; - - # Add home manager configuration compatibility to the main flake - homeConfigurations."ty" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - - # Specify your home configuration modules here, for example, - # the path to your home.nix. - modules = [ - plasma-manager.homeManagerModules.plasma-manager - ./home-manager/custom-modules - ./home-manager/home.nix - ]; - - extraSpecialArgs = { - inherit inputs system secrets; - }; - }; }; } \ No newline at end of file diff --git a/home-manager/default.nix b/home-manager/default.nix index 9c76ef5..28eac10 100755 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -1,19 +1,31 @@ -{ inputs, system, secrets, ... }: +{ inputs, system, secrets, lib, config, ... }: { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.sharedModules = [ - inputs.plasma-manager.homeManagerModules.plasma-manager - ./custom-modules - ]; - home-manager.extraSpecialArgs = { - inherit inputs system secrets; + options.ty-home-manager-options = { + plasma.enable = lib.mkEnableOption "plasma configuration"; + firefox.enable = lib.mkEnableOption "firefox configuration"; + thunderbird.enable = lib.mkEnableOption "thunderbird configuration"; + vscode.enable = lib.mkEnableOption "vscode configuration"; + beets.enable = lib.mkEnableOption "beets configuration"; + rescrobbled.enable = lib.mkEnableOption "rescrobbled configuration"; }; - home-manager.backupFileExtension = "backup"; - home-manager.users.ty = { - imports = [ - ./home.nix + config = { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.sharedModules = [ + inputs.plasma-manager.homeManagerModules.plasma-manager + ./custom-modules ]; + home-manager.extraSpecialArgs = { + inherit inputs system secrets; + inherit (config) ty-home-manager-options; + }; + home-manager.backupFileExtension = "backup"; + + home-manager.users.ty = { + imports = [ + ./home.nix + ]; + }; }; } \ No newline at end of file diff --git a/home-manager/home.nix b/home-manager/home.nix index 9cb1a64..df4f9d7 100755 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -1,4 +1,4 @@ -{ ... }: +{ lib, config, ... }: { home.stateVersion = "24.05"; home.username = "ty"; diff --git a/home-manager/modules/accounts/default.nix b/home-manager/modules/accounts/default.nix index 9eaca80..60bd125 100755 --- a/home-manager/modules/accounts/default.nix +++ b/home-manager/modules/accounts/default.nix @@ -1,4 +1,4 @@ -{ ... }: +{ lib, config, ... }: { imports = [ ./email.nix diff --git a/home-manager/modules/accounts/email.nix b/home-manager/modules/accounts/email.nix index 80778d0..09f5b91 100755 --- a/home-manager/modules/accounts/email.nix +++ b/home-manager/modules/accounts/email.nix @@ -1,6 +1,6 @@ -{ ... }: +{ lib, ty-home-manager-options, ... }: { - accounts.email.accounts = { + accounts.email.accounts = lib.mkIf ty-home-manager-options.thunderbird.enable { PurelyMail = rec { realName = "Tyler Beckman"; address = "ty@myriation.xyz"; diff --git a/home-manager/modules/beets.nix b/home-manager/modules/beets.nix index 670f412..687790c 100644 --- a/home-manager/modules/beets.nix +++ b/home-manager/modules/beets.nix @@ -1,6 +1,6 @@ -{ lib, secrets, ... }: +{ lib, secrets, ty-home-manager-options, ... }: { - programs.beets = { + programs.beets = lib.mkIf ty-home-manager-options.beets.enable { enable = true; settings = { diff --git a/home-manager/modules/desktop.nix b/home-manager/modules/desktop.nix index 08338e4..ccc3957 100644 --- a/home-manager/modules/desktop.nix +++ b/home-manager/modules/desktop.nix @@ -1,6 +1,6 @@ -{ ... }: +{ lib, ty-home-manager-options, ... }: { - xdg.desktopEntries = { + xdg.desktopEntries = lib.mkIf ty-home-manager-options.plasma.enable { # Override vesktop for matching icon in beautyline (make it generic discord icon) vesktop = { categories = [ "Network" "InstantMessaging" "Chat" ]; diff --git a/home-manager/modules/firefox.nix b/home-manager/modules/firefox.nix index cf89f40..45f3357 100755 --- a/home-manager/modules/firefox.nix +++ b/home-manager/modules/firefox.nix @@ -1,6 +1,6 @@ -{ pkgs, inputs, system, ... }: +{ pkgs, inputs, system, lib, ty-home-manager-options, ... }: { - programs.firefox = { + programs.firefox = lib.mkIf ty-home-manager-options.firefox.enable { enable = true; policies = { ExtensionSettings = { diff --git a/home-manager/modules/gtk.nix b/home-manager/modules/gtk.nix index 1ca0476..62e3fa2 100644 --- a/home-manager/modules/gtk.nix +++ b/home-manager/modules/gtk.nix @@ -1,25 +1,27 @@ -{ pkgs, config, ... }: +{ pkgs, lib, config, ty-home-manager-options, ... }: { - gtk = { - enable = true; + config = lib.mkIf ty-home-manager-options.plasma.enable { + gtk = { + enable = true; - gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc"; + gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc"; - theme = { - name = "Breeze-Dark"; - package = pkgs.kdePackages.breeze-gtk; - }; - cursorTheme = { - name = "Vimix-cursors"; - package = pkgs.vimix-cursors; - size = 24; - }; - iconTheme = { - name = "beautyline-garuda"; - package = (pkgs.callPackage ../../packages/beautyline {}); + theme = { + name = "Breeze-Dark"; + package = pkgs.kdePackages.breeze-gtk; + }; + cursorTheme = { + name = "Vimix-cursors"; + package = pkgs.vimix-cursors; + size = 24; + }; + iconTheme = { + name = "beautyline-garuda"; + package = (pkgs.callPackage ../../packages/beautyline {}); + }; }; + + # Tell home-manager to force overwrite the gtk2 configuration as it keeps getting overwritten by something (likely plasma) + home.file.${config.gtk.gtk2.configLocation}.force = true; }; - - # Tell home-manager to force overwrite the gtk2 configuration as it keeps getting overwritten by something (likely plasma) - home.file.${config.gtk.gtk2.configLocation}.force = true; } \ No newline at end of file diff --git a/home-manager/modules/packages.nix b/home-manager/modules/packages.nix index 4855f7e..994ff17 100755 --- a/home-manager/modules/packages.nix +++ b/home-manager/modules/packages.nix @@ -1,4 +1,4 @@ -{ pkgs, inputs, system, ... }: +{ pkgs, inputs, system, ty-home-manager-options, ... }: { home.packages = (with pkgs; [ # Documents diff --git a/home-manager/modules/plasma.nix b/home-manager/modules/plasma.nix index 28578cd..f94511f 100755 --- a/home-manager/modules/plasma.nix +++ b/home-manager/modules/plasma.nix @@ -1,6 +1,6 @@ -{ pkgs, ... }: +{ pkgs, lib, ty-home-manager-options, ... }: { - programs.plasma = { + programs.plasma = lib.mkIf ty-home-manager-options.plasma.enable { enable = true; workspace = { diff --git a/home-manager/modules/rescrobbled.nix b/home-manager/modules/rescrobbled.nix index 190c80c..b718c64 100644 --- a/home-manager/modules/rescrobbled.nix +++ b/home-manager/modules/rescrobbled.nix @@ -1,21 +1,23 @@ -{ secrets, lib, ... }: +{ secrets, lib, ty-home-manager-options, ... }: { - services.custom.rescrobbled = let s = secrets.programs.rescrobbled; in lib.mkIf s.enable { - enable = true; + config = lib.mkIf ty-home-manager-options.rescrobbled.enable { + services.custom.rescrobbled = let s = secrets.programs.rescrobbled; in lib.mkIf s.enable { + enable = true; - session = s.lastfm.session; + session = s.lastfm.session; - settings = { - player-whitelist = [ "elisa" ]; + settings = { + player-whitelist = [ "elisa" ]; - listenbrainz = lib.mkIf (s.listenbrainz.token != null) [ - { - token = s.listenbrainz.token; - } - ]; - - lastfm-key = lib.mkIf (s.lastfm.key != null && s.lastfm.secret != null) s.lastfm.key; - lastfm-secret = lib.mkIf (s.lastfm.key != null && s.lastfm.secret != null) s.lastfm.secret; + listenbrainz = lib.mkIf (s.listenbrainz.token != null) [ + { + token = s.listenbrainz.token; + } + ]; + + lastfm-key = lib.mkIf (s.lastfm.key != null && s.lastfm.secret != null) s.lastfm.key; + lastfm-secret = lib.mkIf (s.lastfm.key != null && s.lastfm.secret != null) s.lastfm.secret; + }; }; }; } \ No newline at end of file diff --git a/home-manager/modules/shell/konsole.nix b/home-manager/modules/shell/konsole.nix index b3091fd..17ec13c 100644 --- a/home-manager/modules/shell/konsole.nix +++ b/home-manager/modules/shell/konsole.nix @@ -1,6 +1,6 @@ -{ pkgs, ... }: +{ pkgs, lib, ty-home-manager-options, ... }: { - programs.konsole = { + programs.konsole = lib.mkIf ty-home-manager-options.plasma.enable { enable = true; defaultProfile = "Primary"; profiles = { diff --git a/home-manager/modules/thunderbird.nix b/home-manager/modules/thunderbird.nix index 5e64a80..f865b47 100755 --- a/home-manager/modules/thunderbird.nix +++ b/home-manager/modules/thunderbird.nix @@ -1,6 +1,6 @@ -{ pkgs, ... }: +{ pkgs, lib, ty-home-manager-options, ... }: { - programs.thunderbird = { + programs.thunderbird = lib.mkIf ty-home-manager-options.thunderbird.enable { enable = true; package = pkgs.thunderbird-latest; profiles = { diff --git a/home-manager/modules/vscode.nix b/home-manager/modules/vscode.nix index 25f9381..778b49a 100644 --- a/home-manager/modules/vscode.nix +++ b/home-manager/modules/vscode.nix @@ -1,100 +1,102 @@ -{ pkgs, inputs, system, ... }: +{ pkgs, inputs, system, lib, ty-home-manager-options, ... }: { - programs.vscode = let vscode-package = pkgs.vscodium; in { - enable = true; - package = vscode-package; - - enableUpdateCheck = false; - enableExtensionUpdateCheck = false; - mutableExtensionsDir = false; + programs.vscode = lib.mkIf ty-home-manager-options.vscode.enable ( + let vscode-package = pkgs.vscodium; in { + enable = true; + package = vscode-package; + + enableUpdateCheck = false; + enableExtensionUpdateCheck = false; + mutableExtensionsDir = false; - extensions = with (inputs.vscode-extensions.extensions."${system}".forVSCodeVersion ( - # Get pkgs.vscodium version, and remove the 4th part (forVSCodeVersion only expects 3 parts) - # By using forVSCodeVersion, any unsupported versions are automatically excluded and this config - # won't build (rather than only finding out in vscode itself) - pkgs.lib.strings.concatStringsSep "." ( - pkgs.lib.lists.take 3 ( - pkgs.lib.strings.splitString "." vscode-package.version + extensions = with (inputs.vscode-extensions.extensions."${system}".forVSCodeVersion ( + # Get pkgs.vscodium version, and remove the 4th part (forVSCodeVersion only expects 3 parts) + # By using forVSCodeVersion, any unsupported versions are automatically excluded and this config + # won't build (rather than only finding out in vscode itself) + pkgs.lib.strings.concatStringsSep "." ( + pkgs.lib.lists.take 3 ( + pkgs.lib.strings.splitString "." vscode-package.version + ) ) - ) - )); ( - (with open-vsx; [ - # Language support - rust-lang.rust-analyzer # Rust - llvm-vs-code-extensions.vscode-clangd # C++ - vadimcn.vscode-lldb # C++ Debugging - jnoortheen.nix-ide # Nix - tamasfe.even-better-toml # TOML - yzhang.markdown-all-in-one # Markdown - denoland.vscode-deno # Deno JS/TS - mathiasfrohlich.kotlin # Kotlin (no LSP) - matthewpi.caddyfile-support # Caddyfile - # Theming - pkief.material-icon-theme # Material icons - # Utilities - streetsidesoftware.code-spell-checker # Spellchecking - jeanp413.open-remote-ssh # Remote SSH - mkhl.direnv # nix-direnv autoloading - cschlosser.doxdocgen # C++ Doxygen generator - tomoki1207.pdf # PDF Viewing - ]) - ++ (with vscode-marketplace; [ - yy0931.save-as-root # Save as root over SSH - akiramiyakoda.cppincludeguard # Auto-insert header guards for header files - ]) - ); + )); ( + (with open-vsx; [ + # Language support + rust-lang.rust-analyzer # Rust + llvm-vs-code-extensions.vscode-clangd # C++ + vadimcn.vscode-lldb # C++ Debugging + jnoortheen.nix-ide # Nix + tamasfe.even-better-toml # TOML + yzhang.markdown-all-in-one # Markdown + denoland.vscode-deno # Deno JS/TS + mathiasfrohlich.kotlin # Kotlin (no LSP) + matthewpi.caddyfile-support # Caddyfile + # Theming + pkief.material-icon-theme # Material icons + # Utilities + streetsidesoftware.code-spell-checker # Spellchecking + jeanp413.open-remote-ssh # Remote SSH + mkhl.direnv # nix-direnv autoloading + cschlosser.doxdocgen # C++ Doxygen generator + tomoki1207.pdf # PDF Viewing + ]) + ++ (with vscode-marketplace; [ + yy0931.save-as-root # Save as root over SSH + akiramiyakoda.cppincludeguard # Auto-insert header guards for header files + ]) + ); - userSettings = { - # Editor - "editor.fontFamily" = "'FiraCode Nerd Font Mono', 'Droid Sans Mono', 'monospace', monospace"; - "editor.indentSize" = "tabSize"; - "editor.tabSize" = 4; - "files.associations" = { - "*.hujson" = "jsonc"; - }; - # JJ - "files.watcherExclude" = { - "**/.git/objects/**" = true; - "**/.git/subtree-cache/**" = true; - "**/.hg/store/**" = true; - "**/.jj" = true; - }; - "files.exclude" = { - "**/.git" = true; - "**/.jj" = true; - "**/.svn" = true; - "**/.hg" = true; - "**/CVS" = true; - "**/.DS_Store" = true; - "**/Thumbs.db" = true; - }; - # Nix - "nix.enableLanguageServer" = true; - "nix.serverPath" = "nixd"; - "nix.serverSettings" = { - nixd = { - formatting = { - command = [ "nixfmt" ]; - }; - - nixpkgs = { - expr = ''import (builtins.getFlake "/etc/nixos").inputs.nixpkgs { }''; - }; - - options = { - nixos = { - expr = ''(builtins.getFlake "/etc/nixos").nixosConfigurations.ty-nixos.options''; + userSettings = { + # Editor + "editor.fontFamily" = "'FiraCode Nerd Font Mono', 'Droid Sans Mono', 'monospace', monospace"; + "editor.indentSize" = "tabSize"; + "editor.tabSize" = 4; + "files.associations" = { + "*.hujson" = "jsonc"; + }; + # JJ + "files.watcherExclude" = { + "**/.git/objects/**" = true; + "**/.git/subtree-cache/**" = true; + "**/.hg/store/**" = true; + "**/.jj" = true; + }; + "files.exclude" = { + "**/.git" = true; + "**/.jj" = true; + "**/.svn" = true; + "**/.hg" = true; + "**/CVS" = true; + "**/.DS_Store" = true; + "**/Thumbs.db" = true; + }; + # Nix + "nix.enableLanguageServer" = true; + "nix.serverPath" = "nixd"; + "nix.serverSettings" = { + nixd = { + formatting = { + command = [ "nixfmt" ]; }; - home-manager = { - expr = ''(builtins.getFlake "/etc/nixos").homeConfigurations."ty".options''; + + nixpkgs = { + expr = ''import (builtins.getFlake "/etc/nixos").inputs.nixpkgs { }''; + }; + + options = { + nixos = { + expr = ''(builtins.getFlake "/etc/nixos").nixosConfigurations.ty-nixos.options''; + }; + home-manager = { + expr = ''(builtins.getFlake "/etc/nixos").homeConfigurations."ty".options''; + }; }; }; }; + "direnv.restart.automatic" = true; + # C++ Include guards + "C/C++ Include Guard.Comment Style" = "Line"; + "C/C++ Include Guard.Macro Type" = "Filename"; }; - "direnv.restart.automatic" = true; - # C++ Include guards - "C/C++ Include Guard.Comment Style" = "Line"; - "C/C++ Include Guard.Macro Type" = "Filename"; - }; - }; + } + ); }