flake: export nixosModules.gaming for guests with their own hardware
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
7be860ad0c
commit
42b1f16938
2 changed files with 73 additions and 7 deletions
39
flake.nix
39
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 ];
|
||||
|
|
|
|||
41
readme.md
41
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 |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue