Refactor modules

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-06-13 19:53:43 +03:00
parent 4b5c7e5c68
commit 77deff930e
34 changed files with 326 additions and 313 deletions

View File

@@ -0,0 +1,8 @@
{
programs.neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
};
}

View File

@@ -0,0 +1,9 @@
{
programs.tmux = {
enable = true;
clock24 = true;
historyLimit = 10000;
keyMode = "vi";
newSession = true;
};
}

View File

@@ -0,0 +1,3 @@
{
programs.zsh.enable = true;
}

87
hosts/common/default.nix Normal file
View File

@@ -0,0 +1,87 @@
{ inputs, lib, pkgs, ... }:
{
imports = [
inputs.impermanence.nixosModules.impermanence
./configs/zsh.nix
./configs/neovim.nix
./configs/tmux.nix
];
fileSystems."/persist".neededForBoot = true;
boot = {
loader = {
systemd-boot.enable = true;
timeout = 0;
efi.canTouchEfiVariables = true;
};
initrd = {
verbose = false;
postDeviceCommands = lib.mkAfter (builtins.readFile ./scripts/impermanence.sh);
};
kernelParams = [ "loglevel=3" "quiet" ];
consoleLogLevel = 0;
};
environment = {
persistence."/persist" = {
hideMounts = true;
directories = [
"/etc/nixos"
"/etc/NetworkManager/system-connections"
"/var/lib/nixos"
"/var/log"
"/var/lib/systemd/coredump"
];
files = [
"/var/lib/sops-nix/key.txt"
"/etc/machine-id"
"/root/.zsh_history"
];
};
systemPackages = with pkgs; [
nano
tree
git
ranger
btop
fastfetch
];
};
networking.networkmanager.enable = true;
i18n.defaultLocale = "en_US.UTF-8";
users.defaultUserShell = pkgs.zsh;
programs = {
nix-ld = {
enable = true;
libraries = [ ];
};
};
security.sudo.extraConfig = ''
Defaults lecture = never
'';
nix.settings.experimental-features = [ "nix-command" "flakes" ];
system = {
autoUpgrade = {
enable = true;
flake = inputs.self.outPath;
flags = [
"--update-input"
"nixpkgs"
"-L"
];
dates = "02:00";
};
stateVersion = "24.05";
};
}

View File

@@ -0,0 +1,25 @@
delete_subvolume_recursively() {
IFS=$'\n'
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
delete_subvolume_recursively "/mnt/btrfs/$i"
done
btrfs subvolume delete "$1"
}
mkdir -p /mnt/btrfs
mount /dev/mapper/luks /mnt/btrfs
if [[ -e /mnt/btrfs/root ]]; then
mkdir -p /mnt/btrfs/root.bak
timestamp=$(date --date="@$(stat -c %Y /mnt/btrfs/root)" "+%Y-%m-%-d_%H:%M:%S")
mv /mnt/btrfs/root "/mnt/btrfs/root.bak/$timestamp"
fi
find /mnt/btrfs/root.bak/ -maxdepth 1 -mtime +30 | while IFS= read -r i; do
delete_subvolume_recursively "$i"
done
btrfs subvolume create /mnt/btrfs/root
umount /mnt/btrfs
rmdir /mnt/btrfs

View File

@@ -1,25 +1,12 @@
{ inputs, ... }:
{ config, ... }:
{
imports = [
../../user
../common
../../users/nick
./configs/pipewire.nix
];
time.timeZone = "Europe/Athens";
home-manager = {
extraSpecialArgs = { inherit inputs; };
backupFileExtension = "bak";
};
programs = {
fuse.userAllowOther = true;
dconf.enable = true;
};
systemd.tmpfiles.rules = [ "d /persist/home/ 0755 root root -" ];
user.vars = import ../../user/nick.nix;
user.autologin = true;
services.getty.autologinUser = config.users.users.nick.name;
}

View File

@@ -1,71 +1,62 @@
{ config, lib, ... }:
let
cfg = config.format;
in
{
options.format = {
device = lib.mkOption {
type = lib.types.str;
description = "The device to format";
};
};
device ? throw "device argument is required",
...
}:
config = {
disko.devices = {
disk.main = {
type = "disk";
device = cfg.device;
content = {
type = "gpt";
partitions = {
boot = {
name = "boot";
size = "1M";
type = "EF02";
{
disko.devices = {
disk.main = {
inherit device;
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";
};
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;
};
};
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"];
};
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,12 +1,17 @@
{ inputs, ... }:
{
imports = [
../format.nix
inputs.disko.nixosModules.disko
(import ../format.nix { device = "/dev/vda"; })
./hardware-configuration.nix
../default.nix
];
format.device = "/dev/vda";
networking.hostName = "eirene-vm";
boot.kernelParams = [ "video=Virtual-1:2560x1600@60" ];
home-manager.sharedModules = [{ wayland.windowManager.hyprland.settings.monitor = "Virtual-1, 2560x1600@60, 0x0, 1"; }];
fileSystems."/host" = {
device = "host";