Refactor modules
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
8
hosts/common/configs/neovim.nix
Normal file
8
hosts/common/configs/neovim.nix
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
defaultEditor = true;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
};
|
||||
}
|
9
hosts/common/configs/tmux.nix
Normal file
9
hosts/common/configs/tmux.nix
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
clock24 = true;
|
||||
historyLimit = 10000;
|
||||
keyMode = "vi";
|
||||
newSession = true;
|
||||
};
|
||||
}
|
3
hosts/common/configs/zsh.nix
Normal file
3
hosts/common/configs/zsh.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
programs.zsh.enable = true;
|
||||
}
|
87
hosts/common/default.nix
Normal file
87
hosts/common/default.nix
Normal 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";
|
||||
};
|
||||
}
|
25
hosts/common/scripts/impermanence.sh
Normal file
25
hosts/common/scripts/impermanence.sh
Normal 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
|
Reference in New Issue
Block a user