From 726b059e5e10fd08e995e36ad6a240c457b2c392 Mon Sep 17 00:00:00 2001 From: xeovalyte Date: Tue, 25 Jun 2024 13:11:30 +0200 Subject: [PATCH] Refactored configuration --- flake.lock | 226 -------------------------- flake.nix | 46 +++--- hosts/laptop/home.nix | 57 ++++--- hosts/vnix-ctr/default.nix | 53 ++++++ hosts/vnix-ctr/home.nix | 20 +++ modules/home/gui/hyprland/default.nix | 30 ++-- modules/home/gui/hyprland/waybar.nix | 12 +- modules/home/gui/theming.nix | 56 ++++--- modules/system/cli/podman.nix | 17 ++ 9 files changed, 198 insertions(+), 319 deletions(-) create mode 100644 hosts/vnix-ctr/default.nix create mode 100644 hosts/vnix-ctr/home.nix create mode 100644 modules/system/cli/podman.nix diff --git a/flake.lock b/flake.lock index 9c14bc6..1959b69 100644 --- a/flake.lock +++ b/flake.lock @@ -16,80 +16,6 @@ "type": "github" } }, - "firefox-addons": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "dir": "pkgs/firefox-addons", - "lastModified": 1717646600, - "narHash": "sha256-yHNeUEOU8/n+ULrsokW5aCLDWg/mEVbPCOyhTIorZns=", - "owner": "rycee", - "repo": "nur-expressions", - "rev": "bdbbd8c2cb03b23b586fea14a8a680b218ab363c", - "type": "gitlab" - }, - "original": { - "dir": "pkgs/firefox-addons", - "owner": "rycee", - "repo": "nur-expressions", - "type": "gitlab" - } - }, - "flake-checks": { - "locked": { - "lastModified": 1716193450, - "narHash": "sha256-wIbyIQRoLAfGe2v8W7LM6zEZ9Oy0jKuUX0HMUCLQJsM=", - "owner": "getchoo", - "repo": "flake-checks", - "rev": "842c3f225677aa55e44b94342f19c8f3e6f2be06", - "type": "github" - }, - "original": { - "owner": "getchoo", - "repo": "flake-checks", - "type": "github" - } - }, - "flake-utils": { - "locked": { - "lastModified": 1629284811, - "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c5d161cc0af116a2e17f54316f0bf43f0819785c", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "getchoo": { - "inputs": { - "flake-checks": "flake-checks", - "nixpkgs": [ - "nixpkgs-unstable" - ] - }, - "locked": { - "lastModified": 1717496495, - "narHash": "sha256-tvKpBxQ3u9u221bhKHy7zVQp0Wsdc9b4M3SvC3/1FMs=", - "owner": "getchoo", - "repo": "nix-exprs", - "rev": "0eeabcca8362d37d0563e5315a00d50cae73308a", - "type": "github" - }, - "original": { - "owner": "getchoo", - "repo": "nix-exprs", - "type": "github" - } - }, "home-manager": { "inputs": { "nixpkgs": [ @@ -111,94 +37,6 @@ "type": "github" } }, - "hypridle": { - "inputs": { - "hyprlang": "hyprlang", - "nixpkgs": [ - "nixpkgs" - ], - "systems": "systems_2" - }, - "locked": { - "lastModified": 1716309977, - "narHash": "sha256-4jDQIcMDSFOOMBxVTEiC6Ck1vdc0kAFvv+StxnnE59Q=", - "owner": "hyprwm", - "repo": "hypridle", - "rev": "cb169c4e06cec9b4349e3668427e729d22328a54", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hypridle", - "type": "github" - } - }, - "hyprlang": { - "inputs": { - "nixpkgs": [ - "hypridle", - "nixpkgs" - ], - "systems": "systems" - }, - "locked": { - "lastModified": 1713121246, - "narHash": "sha256-502X0Q0fhN6tJK7iEUA8CghONKSatW/Mqj4Wappd++0=", - "owner": "hyprwm", - "repo": "hyprlang", - "rev": "78fcaa27ae9e1d782faa3ff06c8ea55ddce63706", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprlang", - "type": "github" - } - }, - "hyprlang_2": { - "inputs": { - "nixpkgs": [ - "hyprlock", - "nixpkgs" - ], - "systems": "systems_3" - }, - "locked": { - "lastModified": 1713121246, - "narHash": "sha256-502X0Q0fhN6tJK7iEUA8CghONKSatW/Mqj4Wappd++0=", - "owner": "hyprwm", - "repo": "hyprlang", - "rev": "78fcaa27ae9e1d782faa3ff06c8ea55ddce63706", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprlang", - "type": "github" - } - }, - "hyprlock": { - "inputs": { - "hyprlang": "hyprlang_2", - "nixpkgs": [ - "nixpkgs" - ], - "systems": "systems_4" - }, - "locked": { - "lastModified": 1716987277, - "narHash": "sha256-l8aa+XPDbM3Mf3W4ukC/tBBHVZE8A3att4KLXrnyKSI=", - "owner": "hyprwm", - "repo": "hyprlock", - "rev": "e07d4110dc0b9d1786403aa760232564ad28b6fa", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprlock", - "type": "github" - } - }, "nix-colors": { "inputs": { "base16-schemes": "base16-schemes", @@ -265,75 +103,11 @@ }, "root": { "inputs": { - "firefox-addons": "firefox-addons", - "getchoo": "getchoo", "home-manager": "home-manager", - "hypridle": "hypridle", - "hyprlock": "hyprlock", "nix-colors": "nix-colors", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable" } - }, - "systems": { - "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", - "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default-linux", - "type": "github" - } - }, - "systems_2": { - "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", - "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default-linux", - "type": "github" - } - }, - "systems_3": { - "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", - "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default-linux", - "type": "github" - } - }, - "systems_4": { - "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", - "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default-linux", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 3689d4b..06e5a11 100644 --- a/flake.nix +++ b/flake.nix @@ -12,26 +12,6 @@ }; nix-colors.url = "github:misterio77/nix-colors"; - - firefox-addons = { - url = "gitlab:rycee/nur-expressions?dir=pkgs/firefox-addons"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - hyprlock = { - url = "github:/hyprwm/hyprlock"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - hypridle = { - url = "github:/hyprwm/hypridle"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - getchoo = { - url = "github:getchoo/nix-exprs"; - inputs.nixpkgs.follows = "nixpkgs-unstable"; - }; }; outputs = inputs@{ self, nixpkgs, nixpkgs-unstable, home-manager, nix-colors, ... }: @@ -56,12 +36,13 @@ home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; - home-manager.extraSpecialArgs = { inherit inputs nix-colors ;hostName = "xv-laptop"; }; + home-manager.extraSpecialArgs = { inherit inputs nix-colors; }; home-manager.users.xeovalyte.imports = [ ./hosts/laptop/home.nix ]; } ]; }; }; + nixosConfigurations = { xv-desktop = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; @@ -73,11 +54,32 @@ home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; - home-manager.extraSpecialArgs = { inherit inputs nix-colors; hostName = "xv-desktop"; }; + home-manager.extraSpecialArgs = { inherit inputs nix-colors; }; home-manager.users.xeovalyte.imports = [ ./hosts/desktop/home.nix ]; } ]; }; }; + + nixosConfigurations = { + vnix-ctr = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ + ({ config, pkgs, ... }: { + nixpkgs.overlays = [ overlay-unstable ]; + networking.hostName = "vnix-ctn01"; + }) + + ./hosts/vnix-ctr + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.extraSpecialArgs = { inherit inputs nix-colors; }; + home-manager.users.xeovalyte.imports = [ ./hosts/vnix-ctr/home.nix ]; + } + ]; + }; + }; }; } diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index dd715b6..e18a810 100644 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, lib, config, ... }: { imports = [ @@ -13,30 +13,45 @@ ../../modules/home/cli/ssh.nix ]; - home = { - username = "xeovalyte"; - homeDirectory = "/home/xeovalyte"; + options = { + host = lib.mkOption { + type = with lib.types; str; + description = '' + Define the host of the machine + ''; + }; }; - home.packages = with pkgs; [ - # Desktop Applications - kdenlive - unstable.prismlauncher - unstable.joplin-desktop - unstable.moonlight-qt - unstable.prusa-slicer - signal-desktop - unstable.vesktop + config = { + home = { + username = "xeovalyte"; + homeDirectory = "/home/xeovalyte"; + }; - # Office - libreoffice - onlyoffice-bin + host = "xv-laptop"; - # Image editing - gimp - inkscape - ]; + home.packages = with pkgs; [ + # Desktop Applications + kdenlive + unstable.prismlauncher + unstable.joplin-desktop + unstable.moonlight-qt + unstable.prusa-slicer + signal-desktop + unstable.vesktop + + # Office + libreoffice + onlyoffice-bin + + # Image editing + gimp + inkscape + + ]; + + home.stateVersion = "24.05"; + }; - home.stateVersion = "24.05"; } diff --git a/hosts/vnix-ctr/default.nix b/hosts/vnix-ctr/default.nix new file mode 100644 index 0000000..58cf5ba --- /dev/null +++ b/hosts/vnix-ctr/default.nix @@ -0,0 +1,53 @@ +{ config, pkgs, ... }: + +{ + imports = [ # Include the results of the hardware scan. + ./hardware-configuration.nix + + # CLI + ../../modules/system/cli/common.nix + ../../modules/system/cli/podman.nix + + # Hardware + ../../modules/system/hardware/firewall.nix + ../../modules/system/hardware/garbage-collection.nix + ../../modules/system/hardware/locale.nix + ]; + + nix.settings = { + experimental-features = [ "nix-command" "flakes" ]; + + substituters = [ + "https://nix-community.cachix.org" + "https://cache.nixos.org/" + ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; + + # Bootloader + boot.loader.grub = { + enable = true; + device = "/dev/sda"; + useOSProber = true; + }; + + # Networking + networking.networkmanager.enable = true; + + networking.firewall = { + allowedTCPPorts = [ 1080 ]; + allowedUDPPorts = [ 53 ]; + }; + + # Configure user + users.users.xeovalyte = { + isNormalUser = true; + description = "Timo Boomers"; + extraGroups = [ "networkmanager" "wheel" "dialout" "fuse" ]; + }; + + system.stateVersion = "24.05"; + +} diff --git a/hosts/vnix-ctr/home.nix b/hosts/vnix-ctr/home.nix new file mode 100644 index 0000000..191f5aa --- /dev/null +++ b/hosts/vnix-ctr/home.nix @@ -0,0 +1,20 @@ +{ pkgs, ... }: + +{ + imports = [ + # GUI + ../../modules/home/gui/theming.nix + + # CLI + ../../modules/home/cli/common + ]; + + guiTheming.enable = false; + + home = { + username = "xeovalyte"; + homeDirectory = "/home/xeovalyte"; + }; + + home.stateVersion = "24.05"; +} diff --git a/modules/home/gui/hyprland/default.nix b/modules/home/gui/hyprland/default.nix index 01e00bb..bf7f71f 100644 --- a/modules/home/gui/hyprland/default.nix +++ b/modules/home/gui/hyprland/default.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, hostName, ... }: +{ config, pkgs, lib, ... }: { imports = [ @@ -24,12 +24,10 @@ wayland.windowManager.hyprland = { enable = true; settings = { - monitor = if hostName == "xv-laptop" then [ + monitor = lib.mkIf (config.host == "xv-laptop") [ "eDP-1,preferred,3840x0,1.333" "DP-10,preferred,0x0,1" "DP-9,preferred,1920x0,1" - ] else [ - ",preferred,auto,auto" ]; exec-once = [ @@ -81,7 +79,10 @@ force_zero_scaling = true; }; - workspace = if hostName == "xv-desktop" then [ + workspace = lib.mkMerge [[ + + ] + (lib.mkIf (config.host == "xv-desktop") [ "1, monitor:DP-2" "2, monitor:DP-2" "3, monitor:DP-2" @@ -92,7 +93,8 @@ "8, monitor:HDMI-A-1" "9, monitor:HDMI-A-1" "10, monitor:HDMI-A-1" - ] else [ + ]) + (lib.mkIf (config.host == "xv-laptop") [ "1, monitor:DP-10" "2, monitor:DP-10" "3, monitor:DP-10" @@ -103,7 +105,7 @@ "8, monitor:eDP-1" "9, monitor:eDP-1" "10, monitor:eDP-1" - ]; + ])]; bind = [ "$mod, Q, exec, alacritty" @@ -156,19 +158,7 @@ "$mod SHIFT, 8, movetoworkspace, 8" "$mod SHIFT, 9, movetoworkspace, 9" "$mod SHIFT, 0, movetoworkspace, 10" - ] ++ (if hostName == "xv-desktop" then [ - ",code:194,workspace, 6" - ",code:195,workspace, 7" - ",code:196,workspace, 8" - ",code:197,workspace, 9" - ",code:198,workspace, 10" - - "SHIFT, code:194, movetoworkspace, 6" - "SHIFT, code:195, movetoworkspace, 7" - "SHIFT, code:196, movetoworkspace, 8" - "SHIFT, code:197, movetoworkspace, 9" - "SHIFT, code:198, movetoworkspace, 10" - ] else [ ]); + ]; bindle = [ # Volume control diff --git a/modules/home/gui/hyprland/waybar.nix b/modules/home/gui/hyprland/waybar.nix index f18ec81..9d0a6e4 100644 --- a/modules/home/gui/hyprland/waybar.nix +++ b/modules/home/gui/hyprland/waybar.nix @@ -1,4 +1,4 @@ -{ hostName, pkgs, ... }: +{ pkgs, lib, config, ... }: { programs.waybar = { @@ -28,14 +28,14 @@ "on-scroll-up" = "hyprctl dispatch workspace e+1"; "on-scroll-down" = "hyprctl dispatch workspace e-1"; "on-click" = "activate"; - "persistent-workspaces" = if hostName == "xv-laptop" then { + "persistent-workspaces" = lib.mkMerge [{ + + } + (lib.mkIf (config.host == "xv-laptop") { "DP-10" = [ 1 2 3 4 ]; "DP-9" = [ 5 6 7 ]; "eDP-1" = [ 8 9 10 ]; - } else { - "DP-2" = [ 1 2 3 4 5 ]; - "HDMI-A-1" = [ 6 7 8 9 10 ]; - }; + })]; "format-icons" = { "default" = ""; "empty" = ""; diff --git a/modules/home/gui/theming.nix b/modules/home/gui/theming.nix index 4ac394f..df62324 100644 --- a/modules/home/gui/theming.nix +++ b/modules/home/gui/theming.nix @@ -5,37 +5,45 @@ let gtkThemeFromScheme; in { + options = { + guiTheming.enable = lib.mkEnableOption "Enable GTK and QT theming"; + }; + imports = [ nix-colors.homeManagerModules.default ]; - colorScheme = nix-colors.colorSchemes.da-one-sea; + config = { + guiTheming.enable = lib.mkDefault true; - gtk = { - enable = true; - theme = { - name = "${config.colorScheme.slug}"; - package = gtkThemeFromScheme { scheme = config.colorScheme; }; - }; - iconTheme = { - package = pkgs.qogir-icon-theme; - name = "Qogir-dark"; - }; - }; + colorScheme = nix-colors.colorSchemes.da-one-sea; - qt = { - enable = true; - platformTheme.name = "gtk"; - style = { - name = "gtk2"; - package = pkgs.qt6Packages.qt6gtk2; + gtk = lib.mkIf config.guiTheming.enable { + enable = true; + theme = { + name = "${config.colorScheme.slug}"; + package = gtkThemeFromScheme { scheme = config.colorScheme; }; + }; + iconTheme = { + package = pkgs.qogir-icon-theme; + name = "Qogir-dark"; + }; }; - }; - home.pointerCursor = { - package = pkgs.phinger-cursors; - name = "phinger-cursors-dark"; - size = 24; - gtk.enable = true; + qt = lib.mkIf config.guiTheming.enable { + enable = true; + platformTheme.name = "gtk"; + style = { + name = "gtk2"; + package = pkgs.qt6Packages.qt6gtk2; + }; + }; + + home.pointerCursor = lib.mkIf config.guiTheming.enable { + package = pkgs.phinger-cursors; + name = "phinger-cursors-dark"; + size = 24; + gtk.enable = true; + }; }; } diff --git a/modules/system/cli/podman.nix b/modules/system/cli/podman.nix new file mode 100644 index 0000000..ca51568 --- /dev/null +++ b/modules/system/cli/podman.nix @@ -0,0 +1,17 @@ +{ pkgs, ... }: + +{ + virtualisation.containers.enable = true; + + virtualisation.podman = { + enable = true; + dockerCompat = true; + defaultNetwork.settings.dns_enabled = true; + }; + + environment.systemPackages = with pkgs; [ + dive + podman-tui + podman-compose + ]; +}