feat: merge greeter into sway, yubikey into gnupg, automount into vm-guest
This commit is contained in:
@@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
nixos =
|
|
||||||
{ lib, inputs, ... }:
|
|
||||||
{
|
|
||||||
programs.regreet = {
|
|
||||||
enable = true;
|
|
||||||
# single output to avoid stretching across monitors
|
|
||||||
cageArgs = [
|
|
||||||
"-s"
|
|
||||||
"-m"
|
|
||||||
"last"
|
|
||||||
];
|
|
||||||
font = {
|
|
||||||
name = lib.mkForce "JetBrainsMono Nerd Font";
|
|
||||||
size = lib.mkForce 14;
|
|
||||||
};
|
|
||||||
settings = {
|
|
||||||
background = {
|
|
||||||
path = lib.mkForce "${inputs.assets}/wallpaper.png";
|
|
||||||
fit = lib.mkForce "Cover";
|
|
||||||
};
|
|
||||||
GTK = {
|
|
||||||
application_prefer_dark_theme = lib.mkForce true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,33 @@
|
|||||||
{
|
{
|
||||||
nixos =
|
nixos =
|
||||||
{ pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.features.sway;
|
||||||
|
desktopCfg = config.features.desktop;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
|
options.features.sway = {
|
||||||
|
enable = lib.mkEnableOption "sway window manager";
|
||||||
|
|
||||||
|
greeter.enable = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||||
|
{
|
||||||
|
# soft dependency
|
||||||
|
features.desktop.enable = lib.mkDefault true;
|
||||||
|
|
||||||
|
# hard dependency
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = desktopCfg.enable;
|
||||||
|
message = "features.sway requires features.desktop";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
programs.sway = {
|
programs.sway = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.swayfx;
|
package = pkgs.swayfx;
|
||||||
@@ -34,5 +60,32 @@
|
|||||||
cliphist
|
cliphist
|
||||||
zenity
|
zenity
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
# greeter
|
||||||
|
(lib.mkIf cfg.greeter.enable {
|
||||||
|
programs.regreet = {
|
||||||
|
enable = true;
|
||||||
|
cageArgs = [
|
||||||
|
"-s"
|
||||||
|
"-m"
|
||||||
|
"last"
|
||||||
|
];
|
||||||
|
font = {
|
||||||
|
name = lib.mkForce "JetBrainsMono Nerd Font";
|
||||||
|
size = lib.mkForce 14;
|
||||||
|
};
|
||||||
|
settings = {
|
||||||
|
background = {
|
||||||
|
path = lib.mkForce (toString desktopCfg.theme.wallpaper);
|
||||||
|
fit = lib.mkForce "Cover";
|
||||||
|
};
|
||||||
|
GTK = {
|
||||||
|
application_prefer_dark_theme = lib.mkForce true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
]);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
{
|
|
||||||
nixos =
|
|
||||||
{
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
inherit (config.vm-9p-automount) user;
|
|
||||||
inherit (config.users.users.${user}) home group;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
vm-9p-automount = {
|
|
||||||
user = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
};
|
|
||||||
|
|
||||||
prefix = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "m_";
|
|
||||||
};
|
|
||||||
|
|
||||||
basePath = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "${home}/mnt";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
|
||||||
systemd.services.vm-9p-automount = {
|
|
||||||
description = "Auto-discover and mount 9p shares";
|
|
||||||
after = [
|
|
||||||
"local-fs.target"
|
|
||||||
"nss-user-lookup.target"
|
|
||||||
"systemd-modules-load.service"
|
|
||||||
];
|
|
||||||
wants = [ "systemd-modules-load.service" ];
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
RemainAfterExit = true;
|
|
||||||
ExecStart = pkgs.writeShellScript "vm-9p-automount" ''
|
|
||||||
BASE="${config.vm-9p-automount.basePath}"
|
|
||||||
PREFIX="${config.vm-9p-automount.prefix}"
|
|
||||||
mkdir -p "$BASE"
|
|
||||||
chown ${user}:${group} "$BASE"
|
|
||||||
|
|
||||||
for tagfile in $(find /sys/devices -name mount_tag 2>/dev/null); do
|
|
||||||
[ -f "$tagfile" ] || continue
|
|
||||||
tag=$(tr -d '\0' < "$tagfile")
|
|
||||||
|
|
||||||
case "$tag" in
|
|
||||||
"$PREFIX"*) ;;
|
|
||||||
*) continue ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
name="''${tag#"$PREFIX"}"
|
|
||||||
target="$BASE/$name"
|
|
||||||
|
|
||||||
mkdir -p "$target"
|
|
||||||
${pkgs.util-linux}/bin/mount -t 9p "$tag" "$target" \
|
|
||||||
-o trans=virtio,version=9p2000.L || continue
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -6,19 +6,46 @@
|
|||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.features.vm-guest;
|
||||||
|
autoUser = cfg.automount.user;
|
||||||
|
autoHome = config.users.users.${autoUser}.home;
|
||||||
|
autoGroup = config.users.users.${autoUser}.group;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options.features.vm-guest = {
|
||||||
vm-guest.headless = lib.mkOption {
|
enable = lib.mkEnableOption "qemu vm guest";
|
||||||
|
|
||||||
|
headless = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
automount = {
|
||||||
|
enable = lib.mkEnableOption "9p share automount";
|
||||||
|
|
||||||
|
user = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
prefix = lib.mkOption {
|
||||||
services.qemuGuest.enable = true;
|
type = lib.types.str;
|
||||||
services.spice-vdagentd.enable = lib.mkIf (!config.vm-guest.headless) true;
|
default = "m_";
|
||||||
|
};
|
||||||
|
|
||||||
boot.kernelParams = lib.mkIf config.vm-guest.headless [ "console=ttyS0,115200" ];
|
basePath = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "${autoHome}/mnt";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||||
|
{
|
||||||
|
services.qemuGuest.enable = true;
|
||||||
|
services.spice-vdagentd.enable = lib.mkIf (!cfg.headless) true;
|
||||||
|
|
||||||
|
boot.kernelParams = lib.mkIf cfg.headless [ "console=ttyS0,115200" ];
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [
|
boot.initrd.availableKernelModules = [
|
||||||
"9p"
|
"9p"
|
||||||
@@ -42,6 +69,47 @@
|
|||||||
htop
|
htop
|
||||||
sshfs
|
sshfs
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
(lib.mkIf cfg.automount.enable {
|
||||||
|
systemd.services.vm-9p-automount = {
|
||||||
|
description = "Auto-discover and mount 9p shares";
|
||||||
|
after = [
|
||||||
|
"local-fs.target"
|
||||||
|
"nss-user-lookup.target"
|
||||||
|
"systemd-modules-load.service"
|
||||||
|
];
|
||||||
|
wants = [ "systemd-modules-load.service" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
ExecStart = pkgs.writeShellScript "vm-9p-automount" ''
|
||||||
|
BASE="${cfg.automount.basePath}"
|
||||||
|
PREFIX="${cfg.automount.prefix}"
|
||||||
|
mkdir -p "$BASE"
|
||||||
|
chown ${autoUser}:${autoGroup} "$BASE"
|
||||||
|
|
||||||
|
for tagfile in $(find /sys/devices -name mount_tag 2>/dev/null); do
|
||||||
|
[ -f "$tagfile" ] || continue
|
||||||
|
tag=$(tr -d '\0' < "$tagfile")
|
||||||
|
|
||||||
|
case "$tag" in
|
||||||
|
"$PREFIX"*) ;;
|
||||||
|
*) continue ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
name="''${tag#"$PREFIX"}"
|
||||||
|
target="$BASE/$name"
|
||||||
|
|
||||||
|
mkdir -p "$target"
|
||||||
|
${pkgs.util-linux}/bin/mount -t 9p "$tag" "$target" \
|
||||||
|
-o trans=virtio,version=9p2000.L || continue
|
||||||
|
done
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
nixos =
|
|
||||||
{ pkgs, ... }:
|
|
||||||
{
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
yubikey-personalization
|
|
||||||
yubikey-manager
|
|
||||||
];
|
|
||||||
|
|
||||||
services.pcscd.enable = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user