diff --git a/boxes/desktop/configuration.nix b/boxes/desktop/configuration.nix index c2402c2..c7fd6e9 100644 --- a/boxes/desktop/configuration.nix +++ b/boxes/desktop/configuration.nix @@ -3,48 +3,15 @@ # https://search.nixos.org/options and in the NixOS manual (`nixos-help`). { config, lib, pkgs, inputs, ... }: - -let - _v = import ../../common/programs/virt.nix { }; - wireshark = import ../../common/programs/wireshark.nix { }; -in { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ../../common/modules/audio.nix - ../../common/modules/kde.nix + ../../common/systemModules/audio.nix + ../../common/systemModules/kde.nix ../../common/users/meyer - inputs.sops-nix.nixosModules.sops ]; - sops.defaultSopsFile = ../../secrets.yaml; - sops.defaultSopsFormat = "yaml"; - sops.age.keyFile = "/home/meyer/.config/sops/age/keys.txt"; - sops.secrets.password.neededForUsers = true; - users.users.meyer = { - isNormalUser = true; - hashedPasswordFile = config.sops.secrets.password.path; - extraGroups = [ - "wireshark" - "kvm" - "libvirtd" - "wheel" # Enable ‘sudo’ for the user. - "audio" - "sound" - "video" - "input" - "tty" - "plugdev" - ]; - shell = pkgs.zsh; - }; - home-manager = { - extraSpecialArgs = { inherit inputs; }; - users = { - "meyer" = import ./home.nix; - }; - }; # Use the systemd-boot EFI boot loader. boot.loader.grub.device = "nodev"; boot.kernelPackages = pkgs.linuxPackages_latest; @@ -81,28 +48,14 @@ in avahi.enable = true; usbmuxd.enable = true; }; - services.xserver.videoDrivers = ["amdgpu"]; + services.xserver.videoDrivers = [ "amdgpu" ]; services.printing.enable = true; services.printing.drivers = with pkgs; [ hplip ]; - virtualisation = _v; nix.settings.experimental-features = [ "nix-command" "flakes" ]; - # Enable sound. - # sound.enable = true; - # hardware.pulseaudio.enable = true; - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; - - # Define a user account. Don't forget to set a password with ‘passwd’. - - - - programs = { - inherit wireshark; - }; programs.zsh.enable = true; programs.steam.enable = true; programs.steam.extraCompatPackages = with pkgs; [ @@ -112,18 +65,12 @@ in - # networking.nameservers = ["10.0.0.97" "1.1.1.1"]; - # List packages installed in system profile. To search, run: - # $ nix search wget environment.systemPackages = with pkgs; [ clinfo fuse ifuse ddcutil i2c-tools - # python311 - # python311Packages.evdev - # python311Packages.xlib gcc neovim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. curl diff --git a/common/desktopEntries.nix b/common/desktopEntries.nix deleted file mode 100644 index ff88e85..0000000 --- a/common/desktopEntries.nix +++ /dev/null @@ -1,13 +0,0 @@ -{}: -{ - spotifyOpen = { - type = "Application"; - name = "Open in Spotify"; - genericName = "Music Player"; - icon = "spotify-client"; - terminal = false; - categories = [ "Audio" "Music" "Player" "AudioVideo" ]; - exec = "qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.OpenUri %U"; - mimeType = [ "x-scheme-handler/spotify" ]; - }; -} diff --git a/common/programs/arrpc.nix b/common/programs/arrpc.nix deleted file mode 100644 index 9974718..0000000 --- a/common/programs/arrpc.nix +++ /dev/null @@ -1,3 +0,0 @@ -{}: { -enable = true; -} diff --git a/common/programs/flameshot.nix b/common/programs/flameshot.nix deleted file mode 100644 index d14750e..0000000 --- a/common/programs/flameshot.nix +++ /dev/null @@ -1,11 +0,0 @@ -{config}: { - enable = true; - settings = { - General = { - savePath="/home/${config.home.username}/ss/"; - saveAsFileExtension=".png"; - showDesktopNotification=false; - startupLaunch=true; - }; - }; -} diff --git a/common/programs/virt.nix b/common/programs/virt.nix deleted file mode 100644 index 3f3afab..0000000 --- a/common/programs/virt.nix +++ /dev/null @@ -1,3 +0,0 @@ -{} : { - libvirtd.enable = true; -} diff --git a/common/programs/wireshark.nix b/common/programs/wireshark.nix index b8cb878..32ae4bd 100644 --- a/common/programs/wireshark.nix +++ b/common/programs/wireshark.nix @@ -1,3 +1,16 @@ -{} : { - enable = true; +{ NAME }: { ... }: { + programs = { + wireshark = { + enable = true; + }; + }; + users = { + users = { + "${NAME}" = { + extraGroups = [ + "wireshark" + ]; + }; + }; + }; } diff --git a/common/programs/zsh.nix b/common/programs/zsh.nix deleted file mode 100644 index 14bbc7f..0000000 --- a/common/programs/zsh.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ lib, pkgs }: -let - - _ = [ - "source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme" - "source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" - "[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh" - "setopt globstarshort" - ]; - zshInitArgs = lib.concatMapStrings (x: x + "\n") _; -in -{ - enable = true; - oh-my-zsh.enable = true; - initExtra = zshInitArgs; - enableCompletion = true; - plugins = [ - { - name = "zsh-nix-shell"; - file = "nix-shell.plugin.zsh"; - src = pkgs.fetchFromGitHub { - owner = "chisui"; - repo = "zsh-nix-shell"; - rev = "v0.8.0"; - sha256 = "1lzrn0n4fxfcgg65v0qhnj7wnybybqzs4adz7xsrkgmcsr0ii8b7"; - }; - } - ]; -} diff --git a/common/sops.nix b/common/sops.nix deleted file mode 100644 index eec8abe..0000000 --- a/common/sops.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ config }: -{ - age.keyFile = "/home/${config.home.username}/.config/sops/age/keys.txt"; - defaultSopsFile = ../secrets.yaml; - secrets.hosts = { - format = "binary"; - sopsFile = ../secrets/hosts; - path = "/home/${config.home.username}/.config/gh/hosts.yml"; - }; - } diff --git a/common/modules/audio.nix b/common/systemModules/audio.nix similarity index 100% rename from common/modules/audio.nix rename to common/systemModules/audio.nix diff --git a/common/modules/kde.nix b/common/systemModules/kde.nix similarity index 100% rename from common/modules/kde.nix rename to common/systemModules/kde.nix diff --git a/common/users/modules/networkManager.nix b/common/systemModules/networkManager.nix similarity index 100% rename from common/users/modules/networkManager.nix rename to common/systemModules/networkManager.nix diff --git a/common/systemModules/sops.nix b/common/systemModules/sops.nix new file mode 100644 index 0000000..2ea4f85 --- /dev/null +++ b/common/systemModules/sops.nix @@ -0,0 +1,24 @@ +{ NAME }: { config, inputs, ... }: { + imports = [ + inputs.sops-nix.nixosModules.sops + ]; + sops = { + defaultSopsFile = ../../secrets.yaml; + defaultSopsFormat = "yaml"; + age = { + keyFile = "/home/${NAME}/.config/sops/age/keys.txt"; + }; + secrets = { + password = { + neededForUsers = true; + }; + }; + }; + users = { + users = { + "${NAME}" = { + hashedPasswordFile = config.sops.secrets.password.path; + }; + }; + }; +} diff --git a/common/systemModules/vm.nix b/common/systemModules/vm.nix new file mode 100644 index 0000000..8881d87 --- /dev/null +++ b/common/systemModules/vm.nix @@ -0,0 +1,14 @@ +{ NAME }: { ... }: { + virtualisation = { + libvirtd = { + enable = true; + }; + }; + users = { + users = { + "${NAME}" = { + extraGroups = [ "kvm" "libvirtd" ]; + }; + }; + }; +} diff --git a/common/users/homeModules/arrpc.nix b/common/users/homeModules/arrpc.nix new file mode 100644 index 0000000..fa9ea3c --- /dev/null +++ b/common/users/homeModules/arrpc.nix @@ -0,0 +1,7 @@ +{ ... }: { + services = { + arrpc = { + enable = true; + }; + }; +} diff --git a/common/users/homeModules/desktopEntries.nix b/common/users/homeModules/desktopEntries.nix new file mode 100644 index 0000000..f458bf9 --- /dev/null +++ b/common/users/homeModules/desktopEntries.nix @@ -0,0 +1,17 @@ +{ ... }: +{ + xdg = { + desktopEntries = { + spotifyOpen = { + type = "Application"; + name = "Open in Spotify"; + genericName = "Music Player"; + icon = "spotify-client"; + terminal = false; + categories = [ "Audio" "Music" "Player" "AudioVideo" ]; + exec = "qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.OpenUri %U"; + mimeType = [ "x-scheme-handler/spotify" ]; + }; + }; + }; +} diff --git a/common/users/homeModules/flameshot.nix b/common/users/homeModules/flameshot.nix new file mode 100644 index 0000000..1d26929 --- /dev/null +++ b/common/users/homeModules/flameshot.nix @@ -0,0 +1,15 @@ +{ config, ... }: { + services = { + flameshot = { + enable = true; + settings = { + General = { + savePath = "/home/${config.home.username}/ss/"; + saveAsFileExtension = ".png"; + showDesktopNotification = false; + startupLaunch = true; + }; + }; + }; + }; +} diff --git a/common/users/homeModules/zsh.nix b/common/users/homeModules/zsh.nix new file mode 100644 index 0000000..f13ff48 --- /dev/null +++ b/common/users/homeModules/zsh.nix @@ -0,0 +1,37 @@ +{ lib, pkgs, ... }: +let + + _ = [ + "source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme" + "source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" + "[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh" + "setopt globstarshort" + ]; + zshInitArgs = lib.concatMapStrings (x: x + "\n") _; +in +{ + programs = { + zoxide = { + enable = true; + enableZshIntegration = true; + }; + zsh = { + enable = true; + oh-my-zsh.enable = true; + initExtra = zshInitArgs; + enableCompletion = true; + plugins = [ + { + name = "zsh-nix-shell"; + file = "nix-shell.plugin.zsh"; + src = pkgs.fetchFromGitHub { + owner = "chisui"; + repo = "zsh-nix-shell"; + rev = "v0.8.0"; + sha256 = "1lzrn0n4fxfcgg65v0qhnj7wnybybqzs4adz7xsrkgmcsr0ii8b7"; + }; + } + ]; + }; + }; +} diff --git a/common/users/meyer/default.nix b/common/users/meyer/default.nix index ac423b5..d5daff4 100644 --- a/common/users/meyer/default.nix +++ b/common/users/meyer/default.nix @@ -1,9 +1,35 @@ -{ ... }: +{ pkgs, inputs, ... }: let NAME = "meyer"; in { imports = [ - (import ../modules/networkManager.nix { inherit NAME; }) + (import ../../systemModules/networkManager.nix { inherit NAME; }) + (import ../../systemModules/sops.nix { inherit NAME; }) + (import ../../systemModules/vm.nix { inherit NAME; }) + (import ../../programs/wireshark.nix { inherit NAME; }) ]; + users = { + users = { + "${NAME}" = { + isNormalUser = true; + extraGroups = [ + "wheel" # Enable ‘sudo’ for the user. + "audio" + "sound" + "video" + "input" + "tty" + "plugdev" + ]; + shell = pkgs.zsh; + }; + }; + }; + home-manager = { + extraSpecialArgs = { inherit inputs; }; + users = { + "${NAME}" = import ./home.nix; + }; + }; } diff --git a/boxes/desktop/home.nix b/common/users/meyer/home.nix similarity index 71% rename from boxes/desktop/home.nix rename to common/users/meyer/home.nix index 803a732..dc2a6cf 100644 --- a/boxes/desktop/home.nix +++ b/common/users/meyer/home.nix @@ -1,29 +1,22 @@ -{ config, lib, pkgs, inputs, ... }: +{ config, pkgs, inputs, ... }: let - flameshot = import ../../common/programs/flameshot.nix { inherit config; }; - arrpc = import ../../common/programs/arrpc.nix { }; - zsh = import ../../common/programs/zsh.nix { inherit lib pkgs; }; - _s1 = import ../../common/sops.nix { inherit config; }; - files = import ../../common/files.nix { inherit config; }; - shell = import ../../common/shell.nix { inherit config pkgs; }; - p = import ../../common/pkgs.nix { inherit pkgs config; }; - _p1 = p.dev ++ p.gui ++ p.general ++ p.scripts ++ p.gaming; - DES = import ../../common/desktopEntries.nix { }; + files = import ../../files.nix { inherit config; }; + shell = import ../../shell.nix { inherit config pkgs; }; + pkgTypes = import ../../pkgs.nix { inherit pkgs config; }; + packages = pkgTypes.dev ++ pkgTypes.gui ++ pkgTypes.general ++ pkgTypes.scripts ++ pkgTypes.gaming; in { nixpkgs.config.allowInsecurePredicate = (pkg: true); imports = [ - inputs.sops-nix.homeManagerModules.sops + ../homeModules/flameshot.nix + ../homeModules/arrpc.nix + ../homeModules/zsh.nix + ../homeModules/desktopEntries.nix + ./sops.nix ]; - sops = _s1; - programs = { - inherit zsh; - }; programs.java.enable = true; programs.java.package = pkgs.temurin-bin-17; - programs.zoxide.enable = true; - programs.zoxide.enableZshIntegration = true; programs.git.enable = true; programs.git.userName = "sadan"; programs.git.userEmail = "117494111+sadan4@users.noreply.github.com"; @@ -48,9 +41,6 @@ in home.homeDirectory = "/home/meyer"; - services = { - inherit arrpc flameshot; - }; # This value determines the Home Manager release that your configuration is # compatible with. This helps avoid breakage when a new Home Manager release # introduces backwards incompatible changes. @@ -61,7 +51,9 @@ in home.stateVersion = "23.11"; # Please read the comment before changing. # The home.packages option allows you to install Nix packages into your # environment. - home.packages = _p1; + home = { + inherit packages; + }; # Home Manager is pretty good at managing dotfiles. The primary way to manage # plain files is through 'home.file'. home.file = files; @@ -84,7 +76,6 @@ in home.shellAliases = shell.dev.aliases; home.sessionPath = shell.dev.path; home.sessionVariables = shell.dev.env; - xdg.desktopEntries = DES; # Let Home Manager install and manage itself. programs.home-manager.enable = true; diff --git a/common/users/meyer/sops.nix b/common/users/meyer/sops.nix new file mode 100644 index 0000000..1241cbd --- /dev/null +++ b/common/users/meyer/sops.nix @@ -0,0 +1,15 @@ +{ config, inputs, ... }: +{ + imports = [ + inputs.sops-nix.homeManagerModules.sops + ]; + sops = { + age.keyFile = "/home/${config.home.username}/.config/sops/age/keys.txt"; + defaultSopsFile = ../../../secrets.yaml; + secrets.hosts = { + format = "binary"; + sopsFile = ../../../secrets/hosts; + path = "/home/${config.home.username}/.config/gh/hosts.yml"; + }; + }; +}