From fc99570fdc365b026862512b031dbcdcdaf07d49 Mon Sep 17 00:00:00 2001 From: pagedmov Date: Wed, 6 Nov 2024 22:28:16 -0500 Subject: [PATCH] Successfully separated home-manager configs from system configs --- flake.nix | 160 +++++++++++++++++----------- hosts/desktop/config.nix | 20 +++- hosts/desktop/home.nix | 120 +++++++-------------- hosts/server/config.nix | 21 ++-- modules/home/environment/stylix.nix | 39 ++++++- modules/home/programs/firefox.nix | 13 +-- modules/server/cdn/jellyfin.nix | 2 +- modules/server/default.nix | 7 +- modules/server/glasshaus/caddy.nix | 2 +- 9 files changed, 209 insertions(+), 175 deletions(-) diff --git a/flake.nix b/flake.nix index 79f2335..3a0e7e3 100755 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "pagedMov's NixOS configuration"; + description = "pagedMov's NixOS and Home Manager configuration"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; @@ -30,77 +30,111 @@ }; }; - outputs = { - nixpkgs, - nur, - self, - nixvim, - stylix, - ... - } @ inputs: let - system = "x86_64-linux"; - username = "pagedmov"; - in { - homeManagerModules.default = ./modules/home; - nixosModules.default = ./modules/sys; - serverModules.default = ./modules/server; - nix.nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; + outputs = { self, home-manager, nixpkgs, nur, nixvim, stylix, ... } @ inputs: + let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; + username = "pagedmov"; + in { + nix.nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; - nixosConfigurations = { - oganesson = nixpkgs.lib.nixosSystem { - specialArgs = { - host = "oganesson"; - inherit self inputs username; + # Home Manager configurations for each user/machine + homeConfigurations = { + oganessonHome = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + extraSpecialArgs = { + host = "oganesson"; + inherit self username inputs nur; + }; + + # Specific Home Manager config for oganesson + modules = [ + ./hosts/desktop/home.nix + ./modules/home + stylix.homeManagerModules.stylix + ]; + }; + + mercuryHome = home-manager.lib.homeManagerConfiguration { + inherit system; + pkgs = pkgs; + extraSpecialArgs = { inherit self inputs username; }; + + # Specific Home Manager config for mercury + configuration = import ./hosts/laptop/home.nix; + }; + + xenonHome = home-manager.lib.homeManagerConfiguration { + inherit system; + pkgs = pkgs; + extraSpecialArgs = { inherit self inputs username; }; + + # Specific Home Manager config for xenon + configuration = import ./hosts/server/home.nix; }; - inherit system; - modules = [ - ./hosts/desktop/config.nix - ./modules/sys - stylix.nixosModules.stylix - nixvim.nixosModules.nixvim - nur.nixosModules.nur - ]; }; - mercury = nixpkgs.lib.nixosSystem { - specialArgs = { - host = "mercury"; - inherit self inputs username; + nixosConfigurations = { + oganesson = nixpkgs.lib.nixosSystem { + specialArgs = { + host = "oganesson"; + inherit self inputs username; + }; + inherit system; + modules = [ + ./hosts/desktop/config.nix + ./modules/sys + home-manager.nixosModules.home-manager + stylix.nixosModules.stylix + nixvim.nixosModules.nixvim + nur.nixosModules.nur + ]; }; - modules = [ - ./hosts/laptop/config.nix - ./modules/sys - stylix.nixosModules.stylix - nixvim.nixosModules.nixvim - nur.nixosModules.nur - ]; - }; - xenon = nixpkgs.lib.nixosSystem { - specialArgs = { - host = "xenon"; - inherit self inputs username; + mercury = nixpkgs.lib.nixosSystem { + specialArgs = { + host = "mercury"; + inherit self inputs username; + }; + inherit system; + modules = [ + ./hosts/laptop/config.nix + ./modules/sys + home-manager.nixosModules.home-manager + stylix.nixosModules.stylix + nixvim.nixosModules.nixvim + nur.nixosModules.nur + ]; }; - modules = [ - ./hosts/server/config.nix - ./modules/sys - ./modules/server - stylix.nixosModules.stylix - nixvim.nixosModules.nixvim - nur.nixosModules.nur - ]; - }; - installer = nixpkgs.lib.nixosSystem { - specialArgs = { - host = "installer"; - inherit self inputs; + xenon = nixpkgs.lib.nixosSystem { + specialArgs = { + host = "xenon"; + inherit self inputs username; + }; + inherit system; + modules = [ + ./hosts/server/config.nix + ./modules/sys + ./modules/server + home-manager.nixosModules.home-manager + stylix.nixosModules.stylix + nixvim.nixosModules.nixvim + nur.nixosModules.nur + ]; + }; + + installer = nixpkgs.lib.nixosSystem { + specialArgs = { + host = "installer"; + inherit self inputs; + }; + inherit system; + modules = [ + ./hosts/installer + nixvim.nixosModules.nixvim + ]; }; - modules = [ - ./hosts/installer - nixvim.nixosModules.nixvim - ]; }; }; - }; } diff --git a/hosts/desktop/config.nix b/hosts/desktop/config.nix index e3b99a3..ebdd54f 100755 --- a/hosts/desktop/config.nix +++ b/hosts/desktop/config.nix @@ -1,7 +1,6 @@ -{pkgs, ...}: { +{pkgs, username, ...}: { imports = [ ./hardware.nix - ./home.nix ]; # My module options @@ -43,6 +42,23 @@ ]; }; + users = { + groups.persist = {}; + users = { + root.initialPassword = "1234"; + ${username} = { + isNormalUser = true; + initialPassword = "1234"; + shell = pkgs.zsh; + extraGroups = ["wheel" "persist" "libvirtd"]; + }; + }; + }; + security.sudo.extraConfig = '' + ${username} ALL=(ALL) NOPASSWD: /etc/profiles/per-user/${username}/bin/rebuild + ''; + nix.settings.allowed-users = ["${username}"]; + time.timeZone = "America/New_York"; i18n.defaultLocale = "en_US.UTF-8"; } diff --git a/hosts/desktop/home.nix b/hosts/desktop/home.nix index e2a32f1..a6e125f 100755 --- a/hosts/desktop/home.nix +++ b/hosts/desktop/home.nix @@ -1,94 +1,56 @@ { - host, - pkgs, - self, - inputs, username, lib, config, ... -}: let - nur = config.nur; -in { - imports = [inputs.home-manager.nixosModules.home-manager]; - home-manager = { - useUserPackages = true; - useGlobalPkgs = true; - backupFileExtension = "backup"; - extraSpecialArgs = {inherit self inputs host username nur;}; - users = { - ${username} = { - programs.home-manager.enable = true; - imports = [ - inputs.self.outputs.homeManagerModules.default - ]; +}: +{ + home.username = "${username}"; # Replace with your actual username + home.homeDirectory = "/home/${username}"; # Replace with your actual home directory + home.stateVersion = "24.05"; # Adjust this based on your system's NixOS version - # My custom home-manager modules - movOpts = { - # modules/home/files - homeFiles.enable = true; + programs.home-manager.enable = true; - # modules/home/environment - hyprlandConfig.enable = true; - autojumpConfig.enable = true; - stylixHomeConfig.enable = true; - waybarConfig.enable = true; - gtkConfig.enable = true; - spicetifyConfig.enable = true; - starshipConfig.enable = true; + movOpts = { + # modules/home/files + homeFiles.enable = true; - # modules/home/programs - btopConfig.enable = true; - swayncConfig.enable = true; - userPkgs.enable = true; - cavaConfig.enable = true; - ezaConfig.enable = true; - firefoxConfig.enable = true; - fuzzelConfig.enable = true; - fzfConfig.enable = true; - gitConfig.enable = true; - kittyConfig.enable = true; - yaziConfig.enable = true; - zshConfig.enable = true; - passConfig.enable = true; - batConfig.enable = true; + # modules/home/environment + hyprlandConfig.enable = true; + autojumpConfig.enable = true; + stylixHomeConfig.enable = true; + waybarConfig.enable = true; + gtkConfig.enable = true; + spicetifyConfig.enable = true; + starshipConfig.enable = true; - # modules/home/scripts - movScripts.enable = true; - movScripts.commandScripts.enable = true; - movScripts.hyprlandControls.enable = true; - movScripts.nixShortcuts.enable = true; - }; + # modules/home/programs + btopConfig.enable = true; + swayncConfig.enable = true; + userPkgs.enable = true; + cavaConfig.enable = true; + ezaConfig.enable = true; + firefoxConfig.enable = true; + fuzzelConfig.enable = true; + fzfConfig.enable = true; + gitConfig.enable = true; + kittyConfig.enable = true; + yaziConfig.enable = true; + zshConfig.enable = true; + passConfig.enable = true; + batConfig.enable = true; - dconf.settings = lib.mkIf config.movOpts.virtConfig.enable { - "org/virt-manager/virt-manager/connections" = { - autoconnect = ["qemu:///system"]; - uris = ["qemu:///system"]; - }; - }; - home = { - username = "${username}"; - homeDirectory = "/home/${username}"; - stateVersion = "24.05"; - }; - }; - }; + # modules/home/scripts + movScripts.enable = true; + movScripts.commandScripts.enable = true; + movScripts.hyprlandControls.enable = true; + movScripts.nixShortcuts.enable = true; }; - users = { - groups.persist = {}; - users = { - root.initialPassword = "1234"; - ${username} = { - isNormalUser = true; - initialPassword = "1234"; - shell = pkgs.zsh; - extraGroups = ["wheel" "persist" "libvirtd"]; - }; + dconf.settings = { + "org/virt-manager/virt-manager/connections" = { + autoconnect = ["qemu:///system"]; + uris = ["qemu:///system"]; }; }; - security.sudo.extraConfig = '' - ${username} ALL=(ALL) NOPASSWD: /etc/profiles/per-user/${username}/bin/rebuild - ''; - nix.settings.allowed-users = ["${username}"]; } diff --git a/hosts/server/config.nix b/hosts/server/config.nix index 6a01ed4..0a3302b 100755 --- a/hosts/server/config.nix +++ b/hosts/server/config.nix @@ -7,16 +7,17 @@ ./hardware.nix ./home.nix ]; - nixSettings.enable = true; - networkModule.enable = true; - bootLoader.enable = true; - issue.enable = true; - sysPkgs.enable = true; - sysProgs.enable = true; - sysServices.enable = true; - jellyfinConfig.enable = true; - caddyConfig.enable = true; - + movOpts = { + nixSettings.enable = true; + networkModule.enable = true; + bootLoader.enable = true; + issue.enable = true; + sysPkgs.enable = true; + sysProgs.enable = true; + sysServices.enable = true; + jellyfinConfig.enable = true; + caddyConfig.enable = true; + }; networking.firewall = { allowedTCPPorts = [ 443 8920 ]; }; diff --git a/modules/home/environment/stylix.nix b/modules/home/environment/stylix.nix index 6531535..3c6ae04 100755 --- a/modules/home/environment/stylix.nix +++ b/modules/home/environment/stylix.nix @@ -1,18 +1,49 @@ -{lib, config, pkgs, ... }: { +{lib, self, config, pkgs, ... }: + +let + scheme = "tokyo-night-dark"; + wallpaper = "${self}/assets/wallpapers/dark-waves.jpg"; +in +{ options = { movOpts.stylixHomeConfig.enable = lib.mkEnableOption "enables my stylix Home-Manager options"; }; config = lib.mkIf config.movOpts.stylixHomeConfig.enable { stylix = { enable = true; + base16Scheme = "${pkgs.base16-schemes}/share/themes/${scheme}.yaml"; + image = wallpaper; + polarity = "dark"; autoEnable = true; + opacity.terminal = 0.50; targets = { - # fzf.enable = true; - # kitty.enable = true; - # vesktop.enable = true; waybar.enable = false; btop.enable = false; }; + cursor = { + package = pkgs.bibata-cursors; + name = "Bibata-Modern-Ice"; + }; + fonts = { + monospace = { + package = pkgs.nerdfonts.override {fonts = ["JetBrainsMono"];}; + name = "JetBrains Mono Nerd Font"; + }; + sansSerif = { + package = pkgs.nerdfonts.override {fonts = ["JetBrainsMono"];}; + name = "JetBrains Mono Nerd Font"; + }; + serif = { + package = pkgs.nerdfonts.override {fonts = ["JetBrainsMono"];}; + name = "JetBrains Mono Nerd Font"; + }; + sizes = { + desktop = 10; + applications = 14; + terminal = 14; + popups = 16; + }; + }; }; }; } diff --git a/modules/home/programs/firefox.nix b/modules/home/programs/firefox.nix index d8b0068..661a927 100755 --- a/modules/home/programs/firefox.nix +++ b/modules/home/programs/firefox.nix @@ -1,4 +1,4 @@ -{lib, config, nur, username, self, ... }: { +{lib, config, nur, username, self, pkgs, ... }: { options = { movOpts.firefoxConfig.enable = lib.mkEnableOption "enables my firefox configuration"; }; @@ -83,17 +83,6 @@ url = "https://www.nerdfonts.com/cheat-sheet"; } ]; - extensions = with nur.repos.rycee.firefox-addons; [ - darkreader - adnauseam - cookie-autodelete - disconnect - firefox-color - vimium - firenvim - privacy-badger - new-tab-override - ]; extraConfig = '' "browser.startup.homepage" = "${self}/glasshouse-desktop/home/firefox/homepage.html"; "browser.active_color" = "#EE0000"; diff --git a/modules/server/cdn/jellyfin.nix b/modules/server/cdn/jellyfin.nix index 09b11f2..e760921 100755 --- a/modules/server/cdn/jellyfin.nix +++ b/modules/server/cdn/jellyfin.nix @@ -2,7 +2,7 @@ { options = { - jellyfinConfig.enable = lib.mkEnableOption "Enables the server's jellyfin config"; + movOpts.jellyfinConfig.enable = lib.mkEnableOption "Enables the server's jellyfin config"; }; config = lib.mkIf config.movOpts.jellyfinConfig.enable { services.jellyfin = { diff --git a/modules/server/default.nix b/modules/server/default.nix index 83a85f5..8ba279c 100755 --- a/modules/server/default.nix +++ b/modules/server/default.nix @@ -5,7 +5,8 @@ ./cdn ./glasshaus ]; - - jellyfinConfig.enable = lib.mkDefault false; - caddyConfig.enable = lib.mkDefault false; + movOpts = { + jellyfinConfig.enable = lib.mkDefault false; + caddyConfig.enable = lib.mkDefault false; + }; } diff --git a/modules/server/glasshaus/caddy.nix b/modules/server/glasshaus/caddy.nix index 9867f26..2c3eab1 100755 --- a/modules/server/glasshaus/caddy.nix +++ b/modules/server/glasshaus/caddy.nix @@ -2,7 +2,7 @@ { options = { - caddyConfig.enable = lib.mkEnableOption "Enable my caddy config for the glasshaus.info domain name"; + movOpts.caddyConfig.enable = lib.mkEnableOption "Enable my caddy config for the glasshaus.info domain name"; }; config = lib.mkIf config.movOpts.caddyConfig.enable { services.caddy = {