Modularize code
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
22
hosts/common/configs/persist/default.nix
Normal file
22
hosts/common/configs/persist/default.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{ inputs, lib, ... }:
|
||||
|
||||
{
|
||||
imports = [ inputs.impermanence.nixosModules.impermanence ];
|
||||
|
||||
fileSystems."/persist".neededForBoot = true;
|
||||
boot.initrd.postDeviceCommands = lib.mkAfter (builtins.readFile ./impermanence.sh);
|
||||
|
||||
environment.persistence."/persist" = {
|
||||
hideMounts = true;
|
||||
directories = [
|
||||
"/etc/nixos"
|
||||
"/etc/NetworkManager/system-connections"
|
||||
"/var/lib/nixos"
|
||||
"/var/lib/systemd/coredump"
|
||||
"/var/log"
|
||||
];
|
||||
files = [
|
||||
"/etc/machine-id"
|
||||
];
|
||||
};
|
||||
}
|
@@ -1,5 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
delete_subvolume_recursively() {
|
||||
IFS=$'\n'
|
||||
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
||||
@@ -17,7 +15,7 @@ if [[ -e /mnt/btrfs/root ]]; then
|
||||
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
|
||||
find /mnt/btrfs/root.bak/ -maxdepth 1 -mtime +14 | while IFS= read -r i; do
|
||||
delete_subvolume_recursively "$i"
|
||||
done
|
||||
|
16
hosts/common/configs/sops/default.nix
Normal file
16
hosts/common/configs/sops/default.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{ inputs, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [ inputs.sops-nix.nixosModules.sops ];
|
||||
|
||||
environment = {
|
||||
persistence."/persist".files = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
||||
systemPackages = with pkgs; [ sops ];
|
||||
};
|
||||
|
||||
sops.age = {
|
||||
generateKey = true;
|
||||
sshKeyPaths = [ "/persist/etc/ssh/ssh_host_ed25519_key" ];
|
||||
keyFile = "/var/lib/sops-nix/key.txt";
|
||||
};
|
||||
}
|
@@ -3,4 +3,6 @@
|
||||
enable = true;
|
||||
histFile = "/var/lib/zsh/history";
|
||||
};
|
||||
|
||||
environment.persistence."/persist".directories = [ "/var/lib/zsh" ];
|
||||
}
|
||||
|
@@ -2,8 +2,9 @@
|
||||
|
||||
{
|
||||
imports = [
|
||||
inputs.impermanence.nixosModules.impermanence
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
./configs/persist
|
||||
./configs/sops
|
||||
|
||||
./configs/pipewire
|
||||
./configs/zsh
|
||||
./configs/neovim
|
||||
@@ -14,8 +15,6 @@
|
||||
./configs/gpg-agent
|
||||
];
|
||||
|
||||
fileSystems."/persist".neededForBoot = true;
|
||||
|
||||
boot = {
|
||||
loader = {
|
||||
systemd-boot.enable = true;
|
||||
@@ -23,46 +22,23 @@
|
||||
efi.canTouchEfiVariables = true;
|
||||
};
|
||||
|
||||
initrd = {
|
||||
verbose = false;
|
||||
postDeviceCommands = lib.mkAfter (builtins.readFile ./scripts/impermanence.sh);
|
||||
};
|
||||
|
||||
kernelPackages = pkgs.linuxPackages_latest;
|
||||
supportedFilesystems = [ "btrfs" "ntfs" ];
|
||||
kernelParams = [ "loglevel=3" "quiet" ];
|
||||
initrd.verbose = false;
|
||||
consoleLogLevel = 0;
|
||||
};
|
||||
|
||||
environment = {
|
||||
persistence."/persist" = {
|
||||
hideMounts = true;
|
||||
directories = [
|
||||
"/etc/nixos"
|
||||
"/etc/NetworkManager/system-connections"
|
||||
"/var/lib/nixos"
|
||||
"/var/lib/systemd/coredump"
|
||||
"/var/lib/zsh"
|
||||
"/var/log"
|
||||
];
|
||||
files = [
|
||||
"/etc/ssh/ssh_host_ed25519_key"
|
||||
"/etc/machine-id"
|
||||
];
|
||||
};
|
||||
|
||||
systemPackages = with pkgs; [
|
||||
tree
|
||||
ranger
|
||||
btop
|
||||
fastfetch
|
||||
sops
|
||||
];
|
||||
};
|
||||
|
||||
networking.networkmanager.enable = true;
|
||||
i18n.defaultLocale = "en_US.UTF-8";
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
tree
|
||||
ranger
|
||||
btop
|
||||
fastfetch
|
||||
];
|
||||
|
||||
users = {
|
||||
mutableUsers = false;
|
||||
defaultUserShell = pkgs.zsh;
|
||||
@@ -72,12 +48,6 @@
|
||||
Defaults lecture = never
|
||||
'';
|
||||
|
||||
sops.age = {
|
||||
generateKey = true;
|
||||
sshKeyPaths = [ "/persist/etc/ssh/ssh_host_ed25519_key" ];
|
||||
keyFile = "/var/lib/sops-nix/key.txt";
|
||||
};
|
||||
|
||||
system = {
|
||||
autoUpgrade = {
|
||||
enable = true;
|
||||
|
Reference in New Issue
Block a user