diff --git a/flake.nix b/flake.nix index ae41478..6034e01 100644 --- a/flake.nix +++ b/flake.nix @@ -39,19 +39,44 @@ } @ inputs: let system = "x86_64-linux"; + baseModules = hostname: [ + ./hosts/${hostname}.nix + ./common.nix + home-manager.nixosModules.home-manager + stylix.nixosModules.stylix + ./settings/stylix.nix + ]; mkHost = hostname: extraModules: nixpkgs.lib.nixosSystem { inherit system; specialArgs = { inherit inputs; }; - modules = [ - ./hosts/${hostname}.nix - ./common.nix - home-manager.nixosModules.home-manager - stylix.nixosModules.stylix - ./settings/stylix.nix - ] ++ extraModules; + modules = baseModules hostname ++ extraModules; }; in { + # Everything FredOS-Gaming is, minus the hardware — for anyone who wants + # to run this config on their own machine. They import this module next + # to their own hardware-configuration.nix from their own flake (readme.md + # has the snippet). `_module.args` stands in for mkHost's specialArgs, + # which a plain module can't set. + nixosModules.gaming = { lib, ... }: { + imports = baseModules "FredOS-Gaming"; + _module.args.inputs = inputs; + + # Hostname gates every FredOS-Gaming module, so it has to keep matching. + # These four otherwise live in hosts/hardware/FredOS-Gaming.nix, which + # is exactly the file a guest replaces. + networking.hostName = "FredOS-Gaming"; + nixpkgs.hostPlatform = lib.mkDefault system; + system.stateVersion = lib.mkDefault "25.11"; + boot.loader.systemd-boot.enable = lib.mkDefault true; + boot.loader.efi.canTouchEfiVariables = lib.mkDefault true; + + # nordhammer.it is my build server and those are my SSH keys; neither + # belongs on someone else's machine. + nix.distributedBuilds = lib.mkForce false; + users.users.fred.openssh.authorizedKeys.keys = lib.mkForce [ ]; + }; + nixosConfigurations = { FredOS-Gaming = mkHost "FredOS-Gaming" [ ./hosts/hardware/FredOS-Gaming.nix ]; FredOS-Mediaserver = mkHost "FredOS-Mediaserver" [ ./hosts/hardware/FredOS-Mediaserver.nix ]; diff --git a/readme.md b/readme.md index d692548..ac1e095 100644 --- a/readme.md +++ b/readme.md @@ -139,6 +139,47 @@ After this succeeds, the plain `update` alias works from then on. --- +## Running the desktop on someone else's machine + +`nixosModules.gaming` is the whole FredOS-Gaming desktop — Hyprland, quickshell, +stylix theming, Steam, the lot — with `hosts/hardware/FredOS-Gaming.nix` left +out. Import it from your own flake alongside your own +`/etc/nixos/hardware-configuration.nix`, which stays on your machine and never +touches this repo, so `nix flake update` keeps pulling my changes without ever +overwriting your disks and GPU: + +```nix +{ + inputs.fredos.url = "git+https://forg.gregersen.it/rope/nixos"; + + outputs = { self, fredos, ... }: { + nixosConfigurations.mine = fredos.inputs.nixpkgs.lib.nixosSystem { + modules = [ + fredos.nixosModules.gaming + ./hardware-configuration.nix + ]; + }; + }; +} +``` + +Then `sudo nixos-rebuild switch --flake .#mine`. + +Notes: + +- The hostname stays `FredOS-Gaming` — every module in here is gated on it, so + changing it switches the desktop off. +- The module drops my build server and my SSH keys, and defaults + `system.stateVersion`, `nixpkgs.hostPlatform` and systemd-boot so a stock + `hardware-configuration.nix` is enough. All `mkDefault`, so override freely. +- The CachyOS kernel and its binary cache live in the hardware file, so you + won't get them. Copy those lines out of `hosts/hardware/FredOS-Gaming.nix` if + you want them. +- The user is `fred` with passwordless sudo. `passwd fred` after the first + switch. +- My monitor layout (`DP-3`, 3440x1440@180) is in `hosts/FredOS-Gaming.nix`; + override `wayland.windowManager.hyprland.settings.monitor` for yours. + ## Flake inputs | Input | Source |