mirror of
https://github.com/nickolaj-jepsen/nixos.git
synced 2026-01-22 08:06:50 +01:00
feat: more wsl tweaks
This commit is contained in:
parent
50289dcc0d
commit
72a3dc6c5a
10 changed files with 104 additions and 40 deletions
40
README.md
40
README.md
|
|
@ -57,16 +57,13 @@ just bootstrap-flash /dev/sdX
|
||||||
```
|
```
|
||||||
|
|
||||||
This creates:
|
This creates:
|
||||||
- `hosts/<hostname>/` directory
|
- `hosts/<hostname>/default.nix` file which you should edit
|
||||||
- `secrets/hosts/<hostname>/` with SSH keys
|
- `secrets/hosts/<hostname>/` directory with SSH keys
|
||||||
|
|
||||||
2. Add host configuration in `hosts/default.nix`:
|
2. Add host configuration in `hosts/default.nix`:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
<hostname> = mkSystem {
|
<hostname> = mkSystem { host = .<hostname>; };
|
||||||
hostname = "<hostname>";
|
|
||||||
username = "<username>";
|
|
||||||
};
|
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Create required files in `hosts/<hostname>/`:
|
3. Create required files in `hosts/<hostname>/`:
|
||||||
|
|
@ -87,6 +84,37 @@ just bootstrap-flash /dev/sdX
|
||||||
just secret-rekey
|
just secret-rekey
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> If you upload the public key (`secrets/hosts/<hostname>/id_ed25519.pub`) to GitHub, you can pull & push directly from the new host.
|
||||||
|
|
||||||
|
## Deploying
|
||||||
|
|
||||||
|
### Nixos ISO install
|
||||||
|
|
||||||
|
A simple way to install a new machine is to use the official [NixOS ISO](https://nixos.org/download/) to prepare a machine
|
||||||
|
|
||||||
|
Copy the private SSH key for the new host to `/etc/ssh/ssh_host_ed25519_key`
|
||||||
|
|
||||||
|
Enable flakes support in `/etc/nixos/configuration.nix`
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
nix = {
|
||||||
|
package = pkgs.nixFlakes;
|
||||||
|
extraOptions = ''
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ nix develop
|
||||||
|
$ just switch <hostname>
|
||||||
|
```
|
||||||
|
|
||||||
## Secret Management
|
## Secret Management
|
||||||
|
|
||||||
Secrets are managed with [agenix](https://github.com/ryantm/agenix) + [agenix-rekey](https://github.com/oddlama/agenix-rekey), using a YubiKey as the master identity.
|
Secrets are managed with [agenix](https://github.com/ryantm/agenix) + [agenix-rekey](https://github.com/oddlama/agenix-rekey), using a YubiKey as the master identity.
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,14 @@
|
||||||
{
|
{
|
||||||
config = rec {
|
config = {
|
||||||
fireproof = {
|
fireproof = {
|
||||||
hostname = "desktop-wsl";
|
hostname = "desktop-wsl";
|
||||||
username = "nickolaj";
|
username = "nickolaj";
|
||||||
work.enable = true;
|
work.enable = true;
|
||||||
dev.enable = true;
|
dev.enable = true;
|
||||||
|
wsl.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
wsl.enable = true;
|
|
||||||
wsl.defaultUser = fireproof.username;
|
|
||||||
|
|
||||||
services.keyd.enable = false;
|
|
||||||
|
|
||||||
system.stateVersion = "25.11";
|
system.stateVersion = "25.11";
|
||||||
|
|
||||||
# WSL doesn't use a bootloader - disable systemd-boot
|
|
||||||
boot.loader.systemd-boot.enable = false;
|
|
||||||
boot.loader.efi.canTouchEfiVariables = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,11 @@
|
||||||
}: {
|
}: {
|
||||||
options.fireproof.desktop = {
|
options.fireproof.desktop = {
|
||||||
enable = lib.mkEnableOption "Enable desktop environment with niri, greetd, and all desktop features";
|
enable = lib.mkEnableOption "Enable desktop environment with niri, greetd, and all desktop features";
|
||||||
|
windowManager.enable = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = config.fireproof.desktop.enable;
|
||||||
|
description = "Enable window manager (niri) and dank material shell (dms)";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
|
|
@ -18,9 +23,4 @@
|
||||||
./gtk/default.nix
|
./gtk/default.nix
|
||||||
./dms/default.nix
|
./dms/default.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
config = lib.mkIf config.fireproof.desktop.enable {
|
|
||||||
# All desktop-related configuration is handled by the individual modules
|
|
||||||
# which check for fireproof.desktop.enable
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
hasMonitors = config.monitors != [];
|
||||||
|
|
||||||
commonBarSettings = {
|
commonBarSettings = {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
position = 0;
|
position = 0;
|
||||||
|
|
@ -35,11 +37,17 @@
|
||||||
maximizeDetection = true;
|
maximizeDetection = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
primaryMonitor = builtins.head config.monitors;
|
primaryMonitor =
|
||||||
|
if hasMonitors
|
||||||
|
then builtins.head config.monitors
|
||||||
|
else {};
|
||||||
primaryX = primaryMonitor.position.x or 0;
|
primaryX = primaryMonitor.position.x or 0;
|
||||||
|
|
||||||
# Partition secondary monitors into left and right based on their x position relative to primary
|
# Partition secondary monitors into left and right based on their x position relative to primary
|
||||||
secondaryMonitors = builtins.tail config.monitors;
|
secondaryMonitors =
|
||||||
|
if hasMonitors
|
||||||
|
then builtins.tail config.monitors
|
||||||
|
else [];
|
||||||
leftMonitors = builtins.filter (m: (m.position.x or 0) <= primaryX) secondaryMonitors;
|
leftMonitors = builtins.filter (m: (m.position.x or 0) <= primaryX) secondaryMonitors;
|
||||||
rightMonitors = builtins.filter (m: (m.position.x or 0) > primaryX) secondaryMonitors;
|
rightMonitors = builtins.filter (m: (m.position.x or 0) > primaryX) secondaryMonitors;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
./bar.nix
|
./bar.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
config = lib.mkIf config.fireproof.desktop.enable {
|
config = lib.mkIf config.fireproof.desktop.windowManager.enable {
|
||||||
systemd.user.services.niri-flake-polkit.enable = false;
|
systemd.user.services.niri-flake-polkit.enable = false;
|
||||||
|
|
||||||
fireproof.home-manager = {
|
fireproof.home-manager = {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,13 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
config = lib.mkIf config.fireproof.desktop.enable {
|
options.fireproof.desktop.greeter.enable =
|
||||||
|
lib.mkEnableOption "greeter"
|
||||||
|
// {
|
||||||
|
default = config.fireproof.desktop.enable;
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf config.fireproof.desktop.greeter.enable {
|
||||||
services.greetd = {
|
services.greetd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,13 @@
|
||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
primaryMonitorName = (builtins.head config.monitors).name or "";
|
hasMonitors = config.monitors != [];
|
||||||
|
primaryMonitorName =
|
||||||
|
if hasMonitors
|
||||||
|
then (builtins.head config.monitors).name or ""
|
||||||
|
else "";
|
||||||
in {
|
in {
|
||||||
config = lib.mkIf config.fireproof.desktop.enable {
|
config = lib.mkIf config.fireproof.desktop.windowManager.enable {
|
||||||
# TODO: Move these to a separate module
|
|
||||||
programs.xwayland.enable = true;
|
programs.xwayland.enable = true;
|
||||||
|
|
||||||
xdg.portal = {
|
xdg.portal = {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ _: {
|
||||||
./boot.nix
|
./boot.nix
|
||||||
./hosts.nix
|
./hosts.nix
|
||||||
./keyd.nix
|
./keyd.nix
|
||||||
|
./wsl.nix
|
||||||
./ld.nix
|
./ld.nix
|
||||||
./networking.nix
|
./networking.nix
|
||||||
./security.nix
|
./security.nix
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
{lib, ...}: {
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
config = lib.mkIf config.fireproof.desktop.enable {
|
||||||
services.keyd = {
|
services.keyd = {
|
||||||
enable = lib.mkDefault true;
|
enable = lib.mkDefault true;
|
||||||
keyboards.mouse = {
|
keyboards.mouse = {
|
||||||
|
|
@ -14,4 +19,5 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
modules/system/wsl.nix
Normal file
20
modules/system/wsl.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
options.fireproof.wsl.enable = lib.mkEnableOption "Enable WSL configuration";
|
||||||
|
|
||||||
|
config = lib.mkIf config.fireproof.wsl.enable {
|
||||||
|
wsl = {
|
||||||
|
enable = true;
|
||||||
|
defaultUser = config.fireproof.username;
|
||||||
|
startMenuLaunchers = true;
|
||||||
|
interop.includePath = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
# WSL doesn't use a bootloader - disable systemd-boot
|
||||||
|
boot.loader.systemd-boot.enable = false;
|
||||||
|
boot.loader.efi.canTouchEfiVariables = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue