Refactor modules

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-06-13 12:20:45 +03:00
parent 0357a7bfbf
commit df315f97d6
32 changed files with 317 additions and 253 deletions

View File

@@ -21,13 +21,14 @@
};
};
outputs = { self, nixpkgs, ... } @ inputs:
{
outputs = { self, nixpkgs, ... } @ inputs: {
nixosConfigurations.eirene-vm = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
system = "x86_64-linux";
modules = [
./hosts/eirene/vm/configuration.nix
./common
./hosts/eirene
./hosts/eirene/vm
inputs.disko.nixosModules.default
inputs.impermanence.nixosModules.impermanence
inputs.home-manager.nixosModules.default

View File

@@ -1,12 +1,8 @@
{ inputs, ... }:
let
vars = import ../../users/nick/vars.nix;
in
{
imports = [
../../configuration.nix
../../users/nick/home.nix
../../user
./configs/pipewire.nix
];
@@ -23,5 +19,7 @@ in
};
systemd.tmpfiles.rules = [ "d /persist/home/ 0755 root root -" ];
services.getty.autologinUser = vars.user;
user.vars = import ../../user/nick.nix;
user.autologin = true;
}

View File

@@ -1,63 +0,0 @@
{
disko.devices = {
disk.main = {
type = "disk";
content = {
type = "gpt";
partitions = {
boot = {
name = "boot";
size = "1M";
type = "EF02";
};
esp = {
name = "esp";
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
swap = {
name = "swap";
size = "32G";
content = {
type = "swap";
resumeDevice = true;
};
};
root = {
name = "root";
size = "100%";
content = {
name = "luks";
type = "luks";
settings = {
allowDiscards = true;
};
content = {
type = "btrfs";
extraArgs = ["-f"];
subvolumes = {
"/root" = {
mountpoint = "/";
};
"/persist" = {
mountpoint = "/persist";
mountOptions = ["subvol=persist" "compress=zstd" "noatime"];
};
"/nix" = {
mountpoint = "/nix";
mountOptions = ["subvol=nix" "compress=zstd" "noatime"];
};
};
};
};
};
};
};
};
};
}

78
hosts/eirene/format.nix Normal file
View File

@@ -0,0 +1,78 @@
{ config, lib, ... }:
let
cfg = config.format;
in
{
options.format = {
device = lib.mkOption {
type = lib.types.str;
description = "The device to format";
};
};
config = {
disko.devices = {
disk.main = {
type = "disk";
device = cfg.device;
content = {
type = "gpt";
partitions = {
boot = {
name = "boot";
size = "1M";
type = "EF02";
};
esp = {
name = "esp";
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
swap = {
name = "swap";
size = "32G";
content = {
type = "swap";
resumeDevice = true;
};
};
root = {
name = "root";
size = "100%";
content = {
name = "luks";
type = "luks";
settings = {
allowDiscards = true;
};
content = {
type = "btrfs";
extraArgs = ["-f"];
subvolumes = {
"/root" = {
mountpoint = "/";
};
"/persist" = {
mountpoint = "/persist";
mountOptions = ["subvol=persist" "compress=zstd" "noatime"];
};
"/nix" = {
mountpoint = "/nix";
mountOptions = ["subvol=nix" "compress=zstd" "noatime"];
};
};
};
};
};
};
};
};
};
};
}

View File

@@ -1,22 +0,0 @@
let
vars = import ../../../users/nick/vars.nix;
in
{
imports = [
../configuration.nix
../disko.nix
./hardware-configuration.nix
];
disko.devices.disk.main.device = "/dev/vda";
boot.kernelParams = [ "video=Virtual-1:2560x1600@60" ];
home-manager.users."${vars.user}".wayland.windowManager.hyprland.settings.monitor = "Virtual-1, 2560x1600@60, 0x0, 1";
networking.hostName = "eirene-vm";
fileSystems."/host" = {
device = "host";
fsType = "virtiofs";
};
}

View File

@@ -0,0 +1,15 @@
{
imports = [
../format.nix
./hardware-configuration.nix
];
format.device = "/dev/vda";
networking.hostName = "eirene-vm";
boot.kernelParams = [ "video=Virtual-1:2560x1600@60" ];
fileSystems."/host" = {
device = "host";
fsType = "virtiofs";
};
}

22
user/configs/git.nix Normal file
View File

@@ -0,0 +1,22 @@
{ config, lib, ... }:
let
cfg = config.git;
in
{
options.git = {
vars = lib.mkOption {
type = lib.types.attrs;
description = "Variables for the user";
};
};
config = {
programs.git = {
enable = true;
lfs.enable = true;
userEmail = cfg.vars.email;
userName = cfg.vars.fullName;
};
};
}

81
user/configs/hyprland.nix Normal file
View File

@@ -0,0 +1,81 @@
{ config, lib, ... }:
let
cfg = config.hyprland;
in
{
options.hyprland = {
initScript = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = "Script to execute on startup";
default = null;
};
};
config = {
wayland.windowManager.hyprland = {
enable = true;
settings = {
"$mod" = "SUPER";
"$term" = "kitty";
bind = [
"$mod, Return, exec, $term"
"$mod, r, exec, rofi -show drun"
"$mod, b, exec, firefox"
"$mod, left, movefocus, l"
"$mod, h, movefocus, l"
"$mod, down, movefocus, d"
"$mod, j, movefocus, d"
"$mod, up, movefocus, u"
"$mod, k, movefocus, u"
"$mod, right, movefocus, r"
"$mod, l, movefocus, r"
"$mod_SHIFT, left, movewindow, l"
"$mod_SHIFT, h, movewindow, l"
"$mod_SHIFT, down, movewindow, d"
"$mod_SHIFT, j, movewindow, d"
"$mod_SHIFT, up, movewindow, u"
"$mod_SHIFT, k, movewindow, u"
"$mod_SHIFT, right, movewindow, r"
"$mod_SHIFT, l, movewindow, r"
"$mod_CTRL, left, resizeactive, -20 0"
"$mod_CTRL, h, resizeactive, -20 0"
"$mod_CTRL, down, resizeactive, 0 20"
"$mod_CTRL, j, resizeactive, 0 20"
"$mod_CTRL, up, resizeactive, 0 -20"
"$mod_CTRL, k, resizeactive, 0 -20"
"$mod_CTRL, right, resizeactive, 20 0"
"$mod_CTRL, l, resizeactive, 20 0"
"$mod, Tab, cyclenext"
"$mod, Tab, bringactivetotop"
"$mod_SHIFT, Tab, cyclenext, prev"
"$mod_SHIFT, Tab, bringactivetotop"
"$mod, f, fullscreen, 0"
"$mod, Space, togglefloating"
"$mod, Space, centerwindow"
"$mod, q, killactive"
"CTRL_ALT, Delete, exit"
];
bindm = [
"$mod, mouse:272, movewindow"
"$mod, mouse:273, resizewindow"
];
misc = {
"disable_hyprland_logo" = true;
"disable_splash_rendering" = true;
};
exec-once = cfg.initScript;
};
};
};
}

21
user/configs/stylix.nix Normal file
View File

@@ -0,0 +1,21 @@
{ config, lib, pkgs, ... }:
let
cfg = config.stylix;
in
{
options.stylix = {
wallpaper = lib.mkOption {
type = lib.types.path;
description = "The path to the wallpaper";
};
};
config = {
stylix = {
enable = true;
base16Scheme = "${pkgs.base16-schemes}/share/themes/da-one-sea.yaml";
image = cfg.wallpaper;
};
};
}

92
user/default.nix Normal file
View File

@@ -0,0 +1,92 @@
{ config, inputs, lib, pkgs, ... }:
let
wallpaper = ./wallpapers/clouds.png;
init = pkgs.pkgs.writeShellScriptBin "hyprland-init" ''
${pkgs.swww}/bin/swww-daemon &> /tmp/swww.log &
while ! swww query &> /dev/null; do
sleep 0.1
done
${pkgs.swww}/bin/swww img ${wallpaper}
'';
cfg = config.user;
in
{
options.user = {
vars = lib.mkOption {
type = lib.types.attrs;
description = "Variables for the user";
};
autologin = lib.mkOption {
type = lib.types.bool;
description = "Automatically log in the user on boot";
default = false;
};
};
config = {
users.users."${cfg.vars.user}" = {
isNormalUser = true;
createHome = true;
home = "/home/${cfg.vars.user}";
description = cfg.vars.fullName;
hashedPassword = "***REMOVED***";
extraGroups = [ "wheel" ];
linger = true;
uid = 1000;
};
systemd.tmpfiles.rules = [ "d /persist/home/${cfg.vars.user} 0700 ${cfg.vars.user} users -" ];
services.getty.autologinUser = lib.mkIf cfg.autologin cfg.vars.user;
programs.hyprland.enable = true;
home-manager.users."${cfg.vars.user}" = {
imports = [
inputs.impermanence.nixosModules.home-manager.impermanence
inputs.stylix.homeManagerModules.stylix
./configs/stylix.nix
./configs/hyprland.nix
./configs/zsh.nix
./configs/kitty.nix
./configs/firefox.nix
./configs/git.nix
];
home = {
persistence."/persist/home/${cfg.vars.user}" = {
directories = [
"Documents"
"Downloads"
"Music"
"Pictures"
"Videos"
"Templates"
"VMs"
"git"
".mozilla"
];
files = [
".zsh_history"
];
allowOther = true;
};
packages = with pkgs; [
rofi-wayland
swww
];
stateVersion = "24.05";
};
git.vars = cfg.vars;
hyprland.initScript = "${init}/bin/hyprland-init";
stylix.wallpaper = wallpaper;
systemd.user.startServices = "sd-switch";
};
};
}

View File

@@ -1,11 +0,0 @@
let
vars = import ../vars.nix;
in
{
programs.git = {
enable = true;
lfs.enable = true;
userEmail = vars.email;
userName = vars.fullName;
};
}

View File

@@ -1,64 +0,0 @@
{
wayland.windowManager.hyprland = {
enable = true;
settings = {
"$mod" = "SUPER";
"$term" = "kitty";
bind = [
"$mod, Return, exec, $term"
"$mod, r, exec, rofi -show drun"
"$mod, b, exec, firefox"
"$mod, left, movefocus, l"
"$mod, h, movefocus, l"
"$mod, down, movefocus, d"
"$mod, j, movefocus, d"
"$mod, up, movefocus, u"
"$mod, k, movefocus, u"
"$mod, right, movefocus, r"
"$mod, l, movefocus, r"
"$mod_SHIFT, left, movewindow, l"
"$mod_SHIFT, h, movewindow, l"
"$mod_SHIFT, down, movewindow, d"
"$mod_SHIFT, j, movewindow, d"
"$mod_SHIFT, up, movewindow, u"
"$mod_SHIFT, k, movewindow, u"
"$mod_SHIFT, right, movewindow, r"
"$mod_SHIFT, l, movewindow, r"
"$mod_CTRL, left, resizeactive, -20 0"
"$mod_CTRL, h, resizeactive, -20 0"
"$mod_CTRL, down, resizeactive, 0 20"
"$mod_CTRL, j, resizeactive, 0 20"
"$mod_CTRL, up, resizeactive, 0 -20"
"$mod_CTRL, k, resizeactive, 0 -20"
"$mod_CTRL, right, resizeactive, 20 0"
"$mod_CTRL, l, resizeactive, 20 0"
"$mod, Tab, cyclenext"
"$mod, Tab, bringactivetotop"
"$mod_SHIFT, Tab, cyclenext, prev"
"$mod_SHIFT, Tab, bringactivetotop"
"$mod, f, fullscreen, 0"
"$mod, Space, togglefloating"
"$mod, Space, centerwindow"
"$mod, q, killactive"
"CTRL_ALT, Delete, exit"
];
bindm = [
"$mod, mouse:272, movewindow"
"$mod, mouse:273, resizewindow"
];
misc = {
"disable_hyprland_logo" = true;
"disable_splash_rendering" = true;
};
};
};
}

View File

@@ -1,8 +0,0 @@
{ pkgs, ... }:
{
stylix = {
enable = true;
base16Scheme = "${pkgs.base16-schemes}/share/themes/da-one-sea.yaml";
};
}

View File

@@ -1,76 +0,0 @@
{ inputs, pkgs, ... }:
let
wallpaper = ./wallpapers/clouds.png;
init = pkgs.pkgs.writeShellScriptBin "hyprland-init" ''
${pkgs.swww}/bin/swww-daemon &> /tmp/swww.log &
while ! swww query &> /dev/null; do
sleep 0.1
done
${pkgs.swww}/bin/swww img ${wallpaper}
'';
vars = import ./vars.nix;
in
{
users.users."${vars.user}" = {
isNormalUser = true;
createHome = true;
home = "/home/${vars.user}";
description = vars.fullName;
hashedPassword = "***REMOVED***";
extraGroups = [ "wheel" ];
linger = true;
uid = 1000;
};
systemd.tmpfiles.rules = [ "d /persist/home/${vars.user} 0700 ${vars.user} users -" ];
programs.hyprland.enable = true;
home-manager.users."${vars.user}" = {
imports = [
inputs.impermanence.nixosModules.home-manager.impermanence
inputs.stylix.homeManagerModules.stylix
./configs/stylix.nix
./configs/hyprland.nix
./configs/zsh.nix
./configs/kitty.nix
./configs/firefox.nix
./configs/git.nix
];
home = {
persistence."/persist/home/${vars.user}" = {
directories = [
"Documents"
"Downloads"
"Music"
"Pictures"
"Videos"
"Templates"
"VMs"
"git"
".mozilla"
];
files = [
".zsh_history"
];
allowOther = true;
};
packages = with pkgs; [
rofi-wayland
swww
];
stateVersion = "24.05";
};
stylix.image = wallpaper;
wayland.windowManager.hyprland.settings.exec-once = "${init}/bin/hyprland-init";
systemd.user.startServices = "sd-switch";
};
}