From a2037ffb5697bc7f38e405e2ffcdfc102cafc06b Mon Sep 17 00:00:00 2001 From: tomoron Date: Sun, 9 Feb 2025 03:02:57 +0100 Subject: [PATCH] refactor flake.nix and osConfig organization --- dotfiles/config/nvim/init.vim | 1 + flake.nix | 140 ++++-------------- home.nix | 5 +- homes/desktop/home.nix | 18 ++- homes/desktop/hyprland.nix | 18 --- homes/ft/{ft.nix => home.nix} | 0 homes/laptop/home.nix | 1 + homes/{vbox.nix => vbox/home.nix} | 0 modules/vim.nix | 1 + configuration.nix => osConfigs/global.nix | 21 +-- .../hardware-configuration.nix | 0 {hosts => osConfigs/hosts}/desktop.nix | 6 +- {hosts => osConfigs/hosts}/laptop.nix | 6 +- {hosts => osConfigs/hosts}/server.nix | 8 +- {hosts => osConfigs/hosts}/vbox.nix | 0 {hosts => osConfigs}/modules/game.nix | 0 {hosts => osConfigs}/modules/nvidia.nix | 0 {hosts => osConfigs}/modules/vboxHost.nix | 0 {modules => osConfigs/modules}/yubikey.nix | 0 19 files changed, 76 insertions(+), 149 deletions(-) delete mode 100644 homes/desktop/hyprland.nix rename homes/ft/{ft.nix => home.nix} (100%) rename homes/{vbox.nix => vbox/home.nix} (100%) rename configuration.nix => osConfigs/global.nix (57%) rename hardware-configuration.nix => osConfigs/hardware-configuration.nix (100%) rename {hosts => osConfigs/hosts}/desktop.nix (88%) rename {hosts => osConfigs/hosts}/laptop.nix (95%) rename {hosts => osConfigs/hosts}/server.nix (92%) rename {hosts => osConfigs/hosts}/vbox.nix (100%) rename {hosts => osConfigs}/modules/game.nix (100%) rename {hosts => osConfigs}/modules/nvidia.nix (100%) rename {hosts => osConfigs}/modules/vboxHost.nix (100%) rename {modules => osConfigs/modules}/yubikey.nix (100%) diff --git a/dotfiles/config/nvim/init.vim b/dotfiles/config/nvim/init.vim index 7aeda9d..6671c65 100644 --- a/dotfiles/config/nvim/init.vim +++ b/dotfiles/config/nvim/init.vim @@ -19,6 +19,7 @@ call plug#end() colorscheme catppuccin-mocha lua require'lspconfig'.clangd.setup{} +lua require'lspconfig'.nixd.setup{} set signcolumn=no let g:user42 = 'tomoron' diff --git a/flake.nix b/flake.nix index af32b84..fca1294 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,7 @@ # By: tomoron +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/10/17 18:15:24 by tomoron #+# #+# # -# Updated: 2025/02/04 16:03:35 by tomoron ### ########.fr # +# Updated: 2025/02/09 02:55:40 by tomoron ### ########.fr # # # # **************************************************************************** # @@ -31,117 +31,39 @@ }; }; - outputs = { self, nixpkgs, home-manager, nixos-hardware, plymouth-theme-ycontre-glow, ... }@inputs: + outputs = { nixpkgs, home-manager, nixos-hardware, ... }@inputs: let pkgs = import nixpkgs { system = "x86_64-linux"; config.allowUnfree = true; }; - username="tom"; - homeDir="/home/tom"; - in { -#NIXOS CONFIG - nixosConfigurations = { - default = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs; flakeName="default";}; - modules = [ - ./configuration.nix - ]; - }; - server = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs; flakeName="server";}; - modules = [ - ./configuration.nix - ./hosts/server.nix - ]; - }; - vbox = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs;flakeName="vbox";}; - modules = [ - ./configuration.nix - ./hosts/vbox.nix - ]; - }; - laptop = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs;flakeName="laptop";}; - modules = [ - ./configuration.nix - ./hosts/laptop.nix - nixos-hardware.nixosModules.asus-zephyrus-ga401 - ]; - }; - desktop = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs;flakeName="desktop";}; - modules = [ - ./configuration.nix - ./hosts/desktop.nix - ]; - }; + + + osConfig = {flakeName, extraModules ? []}: nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; flakeName = flakeName; }; + modules = nixpkgs.lib.concatLists [ [./osConfigs/global.nix ./osConfigs/hosts/${flakeName}.nix ] extraModules]; }; -#HOME CONFIG - homeConfigurations = { - vbox = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - extraSpecialArgs = { - username = "${username}"; - homeDir = "${homeDir}"; - inherit inputs; - }; - modules = [ - ./home.nix - ./homes/vbox.nix - ./modules/hyprland.nix - ]; - }; - ft = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - extraSpecialArgs = { - username = "tomoron"; - homeDir = "/nfs/homes/tomoron"; - inherit inputs; - }; - modules = [ - ./home.nix - ./homes/ft/ft.nix - ]; - }; - laptop = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - extraSpecialArgs = { - username = "${username}"; - homeDir = "${homeDir}"; - inherit inputs; - }; - modules = [ - ./home.nix - ./homes/laptop/home.nix - ./modules/hyprland.nix - ]; - }; - desktop = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - extraSpecialArgs = { - username = "${username}"; - homeDir = "${homeDir}"; - inherit inputs; - }; - modules = [ - ./home.nix - ./homes/desktop/home.nix - ./modules/hyprland.nix - ]; - }; - server = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - extraSpecialArgs = { - username = "${username}"; - homeDir = "${homeDir}"; - inherit inputs; - }; - modules = [ - ./home.nix - ./homes/server/home.nix - ./modules/hyprland.nix - ]; - }; + + homeConfig = {flakeName, extraModules ? [], username ? "tom", homeDir ? "/home/tom"}: home-manager.lib.homeManagerConfiguration { + inherit pkgs; + extraSpecialArgs = { inherit inputs; username = username; homeDir = homeDir; }; + modules = nixpkgs.lib.concatLists [ [ ./home.nix ./homes/${flakeName}/home.nix] extraModules ]; }; - }; + + in { + + nixosConfigurations = { + server = osConfig {flakeName = "server";}; + vbox = osConfig {flakeName = "vbox";}; + laptop = osConfig {flakeName = "laptop"; extraModules = [ nixos-hardware.nixosModules.asus-zephyrus-ga401 ];}; + desktop = osConfig {flakeName = "desktop";}; + }; + + + homeConfigurations = { + vbox = homeConfig { flakeName = "vbox"; }; + ft = homeConfig { flakeName = "ft"; username = "tomoron"; homeDir = "/nfs/homes/tomoron";}; + laptop = homeConfig { flakeName = "laptop"; }; + desktop = homeConfig { flakeName = "desktop"; }; + server = homeConfig { flakeName = "server"; }; + }; + }; } diff --git a/home.nix b/home.nix index 63e4890..ebf11c9 100644 --- a/home.nix +++ b/home.nix @@ -6,11 +6,11 @@ # By: tomoron +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/10/17 18:15:38 by tomoron #+# #+# # -# Updated: 2025/02/04 16:02:21 by tomoron ### ########.fr # +# Updated: 2025/02/09 02:42:49 by tomoron ### ########.fr # # # # **************************************************************************** # -{ config, lib, pkgs, username,homeDir, ... }: +{lib, pkgs, username,homeDir, ... }: { imports = [ @@ -80,6 +80,7 @@ nix-index yubikey-manager yubico-pam + wl-clipboard ]; home.file = { diff --git a/homes/desktop/home.nix b/homes/desktop/home.nix index 04e5b59..1dea5a0 100644 --- a/homes/desktop/home.nix +++ b/homes/desktop/home.nix @@ -1,10 +1,26 @@ -{ config, lib, pkgs, ... }: +{ ... }: { imports = [ ../modules/nitrogen.nix ./hyprland.nix ]; + + wayland.windowManager.hyprland.settings = { + monitor = [ + "HDMI-A-1, 1920x1080@60, 0x0, auto" + "HDMI-A-3, 1920x1080@60, 1920x0, auto" + "DP-1, 1280x1024@60, 3840x0, auto" + "DP-3, 1280x1024@60, 5120x0, auto" + ]; + workspace = [ + "1, monitor:HDMI-A-1" + "2, monitor:HDMI-A-3, default:true" + "3, monitor:DP-1" + "4, monitor:DP-3" + ]; + }; + home.file = { ".config/bspwm/screenlayout.sh".source = ./bspwm/screenlayout.sh; ".config/bspwm/host.sh".source = ./bspwm/host.sh; diff --git a/homes/desktop/hyprland.nix b/homes/desktop/hyprland.nix deleted file mode 100644 index cb873c1..0000000 --- a/homes/desktop/hyprland.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - wayland.windowManager.hyprland.settings = { - monitor = [ - "HDMI-A-1, 1920x1080@60, 0x0, auto" - "HDMI-A-3, 1920x1080@60, 1920x0, auto" - "DP-1, 1280x1024@60, 3840x0, auto" - "DP-3, 1280x1024@60, 5120x0, auto" - ]; - workspace = [ - "1, monitor:HDMI-A-1" - "2, monitor:HDMI-A-3, default:true" - "3, monitor:DP-1" - "4, monitor:DP-3" - ]; - }; -} diff --git a/homes/ft/ft.nix b/homes/ft/home.nix similarity index 100% rename from homes/ft/ft.nix rename to homes/ft/home.nix diff --git a/homes/laptop/home.nix b/homes/laptop/home.nix index 47b50eb..79ff1f6 100644 --- a/homes/laptop/home.nix +++ b/homes/laptop/home.nix @@ -4,6 +4,7 @@ imports = [ ../modules/game.nix ../modules/nitrogen.nix + ../../modules/hyprland.nix ./hyprland.nix ./waybar.nix ]; diff --git a/homes/vbox.nix b/homes/vbox/home.nix similarity index 100% rename from homes/vbox.nix rename to homes/vbox/home.nix diff --git a/modules/vim.nix b/modules/vim.nix index aaf7ecd..c373764 100644 --- a/modules/vim.nix +++ b/modules/vim.nix @@ -3,6 +3,7 @@ { home.packages = with pkgs;[ clang-tools + nixd nodejs_23 ]; diff --git a/configuration.nix b/osConfigs/global.nix similarity index 57% rename from configuration.nix rename to osConfigs/global.nix index 2a28032..5c9929c 100644 --- a/configuration.nix +++ b/osConfigs/global.nix @@ -1,5 +1,14 @@ -# Edit this configuration file to define what should be installed on your system. Help is available in the configuration.nix(5) man page, on -# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). +# **************************************************************************** # +# # +# ::: :::::::: # +# configuration.nix :+: :+: :+: # +# +:+ +:+ +:+ # +# By: tomoron +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2025/02/09 01:43:46 by tomoron #+# #+# # +# Updated: 2025/02/09 01:50:15 by tomoron ### ########.fr # +# # +# **************************************************************************** # { config, lib, inputs, pkgs, flakeName, ... }: @@ -64,13 +73,7 @@ ffmpeg ]; - #Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - #Or disable the firewall altogether. - # networking.firewall.enable = false; - - system.stateVersion = "24.05"; # Did you read the comment? + system.stateVersion = "24.05"; environment.etc.nixosFlakeName.text = "${flakeName}"; diff --git a/hardware-configuration.nix b/osConfigs/hardware-configuration.nix similarity index 100% rename from hardware-configuration.nix rename to osConfigs/hardware-configuration.nix diff --git a/hosts/desktop.nix b/osConfigs/hosts/desktop.nix similarity index 88% rename from hosts/desktop.nix rename to osConfigs/hosts/desktop.nix index c281e2e..39b9595 100644 --- a/hosts/desktop.nix +++ b/osConfigs/hosts/desktop.nix @@ -3,9 +3,9 @@ { imports = [ - modules/game.nix - modules/nvidia.nix - modules/vboxHost.nix + ../modules/game.nix + ../modules/nvidia.nix + ../modules/vboxHost.nix ]; environment.systemPackages = with pkgs; [ diff --git a/hosts/laptop.nix b/osConfigs/hosts/laptop.nix similarity index 95% rename from hosts/laptop.nix rename to osConfigs/hosts/laptop.nix index bd69759..2db9bd2 100644 --- a/hosts/laptop.nix +++ b/osConfigs/hosts/laptop.nix @@ -2,9 +2,9 @@ { imports = [ - modules/game.nix - modules/nvidia.nix - modules/vboxHost.nix + ../modules/game.nix + ../modules/nvidia.nix + ../modules/vboxHost.nix ]; boot.kernelParams = [ "kvm.enable_virt_at_load=0" ]; # systemd.tmpfiles.rules = [ diff --git a/hosts/server.nix b/osConfigs/hosts/server.nix similarity index 92% rename from hosts/server.nix rename to osConfigs/hosts/server.nix index a80d927..7018a17 100644 --- a/hosts/server.nix +++ b/osConfigs/hosts/server.nix @@ -3,12 +3,12 @@ { imports = [ - modules/game.nix - modules/vboxHost.nix - modules/nvidia.nix + ../modules/game.nix + ../modules/vboxHost.nix + ../modules/nvidia.nix ]; boot.kernelPackages = pkgs.linuxPackages; - boot.extraModulePackages = with config.boot.kernelPackages; [gasket]; + boot.extraModulePackages = [ config.boot.kernelPackages.gasket ]; networking.hostName = "server"; services.openssh.enable = true; diff --git a/hosts/vbox.nix b/osConfigs/hosts/vbox.nix similarity index 100% rename from hosts/vbox.nix rename to osConfigs/hosts/vbox.nix diff --git a/hosts/modules/game.nix b/osConfigs/modules/game.nix similarity index 100% rename from hosts/modules/game.nix rename to osConfigs/modules/game.nix diff --git a/hosts/modules/nvidia.nix b/osConfigs/modules/nvidia.nix similarity index 100% rename from hosts/modules/nvidia.nix rename to osConfigs/modules/nvidia.nix diff --git a/hosts/modules/vboxHost.nix b/osConfigs/modules/vboxHost.nix similarity index 100% rename from hosts/modules/vboxHost.nix rename to osConfigs/modules/vboxHost.nix diff --git a/modules/yubikey.nix b/osConfigs/modules/yubikey.nix similarity index 100% rename from modules/yubikey.nix rename to osConfigs/modules/yubikey.nix