diff --git a/common/desktop-node.nix b/common/desktop-node.nix new file mode 100644 index 0000000..69725d0 --- /dev/null +++ b/common/desktop-node.nix @@ -0,0 +1,56 @@ +{ pkgs, ... }: +{ + # Enable Hyprland (Wayland compositor) + programs.hyprland = { + enable = true; + xwayland.enable = true; # For compatibility with X11 apps if needed + }; + + # Essential desktop services + services.dbus.enable = true; + + # polkit for privilege escalation + security.polkit.enable = true; + + # Enable sound with pipewire + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + + # XDG portal for screen sharing, file pickers, etc. + xdg.portal = { + enable = true; + extraPortals = [ pkgs.xdg-desktop-portal-hyprland ]; + }; + + # Fonts + fonts.packages = with pkgs; [ + noto-fonts + noto-fonts-cjk-sans + noto-fonts-emoji + liberation_ttf + fira-code + fira-code-symbols + ]; + + # Enable GDM for login (can also use greetd or ly for lighter options) + services.greetd = { + enable = true; + settings = { + default_session = { + command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd Hyprland"; + user = "greeter"; + }; + }; + }; + + # Environment variables for Wayland + environment.sessionVariables = { + NIXOS_OZONE_WL = "1"; # Hint electron apps to use Wayland + WLR_NO_HARDWARE_CURSORS = "1"; # Fix cursor rendering on some hardware + }; +} diff --git a/flake.nix b/flake.nix index 1264a00..62a0dc2 100644 --- a/flake.nix +++ b/flake.nix @@ -54,8 +54,8 @@ }; }; - mkNixos = - system: modules: + mkHost = + system: profile: modules: nixpkgs.lib.nixosSystem { system = system; modules = [ @@ -69,31 +69,30 @@ disko.nixosModules.disko sops-nix.nixosModules.sops impermanence.nixosModules.impermanence + home-manager.nixosModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.ppetru = { + imports = [ + (inputs.impermanence + "/home-manager.nix") + inputs.nix-index-database.homeModules.nix-index + inputs.nixvim.homeModules.nixvim + ./home + ]; + }; + extraSpecialArgs = { + inherit profile; + }; + }; + } ] ++ modules; specialArgs = { inherit inputs self; }; }; - mkHMNixos = - system: modules: - mkNixos system ([ - home-manager.nixosModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - users.ppetru = { - imports = [ - (inputs.impermanence + "/home-manager.nix") - inputs.nix-index-database.homeModules.nix-index - inputs.nixvim.homeModules.nixvim - ./home - ]; - }; - }; - }] ++ modules); - pkgsFor = system: import nixpkgs { @@ -119,16 +118,16 @@ in { nixosConfigurations = { - c1 = mkHMNixos "x86_64-linux" [ ./hosts/c1 ]; - c2 = mkHMNixos "x86_64-linux" [ ./hosts/c2 ]; - c3 = mkHMNixos "x86_64-linux" [ ./hosts/c3 ]; - alo-cloud-1 = mkHMNixos "aarch64-linux" [ ./hosts/alo-cloud-1 ]; - zippy = mkHMNixos "x86_64-linux" [ + c1 = mkHost "x86_64-linux" "server" [ ./hosts/c1 ]; + c2 = mkHost "x86_64-linux" "server" [ ./hosts/c2 ]; + c3 = mkHost "x86_64-linux" "server" [ ./hosts/c3 ]; + alo-cloud-1 = mkHost "aarch64-linux" "server" [ ./hosts/alo-cloud-1 ]; + zippy = mkHost "x86_64-linux" "workstation" [ ethereum-nix.nixosModules.default ./hosts/zippy ]; - chilly = mkHMNixos "x86_64-linux" [ ./hosts/chilly ]; - sparky = mkHMNixos "x86_64-linux" [ ./hosts/sparky ]; + chilly = mkHost "x86_64-linux" "workstation" [ ./hosts/chilly ]; + sparky = mkHost "x86_64-linux" "desktop" [ ./hosts/sparky ]; }; deploy = { diff --git a/home/default.nix b/home/default.nix index 1868a9a..b43817c 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,7 +1,7 @@ -{ pkgs, ... }: +{ pkgs, profile ? "cli", ... }: { home = { - packages = (import ./packages.nix { inherit pkgs; }).packages; + packages = (import ./packages.nix { inherit pkgs profile; }).packages; stateVersion = "24.05"; # TODO: unify this with the references in flake.nix:inputs sessionVariables = { diff --git a/home/packages.nix b/home/packages.nix index b428c3f..6d499b7 100644 --- a/home/packages.nix +++ b/home/packages.nix @@ -1,38 +1,7 @@ -{ pkgs }: +{ pkgs, profile ? "workstation" }: let - corePkgs = with pkgs; [ - unstable.claude-code - unstable.codex - unstable.chromium - unstable.gemini-cli - unstable.playwright - unstable.playwright-driver.browsers - unstable.playwright-mcp - direnv - fzf - git - mosh - ripgrep - tmux - zsh - ]; - - pythonEnv = pkgs.unstable.python3.withPackages (ps: [ - # unstable only - # ps.aider-chat - ps.google-generativeai - ps.ipython - ps.llm - ps.llm-gemini - ]); - - fishPkgs = with pkgs.fishPlugins; [ - pure - # don't add failed commands to history - sponge - transient-fish - ]; + profilePackages = import ./profiles/${profile}.nix { inherit pkgs; }; in { - packages = corePkgs ++ [ pythonEnv ] ++ fishPkgs; + packages = profilePackages.packages; } diff --git a/home/profiles/desktop.nix b/home/profiles/desktop.nix new file mode 100644 index 0000000..f97f9ac --- /dev/null +++ b/home/profiles/desktop.nix @@ -0,0 +1,12 @@ +{ pkgs }: +let + workstationProfile = import ./workstation.nix { inherit pkgs; }; + + desktopPkgs = with pkgs; [ + unstable.chromium + foot # Wayland-native terminal emulator + ]; +in +{ + packages = workstationProfile.packages ++ desktopPkgs; +} diff --git a/home/profiles/server.nix b/home/profiles/server.nix new file mode 100644 index 0000000..79c0774 --- /dev/null +++ b/home/profiles/server.nix @@ -0,0 +1,27 @@ +{ pkgs }: +let + corePkgs = with pkgs; [ + direnv + fzf + git + mosh + ripgrep + tmux + zsh + ]; + + pythonEnv = pkgs.unstable.python3.withPackages (ps: [ + ps.google-generativeai + ps.ipython + ]); + + fishPkgs = with pkgs.fishPlugins; [ + pure + # don't add failed commands to history + sponge + transient-fish + ]; +in +{ + packages = corePkgs ++ [ pythonEnv ] ++ fishPkgs; +} diff --git a/home/profiles/workstation.nix b/home/profiles/workstation.nix new file mode 100644 index 0000000..6e339f5 --- /dev/null +++ b/home/profiles/workstation.nix @@ -0,0 +1,20 @@ +{ pkgs }: +let + serverProfile = import ./server.nix { inherit pkgs; }; + + cliPkgs = with pkgs; [ + unstable.claude-code + unstable.codex + unstable.gemini-cli + ]; + + pythonEnv = pkgs.unstable.python3.withPackages (ps: [ + ps.google-generativeai + ps.ipython + ps.llm + ps.llm-gemini + ]); +in +{ + packages = serverProfile.packages ++ cliPkgs ++ [ pythonEnv ]; +} diff --git a/hosts/sparky/default.nix b/hosts/sparky/default.nix index 7b536de..76236e5 100644 --- a/hosts/sparky/default.nix +++ b/hosts/sparky/default.nix @@ -5,6 +5,7 @@ ../../common/global ../../common/base-node.nix ../../common/dev-node.nix + ../../common/desktop-node.nix ./hardware.nix ];