diff --git a/flake.nix b/flake.nix index c35e792..c6602de 100644 --- a/flake.nix +++ b/flake.nix @@ -23,10 +23,10 @@ # ========= Utilities ========= # # Secrets management - sops-nix = { - url = "github:mic92/sops-nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + # sops-nix = { + # url = "github:mic92/sops-nix"; + # inputs.nixpkgs.follows = "nixpkgs"; + # }; # Catppuccin theming catppuccin = { url = "github:catppuccin/nix"; @@ -76,7 +76,7 @@ lib = nixpkgs.lib.extend customLib; libHm = home-manager.lib.extend customLib; - systems = [ + systems = builtins.map (config: defaultAttrs // config) [ { hostName = "desktop"; system = "x86_64-linux"; @@ -94,6 +94,16 @@ # TODO Homelab config ]; + defaultAttrs = { + user = { + name = common.username; + password = "temp"; + }; + version = common.system.version; + wayland.enable = true; + nvidia.enable = false; + }; + in { # @@ -110,18 +120,9 @@ { hostName, system, - user ? { - name = common.username; - password = "temp"; - }, - version ? common.version, - wayland ? { - enable = true; - }, - nvidia ? { - enable = false; - }, - }@systemConfig: # TODO only pass in systemConfig + user, + ... + }@systemConfig: { name = hostName; diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index ef3c46f..26e06e8 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -1,70 +1,11 @@ { - pkgs, - inputs, - outputs, - common, + lib, ... }: { - imports = [ ./modules ]; - - nixpkgs.overlays = [ outputs.overlays.unstable-packages ]; - - # Bootloader. - boot.loader = { - systemd-boot.enable = true; - efi.canTouchEfiVariables = true; - }; - - # Define a user account. Don't forget to set a password with 'passwd'. - users.users.${common.username} = { - isNormalUser = true; - description = common.username; - extraGroups = [ - "networkmanager" - "wheel" - ]; - }; - - # Allow unfree packages - nixpkgs.config.allowUnfree = true; - - environment.sessionVariables = { - # Tells Electron apps to use Wayland - NIXOS_OZONE_WL = "1"; - }; - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - wget - xdg-utils - xdg-desktop-portal - xdg-desktop-portal-gtk - unstable.protonmail-desktop - stremio - fastfetch - discord - nix-prefetch-github # Cmd to get rev and hash from GitHub - gimp - vlc - vdhcoapp # TODO run "vdhcoapp install" on startup - onlyoffice-desktopeditors - inputs.grayjay.packages.${system}.grayjay + imports = [ + (lib.custom.relativeToRoot "shared/modules") + ./hardware-configuration.nix ]; - - nix.settings.experimental-features = [ - "nix-command" - "flakes" - ]; - - programs.kdeconnect.enable = true; - - services = { - flatpak.enable = false; - xserver.enable = true; - }; - - system.stateVersion = common.system.version; } diff --git a/hosts/desktop/modules/hardware-configuration.nix b/hosts/desktop/hardware-configuration.nix similarity index 100% rename from hosts/desktop/modules/hardware-configuration.nix rename to hosts/desktop/hardware-configuration.nix diff --git a/hosts/desktop/modules/default.nix b/hosts/desktop/modules/default.nix deleted file mode 100644 index 4b22dc7..0000000 --- a/hosts/desktop/modules/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ lib, ... }: - -{ - imports = [ - (lib.custom.relativeToRoot "shared/modules") - ./hardware-configuration.nix - ]; -} diff --git a/hosts/thinkpad/modules/battery.nix b/hosts/thinkpad/battery.nix similarity index 100% rename from hosts/thinkpad/modules/battery.nix rename to hosts/thinkpad/battery.nix diff --git a/hosts/thinkpad/modules/bluetooth.nix b/hosts/thinkpad/bluetooth.nix similarity index 100% rename from hosts/thinkpad/modules/bluetooth.nix rename to hosts/thinkpad/bluetooth.nix diff --git a/hosts/thinkpad/default.nix b/hosts/thinkpad/default.nix index 682f4b1..48dd47b 100644 --- a/hosts/thinkpad/default.nix +++ b/hosts/thinkpad/default.nix @@ -1,72 +1,23 @@ { pkgs, - outputs, - common, + lib, ... }: { - imports = [ ./modules ]; + imports = [ + (lib.custom.relativeToRoot "shared/modules") + ./battery.nix + ./bluetooth.nix + ./hardware-configuration.nix + ./security.nix + ]; - nixpkgs.overlays = [ outputs.overlays.unstable-packages ]; + boot.kernelPackages = pkgs.linuxPackages_latest; - # Bootloader. - boot = { - kernelPackages = pkgs.linuxPackages_latest; - loader = { - systemd-boot.enable = true; - efi.canTouchEfiVariables = true; - }; - }; - - # Define a user account. Don't forget to set a password with 'passwd'. - users.users.${common.username} = { - isNormalUser = true; - description = common.username; - extraGroups = [ - "networkmanager" - "wheel" - ]; - }; - - # Allow unfree packages - nixpkgs.config.allowUnfree = true; - - environment.sessionVariables = { - # Tells Electron apps to use Wayland - NIXOS_OZONE_WL = "1"; - }; - - # List packages installed in system profile. To search, run: - # $ nix search wget environment.systemPackages = with pkgs; [ brightnessctl - wget - xdg-utils - xdg-desktop-portal - xdg-desktop-portal-gtk - unstable.protonmail-desktop - stremio - fastfetch - discord - nix-prefetch-github # Cmd to get rev and hash from GitHub - gimp - vlc - vdhcoapp - onlyoffice-desktopeditors + hyprsunset # Blue light filter ]; - nix.settings.experimental-features = [ - "nix-command" - "flakes" - ]; - - programs.kdeconnect.enable = true; - - services = { - flatpak.enable = false; - xserver.enable = true; - }; - - system.stateVersion = common.system.version; } diff --git a/hosts/thinkpad/modules/hardware-configuration.nix b/hosts/thinkpad/hardware-configuration.nix similarity index 100% rename from hosts/thinkpad/modules/hardware-configuration.nix rename to hosts/thinkpad/hardware-configuration.nix diff --git a/hosts/thinkpad/modules/default.nix b/hosts/thinkpad/modules/default.nix deleted file mode 100644 index 2069513..0000000 --- a/hosts/thinkpad/modules/default.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ pkgs, lib, ... }: - -{ - imports = [ - (lib.custom.relativeToRoot "shared/modules") - ./battery.nix - ./bluetooth.nix - ./hardware-configuration.nix - ./security.nix - ]; - - environment.systemPackages = with pkgs; [ - hyprsunset # Blue light filter - ]; -} diff --git a/hosts/thinkpad/modules/security.nix b/hosts/thinkpad/security.nix similarity index 100% rename from hosts/thinkpad/modules/security.nix rename to hosts/thinkpad/security.nix diff --git a/shared/modules/boot.nix b/shared/modules/boot.nix new file mode 100644 index 0000000..fca6970 --- /dev/null +++ b/shared/modules/boot.nix @@ -0,0 +1,6 @@ +{ + boot.loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; +} diff --git a/shared/modules/default.nix b/shared/modules/default.nix index 5999ba5..c9e72c8 100644 --- a/shared/modules/default.nix +++ b/shared/modules/default.nix @@ -1,17 +1,28 @@ { imports = [ + ./boot.nix ./development + ./electron.nix ./fonts.nix ./gaming ./gnome ./hardware + ./kdeconnect.nix ./locale.nix + ./mail.nix + ./media.nix ./networking.nix + ./nixos.nix ./nix-helper.nix + ./office.nix ./hyprland ./sddm.nix ./security.nix ./shell.nix + ./social.nix + ./users.nix ./qt.nix + ./xdg.nix + ./xserver.nix ]; } diff --git a/shared/modules/electron.nix b/shared/modules/electron.nix new file mode 100644 index 0000000..b76341d --- /dev/null +++ b/shared/modules/electron.nix @@ -0,0 +1,8 @@ +{ lib, systemConfig, ... }: + +{ + environment.sessionVariables = lib.mkIf systemConfig.wayland.enable { + # Tells Electron apps to use Wayland + NIXOS_OZONE_WL = "1"; + }; +} diff --git a/shared/modules/kdeconnect.nix b/shared/modules/kdeconnect.nix new file mode 100644 index 0000000..0cb7c87 --- /dev/null +++ b/shared/modules/kdeconnect.nix @@ -0,0 +1,3 @@ +{ + programs.kdeconnect.enable = true; +} diff --git a/shared/modules/mail.nix b/shared/modules/mail.nix new file mode 100644 index 0000000..ce75156 --- /dev/null +++ b/shared/modules/mail.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + unstable.protonmail-desktop + ]; +} diff --git a/shared/modules/media.nix b/shared/modules/media.nix new file mode 100644 index 0000000..3cd7107 --- /dev/null +++ b/shared/modules/media.nix @@ -0,0 +1,11 @@ +{ pkgs, inputs, ... }: + +{ + environment.systemPackages = with pkgs; [ + stremio + gimp + vlc + vdhcoapp + inputs.grayjay.packages.${system}.grayjay + ]; +} diff --git a/shared/modules/networking.nix b/shared/modules/networking.nix index 7ac233a..4e79445 100644 --- a/shared/modules/networking.nix +++ b/shared/modules/networking.nix @@ -1,6 +1,10 @@ -{ systemConfig, ... }: +{ pkgs, systemConfig, ... }: { + environment.systemPackages = with pkgs; [ + wget + ]; + networking = { networkmanager.enable = true; hostName = systemConfig.hostName; diff --git a/shared/modules/nixos.nix b/shared/modules/nixos.nix new file mode 100644 index 0000000..2bb4930 --- /dev/null +++ b/shared/modules/nixos.nix @@ -0,0 +1,25 @@ +{ + pkgs, + outputs, + systemConfig, + ... +}: + +{ + environment.systemPackages = with pkgs; [ + nix-prefetch-github # Cmd to get rev and hash from GitHub + ]; + + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; + + nixpkgs = { + # Allow unfree packages + config.allowUnfree = true; + overlays = [ outputs.overlays.unstable-packages ]; + }; + + system.stateVersion = systemConfig.version; +} diff --git a/shared/modules/office.nix b/shared/modules/office.nix new file mode 100644 index 0000000..59dec77 --- /dev/null +++ b/shared/modules/office.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + onlyoffice-desktopeditors + ]; +} diff --git a/shared/modules/social.nix b/shared/modules/social.nix new file mode 100644 index 0000000..26fb62a --- /dev/null +++ b/shared/modules/social.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + discord + ]; +} diff --git a/shared/modules/users.nix b/shared/modules/users.nix new file mode 100644 index 0000000..0fce21a --- /dev/null +++ b/shared/modules/users.nix @@ -0,0 +1,15 @@ +{ systemConfig, ... }: +let + username = systemConfig.user.name; +in +{ + # Define a user without a password, TODO pass in user.password + users.users.${username} = { + isNormalUser = true; + description = username; + extraGroups = [ + "networkmanager" + "wheel" + ]; + }; +} diff --git a/shared/modules/xdg.nix b/shared/modules/xdg.nix new file mode 100644 index 0000000..24b511f --- /dev/null +++ b/shared/modules/xdg.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + xdg-utils + xdg-desktop-portal + xdg-desktop-portal-gtk + ]; +} diff --git a/shared/modules/xserver.nix b/shared/modules/xserver.nix new file mode 100644 index 0000000..1d78081 --- /dev/null +++ b/shared/modules/xserver.nix @@ -0,0 +1,3 @@ +{ + services.xserver.enable = true; +}