diff --git a/flake.lock b/flake.lock index bcdf334..48fd8ab 100644 --- a/flake.lock +++ b/flake.lock @@ -1,38 +1,5 @@ { "nodes": { - "aquamarine": { - "inputs": { - "hyprutils": [ - "hyprland", - "hyprutils" - ], - "hyprwayland-scanner": [ - "hyprland", - "hyprwayland-scanner" - ], - "nixpkgs": [ - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1725199881, - "narHash": "sha256-jsmipf/u1GFZE5tBUkr56CHMN6VpUWCAjfLIhvQijU0=", - "owner": "hyprwm", - "repo": "aquamarine", - "rev": "f8a687dd29ff019657498f1bd14da2fbbf0e604b", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "aquamarine", - "type": "github" - } - }, "home-manager": { "inputs": { "nixpkgs": [ @@ -53,190 +20,6 @@ "type": "github" } }, - "hy3": { - "inputs": { - "hyprland": [ - "hyprland" - ] - }, - "locked": { - "lastModified": 1725573970, - "narHash": "sha256-KJKO4b5Gl+7t3hF+X56Y0W/Lxf2OxWl/aLgzbiN3+hI=", - "owner": "outfoxxed", - "repo": "hy3", - "rev": "e91460d63627cdad417cac2c09897be58094e2e0", - "type": "github" - }, - "original": { - "owner": "outfoxxed", - "repo": "hy3", - "type": "github" - } - }, - "hyprcursor": { - "inputs": { - "hyprlang": [ - "hyprland", - "hyprlang" - ], - "nixpkgs": [ - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1722623071, - "narHash": "sha256-sLADpVgebpCBFXkA1FlCXtvEPu1tdEsTfqK1hfeHySE=", - "owner": "hyprwm", - "repo": "hyprcursor", - "rev": "912d56025f03d41b1ad29510c423757b4379eb1c", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprcursor", - "type": "github" - } - }, - "hyprland": { - "inputs": { - "aquamarine": "aquamarine", - "hyprcursor": "hyprcursor", - "hyprlang": "hyprlang", - "hyprutils": "hyprutils", - "hyprwayland-scanner": "hyprwayland-scanner", - "nixpkgs": [ - "nixpkgs" - ], - "systems": "systems", - "xdph": "xdph" - }, - "locked": { - "lastModified": 1725738873, - "narHash": "sha256-8OT3XRoPoAhiYHMT/hQ6uKE4o7Z99a1Y+711oEPV+dg=", - "ref": "refs/heads/main", - "rev": "70add904c40924a761059e4009a8c0f1e43d76a3", - "revCount": 5194, - "submodules": true, - "type": "git", - "url": "https://github.com/hyprwm/Hyprland" - }, - "original": { - "submodules": true, - "type": "git", - "url": "https://github.com/hyprwm/Hyprland" - } - }, - "hyprland-protocols": { - "inputs": { - "nixpkgs": [ - "hyprland", - "xdph", - "nixpkgs" - ], - "systems": [ - "hyprland", - "xdph", - "systems" - ] - }, - "locked": { - "lastModified": 1721326555, - "narHash": "sha256-zCu4R0CSHEactW9JqYki26gy8h9f6rHmSwj4XJmlHgg=", - "owner": "hyprwm", - "repo": "hyprland-protocols", - "rev": "5a11232266bf1a1f5952d5b179c3f4b2facaaa84", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprland-protocols", - "type": "github" - } - }, - "hyprlang": { - "inputs": { - "hyprutils": [ - "hyprland", - "hyprutils" - ], - "nixpkgs": [ - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1725188252, - "narHash": "sha256-yBH8c4GDaEAtBrh+BqIlrx5vp6gG/Gu8fQQK63KAQgs=", - "owner": "hyprwm", - "repo": "hyprlang", - "rev": "c12ab785ce1982f82594aff03b3104c598186ddd", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprlang", - "type": "github" - } - }, - "hyprutils": { - "inputs": { - "nixpkgs": [ - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1724966483, - "narHash": "sha256-WXDgKIbzjYKczxSZOsJplCS1i1yrTUpsDPuJV/xpYLo=", - "owner": "hyprwm", - "repo": "hyprutils", - "rev": "8976e3f6a5357da953a09511d0c7f6a890fb6ec2", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprutils", - "type": "github" - } - }, - "hyprwayland-scanner": { - "inputs": { - "nixpkgs": [ - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1721324119, - "narHash": "sha256-SOOqIT27/X792+vsLSeFdrNTF+OSRp5qXv6Te+fb2Qg=", - "owner": "hyprwm", - "repo": "hyprwayland-scanner", - "rev": "a048a6cb015340bd82f97c1f40a4b595ca85cc30", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprwayland-scanner", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1725634671, @@ -256,55 +39,8 @@ "root": { "inputs": { "home-manager": "home-manager", - "hy3": "hy3", - "hyprland": "hyprland", "nixpkgs": "nixpkgs" } - }, - "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" - } - }, - "xdph": { - "inputs": { - "hyprland-protocols": "hyprland-protocols", - "hyprlang": [ - "hyprland", - "hyprlang" - ], - "nixpkgs": [ - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1725203932, - "narHash": "sha256-VLULC/OnI+6R9KEP2OIGk+uLJJsfRlaLouZ5gyFd2+Y=", - "owner": "hyprwm", - "repo": "xdg-desktop-portal-hyprland", - "rev": "2425e8f541525fa7409d9f26a8ffaf92a3767251", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "xdg-desktop-portal-hyprland", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index cf0aa53..f005ec7 100644 --- a/flake.nix +++ b/flake.nix @@ -8,17 +8,6 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; - - hyprland = { - type = "git"; - url = "https://github.com/hyprwm/Hyprland"; - submodules = true; - inputs.nixpkgs.follows = "nixpkgs"; - }; - hy3 = { - url = "github:outfoxxed/hy3"; - inputs.hyprland.follows = "hyprland"; - }; }; outputs = { self, nixpkgs, ... } @ inputs: { @@ -39,8 +28,8 @@ nixosConfigurations.nix-book = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; - specialArgs = { inherit inputs; }; modules = [ + ./roles ./machines/nix-book/configuration.nix inputs.home-manager.nixosModules.home-manager { @@ -52,7 +41,7 @@ ]; }; - nixosConfigurations.boxy= nixpkgs.lib.nixosSystem { + nixosConfigurations.boxy = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { inherit inputs; }; modules = [ diff --git a/home/home-default.nix b/home/home-default.nix index bc74e46..7723c9c 100644 --- a/home/home-default.nix +++ b/home/home-default.nix @@ -1,6 +1,5 @@ -{ config, pkgs, lib, ... }: +{ pkgs, ... }: -with import {}; let nextcloudTalkDesktop = pkgs.callPackage ./modules/applications/nextcloud-talk-desktop/package.nix {}; in @@ -109,7 +108,6 @@ in imports = [ ./modules/applications/emacs/default.nix ./modules/games/lutris/default.nix - ./modules/window_managers/hyprland/default.nix ./modules/window_managers/i3/default.nix ]; diff --git a/machines/nix-book/configuration.nix b/machines/nix-book/configuration.nix index a725a04..5426328 100644 --- a/machines/nix-book/configuration.nix +++ b/machines/nix-book/configuration.nix @@ -2,21 +2,24 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ config, pkgs, inputs, ... }: - +{ pkgs, ... }: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ../../roles/common/default.nix - (import ../../roles/desktop/default.nix { x11Only = false; inherit inputs; inherit pkgs; }) - ../../roles/nfs-mounts/default.nix - ../../roles/nix/default.nix - ../../roles/printing/default.nix - (import ../../roles/users/default.nix { extraGroups = []; }) - ../../roles/virtualisation/default.nix ]; + roles = { + desktop.enable = true; + nfs-mounts.enable = true; + printing.enable = true; + users = { + enable = true; + extraGroups = [ "video" ]; + }; + virtualisation.enable = true; + }; + # Bootloader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; diff --git a/roles/common/default.nix b/roles/common/default.nix deleted file mode 100644 index d29a1bd..0000000 --- a/roles/common/default.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ pkgs, ... }: -{ - i18n.defaultLocale = "en_US.UTF-8"; - i18n.extraLocaleSettings = { - LC_ADDRESS = "en_US.UTF-8"; - LC_IDENTIFICATION = "en_US.UTF-8"; - LC_MEASUREMENT = "en_US.UTF-8"; - LC_MONETARY = "en_US.UTF-8"; - LC_NAME = "en_US.UTF-8"; - LC_NUMERIC = "en_US.UTF-8"; - LC_PAPER = "en_US.UTF-8"; - LC_TELEPHONE = "en_US.UTF-8"; - LC_TIME = "en_US.UTF-8"; - }; - time.timeZone = "America/Los_Angeles"; - - # Enable the OpenSSH daemon. - services.openssh.enable = true; - - services.pipewire = { - enable = true; - pulse.enable = true; - }; - - environment.systemPackages = with pkgs; [ - vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - git - ]; -} diff --git a/roles/default.nix b/roles/default.nix new file mode 100644 index 0000000..a57978a --- /dev/null +++ b/roles/default.nix @@ -0,0 +1,77 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.roles; +in +{ + imports = [ + ./desktop + ./kodi + ./nfs-mounts + ./printing + ./users + ./virtualisation + ]; + + options.roles = { + enable = mkEnableOption "Enable roles"; + }; + + config = { + i18n.defaultLocale = "en_US.UTF-8"; + i18n.extraLocaleSettings = { + LC_ADDRESS = "en_US.UTF-8"; + LC_IDENTIFICATION = "en_US.UTF-8"; + LC_MEASUREMENT = "en_US.UTF-8"; + LC_MONETARY = "en_US.UTF-8"; + LC_NAME = "en_US.UTF-8"; + LC_NUMERIC = "en_US.UTF-8"; + LC_PAPER = "en_US.UTF-8"; + LC_TELEPHONE = "en_US.UTF-8"; + LC_TIME = "en_US.UTF-8"; + }; + time.timeZone = "America/Los_Angeles"; + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + + services.pipewire = { + enable = true; + pulse.enable = true; + }; + + environment.systemPackages = with pkgs; [ + vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + git + ]; + + nix = { + package = pkgs.nixFlakes; + distributedBuilds = true; + buildMachines = [{ + hostName = "z790prors.oglehome"; + system = "x86_64-linux"; + protocol = "ssh-ng"; + sshUser = "johno"; + sshKey = "/root/.ssh/id_ed25519"; + maxJobs = 3; + speedFactor = 2; + }]; + settings = { + experimental-features = [ "nix-command" "flakes" ]; + max-jobs = "auto"; + trusted-users = [ "johno" ]; + substituters = [ + "https://hyprland.cachix.org" + ]; + trusted-public-keys = [ + "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" + ]; + }; + }; + + nixpkgs.config.allowUnfree = true; + }; +} diff --git a/roles/desktop/default.nix b/roles/desktop/default.nix index c25f500..7bd3395 100644 --- a/roles/desktop/default.nix +++ b/roles/desktop/default.nix @@ -1,50 +1,76 @@ -{ inputs, x11Only ? false, pkgs, ... }: +{ lib, config, pkgs, ... }: +with lib; + +let + cfg = config.roles.desktop; +in { - services.xserver.xkb = { - layout = "us"; - variant = ""; - options = "caps:escape"; - }; - services.xserver.enable = true; - services.xserver.displayManager = { - lightdm.enable = true; - }; - services.desktopManager.plasma6.enable = true; - programs.hyprland = { - enable = !x11Only; - package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland; - }; - services.xserver.windowManager.i3 = { - enable = true; - extraPackages = with pkgs; [ - dmenu - i3status - i3lock - ]; - }; - # Helps with i3. Not sure what dconf is though honestly - programs.dconf.enable = true; - - programs.kdeconnect.enable = true; - programs.java.enable = true; - programs.steam = { - enable = true; - remotePlay.openFirewall = true; - localNetworkGameTransfers.openFirewall = true; - #package = pkgs.steam.override { - #withJava = true; - #withPrimus = true; - #extraPkgs = pkgs: [ bumblebee glxinfo ]; - #}; - }; - services.sunshine = { - enable = true; - autoStart = true; - capSysAdmin = true; - openFirewall = true; + options.roles.desktop = { + enable = mkEnableOption "Enable the desktop role"; + x11Only = mkOption { + type = types.bool; + default = false; + }; }; - virtualisation.docker.enable = true; - users.extraGroups.docker.members = [ "johno" ]; + config = + { + services.xserver.xkb = { + layout = "us"; + variant = ""; + options = "caps:escape"; + }; + services.xserver.enable = true; + services.xserver.displayManager = { + lightdm.enable = true; + }; + services.desktopManager.plasma6.enable = true; + + services.xserver.windowManager.i3 = { + enable = true; + extraPackages = with pkgs; [ + dmenu + i3status + i3lock + ]; + }; + programs.dconf.enable = true; + services.gnome.gnome-keyring.enable = true; + + environment.systemPackages = with pkgs; mkIf (!cfg.x11Only) [ + grim + slurp + wl-clipboard + mako + ]; + programs.sway = mkIf (!cfg.x11Only) { + enable = true; + wrapperFeatures.gtk = true; + }; + programs.light.enable = mkIf (!cfg.x11Only) true; + + programs.kdeconnect.enable = true; + programs.java.enable = true; + programs.steam = { + enable = true; + remotePlay.openFirewall = true; + localNetworkGameTransfers.openFirewall = true; + #package = pkgs.steam.override { + #withJava = true; + #withPrimus = true; + #extraPkgs = pkgs: [ bumblebee glxinfo ]; + #}; + }; + services.sunshine = { + enable = true; + autoStart = true; + capSysAdmin = true; + openFirewall = true; + }; + + virtualisation.docker.enable = true; + users.extraGroups.docker.members = [ "johno" ]; + }; + } diff --git a/roles/kids/default.nix b/roles/kids/default.nix deleted file mode 100644 index e6da1d5..0000000 --- a/roles/kids/default.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ pkgs, ... }: - -let - kidsPackages = with pkgs; [ - firefox - ]; -in -{ - users.users.eli = { - isNormalUser = true; - description = "Eli"; - home = "/home/eli"; - packages = kidsPackages; - }; - - users.users.andrew = { - isNormalUser = true; - description = "Andrew"; - home = "/home/andrew"; - packages = kidsPackages; - }; - - users.users.jules = { - isNormalUser = true; - description = "Jules"; - home = "/home/jules"; - packages = kidsPackages; - }; -} diff --git a/roles/kodi/default.nix b/roles/kodi/default.nix index 6d3fce8..97b7a53 100644 --- a/roles/kodi/default.nix +++ b/roles/kodi/default.nix @@ -1,47 +1,62 @@ -{ autologin ? false, wayland ? false, lib, pkgs, ... }: +{ config, lib, pkgs, ... }: with lib; let - kodiBasePkg = if wayland then pkgs.kodi-wayland else pkgs.kodi; - kodiPkg = kodiBasePkg.withPackages (pkgs: with pkgs; [ - jellyfin - steam-launcher - steam-library - youtube - ]); + cfg = config.roles.kodi; in { - users.extraUsers.kodi.isNormalUser = true; - - networking.firewall = { - allowedTCPPorts = [ 8080 ]; - allowedUDPPorts = [ 8080 ]; + options.roles.kodi = { + enable = mkEnableOption "Enable Kodi"; + autologin = mkOption { + default = false; + }; + wayland = mkOption { + default = true; + }; }; - services = mkIf autologin { - cage = mkIf wayland { - user = "kodi"; - program = "${kodiPkg}/bin/kodi-standalone"; - enable = true; + + config = let + kodiBasePkg = if cfg.wayland then pkgs.kodi-wayland else pkgs.kodi; + kodiPkg = kodiBasePkg.withPackages (pkgs: with pkgs; [ + jellyfin + steam-launcher + steam-library + youtube + ]); + in { + users.extraUsers.kodi.isNormalUser = true; + + networking.firewall = { + allowedTCPPorts = [ 8080 ]; + allowedUDPPorts = [ 8080 ]; }; - xserver = mkIf (!wayland) { - enable = true; - desktopManager.kodi = { + services = mkIf cfg.autologin { + cage = mkIf cfg.wayland { + user = "kodi"; + program = "${kodiPkg}/bin/kodi-standalone"; enable = true; - package = kodiPkg; }; - displayManager.lightdm = { + + xserver = mkIf (!cfg.wayland) { enable = true; - greeter.enable = false; + desktopManager.kodi = { + enable = true; + package = kodiPkg; + }; + displayManager.lightdm = { + enable = true; + greeter.enable = false; + }; + }; + displayManager = mkIf (!cfg.wayland) { + autoLogin.enable = true; + autoLogin.user = "kodi"; + defaultSession = "kodi"; + sessionData.autologinSession = "kodi"; }; - }; - displayManager = mkIf (!wayland) { - autoLogin.enable = true; - autoLogin.user = "kodi"; - defaultSession = "kodi"; - sessionData.autologinSession = "kodi"; }; }; } diff --git a/roles/nfs-mounts/default.nix b/roles/nfs-mounts/default.nix index 91a7338..8f25272 100644 --- a/roles/nfs-mounts/default.nix +++ b/roles/nfs-mounts/default.nix @@ -1,14 +1,30 @@ -# TODO: implement requireMount -{ requireMount ? false, ... }: +{ config, lib, ... }: +with lib; + +let + cfg = config.roles.nfs-mounts; +in { - fileSystems."/media" = { - device = "10.0.0.43:/media"; - fsType = "nfs"; - options = [ - "defaults" - "nofail" - "softreval" - ]; + options.roles.nfs-mounts = { + enable = mkEnableOption "Enable default NFS mounts"; + # TODO: implement requireMount + requireMount = mkOption { + type = types.bool; + description = "Hard fail if the NFS mounts are not available"; + default = false; + }; + }; + + config = { + fileSystems."/media" = { + device = "10.0.0.43:/media"; + fsType = "nfs"; + options = [ + "defaults" + "nofail" + "softreval" + ]; + }; }; } diff --git a/roles/nix/default.nix b/roles/nix/default.nix deleted file mode 100644 index 439a993..0000000 --- a/roles/nix/default.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ config, pkgs, ... }: - -{ - nix = { - package = pkgs.nixFlakes; - distributedBuilds = true; - buildMachines = [{ - hostName = "z790prors.oglehome"; - system = "x86_64-linux"; - protocol = "ssh-ng"; - sshUser = "johno"; - sshKey = "/root/.ssh/id_ed25519"; - maxJobs = 3; - speedFactor = 2; - }]; - settings = { - experimental-features = [ "nix-command" "flakes" ]; - max-jobs = "auto"; - trusted-users = [ "johno" ]; - substituters = [ - "https://hyprland.cachix.org" - ]; - trusted-public-keys = [ - "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" - ]; - }; - }; - nixpkgs.config.allowUnfree = true; -} diff --git a/roles/printing/default.nix b/roles/printing/default.nix index 362eb82..384711f 100644 --- a/roles/printing/default.nix +++ b/roles/printing/default.nix @@ -1,4 +1,15 @@ -{ ... }: +{ config, lib, ... }: + +with lib; + { - services.printing.enable = true; + options.roles.printing = { + enable = mkEnableOption "Enable default printing setup"; + }; + + config = { + services.printing.enable = true; + + # TODO: Add actual printer setup config here... + }; } diff --git a/roles/users/default.nix b/roles/users/default.nix index 7781367..123eac7 100644 --- a/roles/users/default.nix +++ b/roles/users/default.nix @@ -1,8 +1,52 @@ -{ extraGroups ? [], ... }: +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.roles.users; +in { - users.users.johno = { - isNormalUser = true; - description = "John Ogle"; - extraGroups = [ "wheel" "networkmanager" "audio" ] ++ extraGroups; + options.roles.users = { + enable = mkEnableOption "Enable default users"; + extraGroups = mkOption { + default = []; + }; + kids = mkOption { + type = types.bool; + default = false; + }; + }; + + config = let + kidsPackages = with pkgs; [ + firefox + ]; + in { + users.users.johno = { + isNormalUser = true; + description = "John Ogle"; + extraGroups = [ "wheel" "networkmanager" "audio" ] ++ cfg.extraGroups; + }; + + users.users.eli = mkIf cfg.kids { + isNormalUser = true; + description = "Eli"; + home = "/home/eli"; + packages = kidsPackages; + }; + + users.users.andrew = mkIf cfg.kids { + isNormalUser = true; + description = "Andrew"; + home = "/home/andrew"; + packages = kidsPackages; + }; + + users.users.jules = mkIf cfg.kids { + isNormalUser = true; + description = "Jules"; + home = "/home/jules"; + packages = kidsPackages; + }; }; } diff --git a/roles/virtualisation/default.nix b/roles/virtualisation/default.nix index aa8bb42..90b48f3 100644 --- a/roles/virtualisation/default.nix +++ b/roles/virtualisation/default.nix @@ -1,6 +1,14 @@ -{ config, ... }: +{ config, lib, ... }: + +with lib; { - virtualisation.libvirtd.enable = true; - programs.virt-manager.enable = true; + options.roles.virtualisation = { + enable = mkEnableOption "Enable virtualisation"; + }; + + config = { + virtualisation.libvirtd.enable = true; + programs.virt-manager.enable = true; + }; }