snowfall lib migration wip

This commit is contained in:
Aleksandr Lebedev 2025-08-07 18:07:27 +02:00
parent b9dadac2af
commit ed08a98651
31 changed files with 1067 additions and 172 deletions

View file

@ -0,0 +1,147 @@
{
lib,
pkgs,
inputs,
namespace,
system,
target,
format,
virtual,
systems,
config,
...
}:
with lib;
with lib.${namespace}; let
cfg = config.${namespace}.programs.fastfetch;
in {
options.${namespace}.programs.fastfetch = with types; {
enable = mkBoolOpt false "Enable fastfetch with custom settings";
firstNixOSInstall = mkOption {
type = nullOr int;
default = null;
description = ''
Unix time of the first install of NixOS to use for age. Can be aquired with "stat -c %W /"
'';
};
};
config = mkIf cfg.enable {
programs.fastfetch = {
enable = true;
settings = {
display = {
color = {
keys = "35";
output = "1000";
};
};
logo = {
source = ./nixos.png;
type = "kitty-direct";
height = 15;
width = 30;
padding = {
top = 3;
left = 3;
};
};
modules = [
"break"
{
type = "custom";
format = "Hardware";
}
{
type = "cpu";
key = " ";
}
{
type = "gpu";
key = " 󰍛 ";
}
{
type = "memory";
key = " 󰑭 ";
}
{
type = "custom";
format = "";
}
"break"
{
type = "custom";
format = "Software";
}
{
type = "custom";
format = " OS -> NixOS btw";
}
{
type = "kernel";
key = " ";
}
{
type = "packages";
key = " 󰏖 ";
}
{
type = "shell";
key = " ";
}
"break"
{
type = "wm";
key = " WM";
}
{
type = "wmtheme";
key = " 󰉼 ";
}
{
type = "terminal";
key = " ";
}
{
type = "custom";
format = "";
}
"break"
{
type = "custom";
format = "Age / Uptime";
}
{
type = "command";
key = " ";
text =
#bash
''
birth_install=${
if cfg.firstNixOSInstall != null
then "${builtins.toString cfg.firstNixOSInstall}"
else "$(stat -c %W /)"
}
current=$(date +%s)
delta=$((current - birth_install))
delta_days=$((delta / 86400))
echo $delta_days days
'';
}
{
type = "uptime";
key = " ";
}
{
type = "custom";
format = "";
}
"break"
];
};
};
};
}

View file

@ -26,5 +26,12 @@ in {
pinentry-program = lib.mkForce "${pkgs.pinentry-curses}/bin/pinentry-curses";
};
};
environment.systemPackages = [
(pkgs.pass.withExtensions (exts:
with exts; [
pass-otp
pass-import
]))
];
};
}

View file

@ -0,0 +1,35 @@
{
lib,
pkgs,
inputs,
namespace,
system,
target,
format,
virtual,
systems,
config,
...
}:
with lib;
with lib.${namespace}; let
cfg = config.${namespace}.hardware.asahi;
in {
options.${namespace}.hardware.asahi = with types; {
enable = mkBoolOpt false "Enable hardware support for Apple Silicon (M Chips)";
imports = [
inputs.apple-silicon-support.nixosModules.default
({pkgs, ...}: {
hardware.asahi = {
peripheralFirmwareDirectory = ./firmware;
useExperimentalGPUDriver = true; #deprecated
#experimentalGPUInstallMode = "overlay";
setupAsahiSound = true;
};
environment.systemPackages = with pkgs; [
mesa-asahi-edge
];
})
];
};
}

Binary file not shown.

View file

@ -19,9 +19,8 @@ in {
enable = mkBoolOpt false "Enable bluetooth support";
};
config =
mkIf cfg.enable {
hardware.bluetooth = {
config = mkIf cfg.enable {
hardware.bluetooth = {
enable = true;
powerOnBoot = true;
settings = {
@ -30,6 +29,6 @@ in {
};
};
};
services.blueman.enable = true;
};
services.blueman.enable = true;
};
}

View file

@ -0,0 +1,49 @@
{
lib,
pkgs,
inputs,
namespace,
system,
target,
format,
virtual,
systems,
config,
...
}:
with lib;
with lib.${namespace}; let
cfg = config.${namespace}.hardware.framework12;
in {
options.${namespace}.hardware.framework12 = with types; {
enable = mkBoolOpt false "Enable hardware support for framework 12. P.s. you still need to import inputs.nixos-hardware.nixosModules.framework-12-13th-gen-intel yourself";
};
config = mkIf cfg.enable {
# Ensure that the `pinctrl_tigerlake` kernel module is loaded before `soc_button_array`.
# This is required for correcly switching to tablet mode when the display is folded back.
boot.extraModprobeConfig = ''
softdep soc_button_array pre: pinctrl_tigerlake
'';
boot.initrd.kernelModules = ["pinctrl_tigerlake"];
# Patch the `udev` rules shipping with `iio-sensor-proxy` according to:
# https://github.com/FrameworkComputer/linux-docs/blob/main/framework12/Ubuntu-25-04-accel-ubuntu25.04.md
nixpkgs.overlays = [
(final: prev: {
iio-sensor-proxy = prev.iio-sensor-proxy.overrideAttrs (old: {
postInstall = ''
${old.postInstall or ""}
sed -i 's/.*iio-buffer-accel/#&/' $out/lib/udev/rules.d/80-iio-sensor-proxy.rules
'';
});
})
];
hardware.enableRedistributableFirmware = true;
environment.systemPackages = [
pkgs.framework-tool
];
users.groups.touchscreen = {};
services.udev.extraRules = ''
KERNEL=="event*", ATTRS{name}=="ILIT2901:00 222A:5539", SYMLINK+="touchscreen", MODE="0660", GROUP="touchscreen"
'';
};
}

View file

@ -0,0 +1,66 @@
{
lib,
pkgs,
inputs,
namespace,
system,
target,
format,
virtual,
systems,
config,
...
}:
with lib;
with lib.${namespace}; let
cfg = config.${namespace}.hardware.nvidia;
in {
options.${namespace}.hardware.nvidia = with types; {
enable = mkBoolOpt false "Enable Nvidia GPU Drivers";
};
config = mkIf cfg.enable {
hardware = {
graphics = {
enable = true;
extraPackages = with pkgs; [
nvidia-vaapi-driver
];
};
nvidia = {
# https://nixos.wiki/wiki/Nvidia
# Modesetting is required.
modesetting.enable = true;
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
# Enable this if you have graphical corruption issues or application crashes after waking
# up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead
# of just the bare essentials.
powerManagement.enable = true; #false;
# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
powerManagement.finegrained = false;
# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
# Currently alpha-quality/buggy, so false is currently the recommended setting.
open = true;
# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;
# Optionally, you may need to select the appropriate driver version for your specific GPU.
package = config.boot.kernelPackages.nvidiaPackages.latest;
};
logitech.wireless.enable = true;
};
services.xserver.videoDrivers = ["nvidia"];
};
}

View file

@ -19,16 +19,15 @@ in {
enable = mkBoolOpt false "Enable printers support";
};
config =
mkIf cfg.enable {
environment.systemPackages = with pkgs; [
system-config-printer
];
services.printing.enable = true;
services.avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
system-config-printer
];
services.printing.enable = true;
services.avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
};
};
}

View file

@ -0,0 +1,38 @@
{
lib,
pkgs,
inputs,
namespace,
system,
target,
format,
virtual,
systems,
config,
...
}:
with lib;
with lib.${namespace}; let
cfg = config.${namespace}.hardware.secureBoot;
in {
options.${namespace}.hardware.secureBoot = with types; {
enable = mkBoolOpt false "Enable support for secure boot. Note: Secure boot should still be configured imperatively. This module only handles the declarative part.";
};
config = mkIf cfg.enable {
boot = {
initrd.systemd.enable = true;
lanzaboote = {
enable = true;
pkiBundle = "/var/lib/sbctl";
};
};
environment.systemPackages = with pkgs; [
# For debugging and troubleshooting Secure Boot.
sbctl
# For tpm auto unlock
tpm2-tss
];
};
}

View file

@ -35,7 +35,7 @@ in {
enable = true;
theme = "catppuccin-mocha";
package = mkDefault pkgs.kdePackages.sddm;
wayland.enable = mkDefault config.${username}.presets.wayland.enable;
wayland.enable = mkDefault config.${namespace}.presets.wayland.enable;
settings = {
General = {
InputMethod = "wvkbd-mobintl"; # Enables optional virtual keyboard at login (SDDM). Useful for touchscreens or accessibility.

View file

@ -14,6 +14,20 @@ in {
};
config = mkIf cfg.enable {
zramSwap = {
enable = true; # Hopefully? helps with freezing when using swap
};
boot = {
kernelPackages = lib.mkDefault pkgs.linuxPackages_latest;
loader = {
systemd-boot.enable = !config.${namespace}.hardware.secureBoot.enable;
efi.canTouchEfiVariables = !config.${namespace}.hardware.asahi.enable;
};
# Hide the OS choice for bootloaders.
# It's still possible to open the bootloader list by pressing any key
# It will just not appear on screen unless a key is pressed
loader.timeout = 0;
};
# Set your time zone.
time.timeZone = "Europe/Berlin";

View file

@ -0,0 +1,121 @@
{
lib,
pkgs,
inputs,
namespace,
system,
target,
format,
virtual,
systems,
config,
...
}:
with lib;
with lib.${namespace}; let
cfg = config.${namespace}.presets.disko.impermanenceBtrfs;
in {
options.${namespace}.presets.disko.impermanenceBtrfs = with types; {
enable = mkBoolOpt false "Enable preset";
device = mkOpt' str "/dev/nvme0n1";
swapSize = mkOpt' int 32;
};
config = mkIf cfg.enable {
disko.devices = {
disk.main = {
inherit (cfg) device;
type = "disk";
content = {
type = "gpt";
partitions = {
boot = {
name = "boot";
size = "1M";
type = "EF02";
};
esp = {
name = "ESP";
size = "500M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
swap = {
size = "${builtins.toString cfg.swapSize}G";
content = {
type = "swap";
resumeDevice = true;
};
};
root = {
name = "root";
size = "100%";
content = {
type = "lvm_pv";
vg = "root_vg";
};
};
};
};
};
lvm_vg = {
root_vg = {
type = "lvm_vg";
lvs = {
root = {
size = "100%FREE";
content = {
type = "btrfs";
extraArgs = ["-f"];
subvolumes = {
"/root" = {
mountpoint = "/";
};
"/persist" = {
mountOptions = ["subvol=persist" "noatime"];
mountpoint = "/persist";
};
"/nix" = {
mountOptions = ["subvol=nix" "noatime"];
mountpoint = "/nix";
};
};
};
};
};
};
};
};
boot.initrd.postDeviceCommands = ''
mkdir -p /btrfs_tmp
mount /dev/root_vg/root /btrfs_tmp
if [[ -e /btrfs_tmp/root ]]; then
mkdir -p /btrfs_tmp/old_roots
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S")
mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp"
fi
delete_subvolume_recursively() {
IFS=$'\n'
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
delete_subvolume_recursively "/btrfs_tmp/$i"
done
btrfs subvolume delete "$1"
}
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
delete_subvolume_recursively "$i"
done
btrfs subvolume create /btrfs_tmp/root
umount /btrfs_tmp
'';
};
}

View file

@ -25,10 +25,14 @@ in {
presets.wayland = enabled;
hardware.printing = enabled;
hardware.bluetooth = enabled;
#programs.fastfetch = {
# enable = true;
# firstNixOSInstall = 1729112485;
#};
gpg = enabled;
services.syncthing = {
enable = true;
user = "kylekrein";
enable = true;
user = "kylekrein";
};
};
@ -71,44 +75,44 @@ in {
element-desktop
];
programs.kdeconnect.enable = true;
programs.kdeconnect.package = lib.mkDefault pkgs.kdePackages.kdeconnect-kde;
programs.kdeconnect.package = lib.mkDefault pkgs.kdePackages.kdeconnect-kde;
fonts.packages = with pkgs; [
nerd-fonts.jetbrains-mono
font-awesome
nerd-fonts.symbols-only
hack-font
# microsoft fonts:
#corefonts
#vistafonts
];
nerd-fonts.jetbrains-mono
font-awesome
nerd-fonts.symbols-only
hack-font
# microsoft fonts:
#corefonts
#vistafonts
];
environment.sessionVariables = {
MANPAGER = "emacsclient -c";
EDITOR = "emacsclient -c";
};
MANPAGER = "emacsclient -c";
EDITOR = "emacsclient -c";
};
hardware = {
logitech.wireless.enable = true;
};
logitech.wireless.enable = true;
};
security.polkit.enable = true;
security.polkit.enable = true;
#programs.thunar = {
# enable = true;
# plugins = with pkgs.xfce; [
# thunar-archive-plugin
# thunar-volman
# ];
# };
#programs.xfconf.enable = true; # so thunar can save config
#services.gvfs.enable = true; # Mount, trash, and other functionalities
#services.tumbler.enable = true; # Thumbnail support for images
#programs.thunar = {
# enable = true;
# plugins = with pkgs.xfce; [
# thunar-archive-plugin
# thunar-volman
# ];
# };
#programs.xfconf.enable = true; # so thunar can save config
#services.gvfs.enable = true; # Mount, trash, and other functionalities
#services.tumbler.enable = true; # Thumbnail support for images
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
};
}

View file

@ -19,53 +19,52 @@ in {
enable = mkBoolOpt false "Enable dolphin on non Kde environments";
};
config =
mkIf cfg.enable {
environment.systemPackages = with pkgs; [
kdePackages.qtwayland
kdePackages.qtsvg
kdePackages.kio-fuse #to mount remote filesystems via FUSE
kdePackages.kio-extras #extra protocols support (sftp, fish and more)
kdePackages.kio-admin
libheif #https://github.com/NixOS/nixpkgs/issues/164021
libheif.out
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
kdePackages.qtwayland
kdePackages.qtsvg
kdePackages.kio-fuse #to mount remote filesystems via FUSE
kdePackages.kio-extras #extra protocols support (sftp, fish and more)
kdePackages.kio-admin
libheif #https://github.com/NixOS/nixpkgs/issues/164021
libheif.out
#kde
kdePackages.breeze-icons
kdePackages.breeze
kdePackages.kdesdk-thumbnailers
kdePackages.kdegraphics-thumbnailers
kdePackages.kservice
kdePackages.kdbusaddons
kdePackages.kfilemetadata
kdePackages.kconfig
kdePackages.kcoreaddons
kdePackages.kcrash
kdePackages.kguiaddons
kdePackages.ki18n
kdePackages.kitemviews
kdePackages.kwidgetsaddons
kdePackages.kwindowsystem
shared-mime-info
#kde
kdePackages.breeze-icons
kdePackages.breeze
kdePackages.kdesdk-thumbnailers
kdePackages.kdegraphics-thumbnailers
kdePackages.kservice
kdePackages.kdbusaddons
kdePackages.kfilemetadata
kdePackages.kconfig
kdePackages.kcoreaddons
kdePackages.kcrash
kdePackages.kguiaddons
kdePackages.ki18n
kdePackages.kitemviews
kdePackages.kwidgetsaddons
kdePackages.kwindowsystem
shared-mime-info
#kde support tools
#libsForQt5.qt5ct
#qt6ct
kdePackages.kimageformats
kdePackages.dolphin
kdePackages.dolphin-plugins
];
xdg = {
menus.enable = true;
mime.enable = true;
};
#https://discourse.nixos.org/t/dolphin-does-not-have-mime-associations/48985/3
# This fixes the unpopulated MIME menus
environment.etc."/xdg/menus/plasma-applications.menu".text = builtins.readFile "${pkgs.kdePackages.plasma-workspace}/etc/xdg/menus/plasma-applications.menu";
environment.etc."/xdg/menus/applications.menu".text = builtins.readFile "${pkgs.kdePackages.plasma-workspace}/etc/xdg/menus/plasma-applications.menu";
#environment.pathsToLink = [
# "share/thumbnailers"
#];
#kde support tools
#libsForQt5.qt5ct
#qt6ct
kdePackages.kimageformats
kdePackages.dolphin
kdePackages.dolphin-plugins
];
xdg = {
menus.enable = true;
mime.enable = true;
};
#https://discourse.nixos.org/t/dolphin-does-not-have-mime-associations/48985/3
# This fixes the unpopulated MIME menus
environment.etc."/xdg/menus/plasma-applications.menu".text = builtins.readFile "${pkgs.kdePackages.plasma-workspace}/etc/xdg/menus/plasma-applications.menu";
environment.etc."/xdg/menus/applications.menu".text = builtins.readFile "${pkgs.kdePackages.plasma-workspace}/etc/xdg/menus/plasma-applications.menu";
#environment.pathsToLink = [
# "share/thumbnailers"
#];
};
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

View file

@ -0,0 +1,72 @@
{
lib,
pkgs,
inputs,
namespace,
system,
target,
format,
virtual,
systems,
config,
...
}:
with lib;
with lib.${namespace}; let
cfg = config.${namespace}.services.ai;
impermanence = config.${namespace}.impermanence;
nvidia = config.${namespace}.hardware.nvidia;
persist = impermanence.persistentStorage;
in {
options.${namespace}.services.ai = with types; {
enable = mkBoolOpt false "Enable local ai powered by ollama";
models = lib.mkOption {
type = types.listOf types.str;
default = [];
description = ''
Download these models using `ollama pull` as soon as `ollama.service` has started.
This creates a systemd unit `ollama-model-loader.service`.
Search for models of your choice from: <https://ollama.com/library>
'';
};
ui.enable = mkBoolOpt true "Enable openwebui at localhost:8080";
ui.port = mkOption {
type = types.port;
default = 8080;
description = ''
Port for ui
'';
};
};
config = mkIf cfg.enable {
services.ollama = {
enable = true;
loadModels = cfg.models;
acceleration =
if nvidia.enable
then "cuda"
else null;
home =
if impermanence.enable
then "${persist}/ollama"
else "/var/lib/ollama";
user = "ollama";
group = "ollama";
};
services.open-webui.enable = cfg.ui.enable;
services.open-webui.openFirewall = false;
services.open-webui.host = "0.0.0.0";
services.open-webui.port = cfg.ui.port;
services.open-webui.stateDir =
if impermanence.enable
then "${persist}/open-webui"
else "/var/lib/open-webui";
systemd.services.open-webui.serviceConfig.User = "ollama";
systemd.services.open-webui.serviceConfig.Group = "ollama";
systemd.services.open-webui.serviceConfig.DynamicUser = lib.mkForce false;
};
}

View file

@ -19,22 +19,24 @@ in {
options.${namespace}.services.syncthing = with types; {
enable = mkBoolOpt false "Enable syncthing service for the user";
user = lib.mkOption {
type = lib.types.singleLineStr;
default = "";
example = "nixos";
description = ''
User, that will use the syncthing service (only one at a time)
'';
};
type = lib.types.singleLineStr;
default = "";
example = "nixos";
description = ''
User, that will use the syncthing service (only one at a time)
'';
};
};
config =
mkIf cfg.enable {
systemd.services.syncthing.environment.STNODEFAULTFOLDER = "true"; # Don't create default ~/Sync folder
services.syncthing = {
inherit (cfg) user;
configDir = optional (impermanence.enable) "${impermanence.persistentStorage}/home/${cfg.user}/.config/syncthing";
enable = true;
};
config = mkIf cfg.enable {
systemd.services.syncthing.environment.STNODEFAULTFOLDER = "true"; # Don't create default ~/Sync folder
services.syncthing = {
inherit (cfg) user;
configDir =
if impermanence.enable
then "${impermanence.persistentStorage}/home/${cfg.user}/.config/syncthing"
else "/home/${cfg.user}/.config.syncthing";
enable = true;
};
};
}

View file

@ -0,0 +1,41 @@
{
lib,
pkgs,
inputs,
namespace,
system,
target,
format,
virtual,
systems,
config,
...
}:
with lib;
with lib.${namespace}; let
username = "kylekrein";
admin = true;
extraGroups = ["networkmanager" "touchscreen"];
trustedSshKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGMt3PWVvmEL6a0HHTsxL4KMq1UGKFdzgX5iIkm6owGQ kylekrein@kylekrein-mac"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFDdxZ5OyGcfD1JwEa4RWw86HWZ2dKFR0syrRckl7EvG kylekrein@kylekrein-homepc"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILt+CDDU4gDo12IO2dc50fceIWkn26/NuTq4j25hiGre kylekrein@kylekrein-framework12"
];
cfg = config.${namespace}.users.${username};
in {
options.${namespace}.users.${username} = with types; {
enable = mkBoolOpt false "Enable ${username} user";
config = mkHomeManagerConfigOpt config;
};
config = mkUser {
inherit config;
inherit (cfg) enable;
homeConfig = cfg.config;
inherit username;
inherit admin;
inherit extraGroups;
inherit trustedSshKeys;
};
}

View file

@ -19,24 +19,21 @@ in {
enable = mkBoolOpt false "Enable Niri as your window manager";
};
config =
mkIf cfg.enable {
${namespace} = {
loginManagers.sddm.enable = mkDefault true;
security.pam.services.hyprlock = {};
programs.niri = {
enable = true;
package = pkgs.niri-unstable;
};
niri-flake.cache.enable = true;
environment.systemPackages = with pkgs; [
wl-clipboard
wayland-utils
libsecret
gamescope
xwayland-satellite-unstable
swaybg
];
};
config = mkIf cfg.enable {
${namespace}.loginManagers.sddm.enable = mkDefault true;
security.pam.services.hyprlock = {};
programs.niri = {
enable = true;
package = pkgs.niri-unstable;
};
niri-flake.cache.enable = true;
environment.systemPackages = with pkgs; [
wl-clipboard
wayland-utils
libsecret
gamescope
xwayland-satellite-unstable
swaybg
];
};
}