chore: format nix files treewide
This commit is contained in:
parent
e1652efa53
commit
90d10606bc
30 changed files with 387 additions and 319 deletions
|
@ -1,9 +1,9 @@
|
|||
{ config, lib, ... }:
|
||||
{
|
||||
config = {
|
||||
services.pipewire = {
|
||||
enable = true;
|
||||
pulse.enable = true;
|
||||
};
|
||||
services.pipewire = {
|
||||
enable = true;
|
||||
pulse.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,81 +1,89 @@
|
|||
{lib, config, ...}:
|
||||
{ lib, config, ... }:
|
||||
let
|
||||
cfg = config.hardware.drives.btrfs;
|
||||
in
|
||||
{
|
||||
config = lib.mkIf (cfg.enable) (lib.mkMerge [
|
||||
{
|
||||
boot.initrd.kernelModules = [ "dm-snapshot" ];
|
||||
disko.devices.disk.main = {
|
||||
device = cfg.drive;
|
||||
type = "disk";
|
||||
content.type = "gpt";
|
||||
content.partitions = {
|
||||
boot.name = "boot";
|
||||
boot.size = "1M";
|
||||
boot.type = "EF02";
|
||||
esp.name = "ESP";
|
||||
esp.size = "500M";
|
||||
esp.type = "EF00";
|
||||
esp.content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
swap.size = "4G";
|
||||
swap.content = {
|
||||
type = "swap";
|
||||
resumeDevice = true;
|
||||
};
|
||||
root.name = "root";
|
||||
root.size = "100%";
|
||||
root.content = {
|
||||
type = "lvm_pv";
|
||||
vg = "root_vg";
|
||||
};
|
||||
};
|
||||
};
|
||||
config = lib.mkIf (cfg.enable) (
|
||||
lib.mkMerge [
|
||||
{
|
||||
boot.initrd.kernelModules = [ "dm-snapshot" ];
|
||||
disko.devices.disk.main = {
|
||||
device = cfg.drive;
|
||||
type = "disk";
|
||||
content.type = "gpt";
|
||||
content.partitions = {
|
||||
boot.name = "boot";
|
||||
boot.size = "1M";
|
||||
boot.type = "EF02";
|
||||
esp.name = "ESP";
|
||||
esp.size = "500M";
|
||||
esp.type = "EF00";
|
||||
esp.content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
swap.size = "4G";
|
||||
swap.content = {
|
||||
type = "swap";
|
||||
resumeDevice = true;
|
||||
};
|
||||
root.name = "root";
|
||||
root.size = "100%";
|
||||
root.content = {
|
||||
type = "lvm_pv";
|
||||
vg = "root_vg";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
disko.devices.lvm_vg.root_vg = {
|
||||
type = "lvm_vg";
|
||||
lvs.root.size = "100%FREE";
|
||||
lvs.root.content.type = "btrfs";
|
||||
lvs.root.content.extraArgs = ["-f"];
|
||||
lvs.root.content.subvolumes = {
|
||||
"/root".mountpoint = "/";
|
||||
"/persist".mountpoint = "/persist";
|
||||
"/persist".mountOptions = ["subvol=persist" "noatime"];
|
||||
"/nix".mountpoint = "/nix";
|
||||
"/nix".mountOptions = ["subvol=nix" "noatime"];
|
||||
};
|
||||
};
|
||||
}
|
||||
(lib.mkIf (cfg.ephemeralRoot) {
|
||||
boot.initrd.postDeviceCommands = lib.mkAfter ''
|
||||
mkdir /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
|
||||
disko.devices.lvm_vg.root_vg = {
|
||||
type = "lvm_vg";
|
||||
lvs.root.size = "100%FREE";
|
||||
lvs.root.content.type = "btrfs";
|
||||
lvs.root.content.extraArgs = [ "-f" ];
|
||||
lvs.root.content.subvolumes = {
|
||||
"/root".mountpoint = "/";
|
||||
"/persist".mountpoint = "/persist";
|
||||
"/persist".mountOptions = [
|
||||
"subvol=persist"
|
||||
"noatime"
|
||||
];
|
||||
"/nix".mountpoint = "/nix";
|
||||
"/nix".mountOptions = [
|
||||
"subvol=nix"
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
(lib.mkIf (cfg.ephemeralRoot) {
|
||||
boot.initrd.postDeviceCommands = lib.mkAfter ''
|
||||
mkdir /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"
|
||||
}
|
||||
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
|
||||
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
|
||||
'';
|
||||
programs.fuse.userAllowOther = true;
|
||||
})
|
||||
]);
|
||||
btrfs subvolume create /btrfs_tmp/root
|
||||
umount /btrfs_tmp
|
||||
'';
|
||||
programs.fuse.userAllowOther = true;
|
||||
})
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{ config, lib, ... }:
|
||||
{
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf (config.hardware.platform == "amd"){
|
||||
hardware.cpu.amd.updateMicrocode = true;
|
||||
boot.kernelModules = [ "kvm-amd" ];
|
||||
(lib.mkIf (config.hardware.platform == "amd") {
|
||||
hardware.cpu.amd.updateMicrocode = true;
|
||||
boot.kernelModules = [ "kvm-amd" ];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{lib,...}:
|
||||
{ lib, ... }:
|
||||
{
|
||||
imports = [
|
||||
./btrfs.nix
|
||||
|
|
|
@ -2,20 +2,22 @@
|
|||
{
|
||||
config = lib.mkMerge [
|
||||
{
|
||||
networking.useDHCP = lib.mkDefault true;
|
||||
networking.hostName = config.system.hostname;
|
||||
networking.networkmanager.enable = true;
|
||||
networking.useDHCP = lib.mkDefault true;
|
||||
networking.hostName = config.system.hostname;
|
||||
networking.networkmanager.enable = true;
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
PrintMotd = true;};
|
||||
};
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
PrintMotd = true;
|
||||
};
|
||||
};
|
||||
|
||||
services.tailscale = {
|
||||
enable = true;
|
||||
authKeyFile = config.sops.secrets."keys/tailscale".path;};
|
||||
environment.persistence."/persist".files = [ "/var/lib/tailscale/tailscaled.state"];
|
||||
services.tailscale = {
|
||||
enable = true;
|
||||
authKeyFile = config.sops.secrets."keys/tailscale".path;
|
||||
};
|
||||
environment.persistence."/persist".files = [ "/var/lib/tailscale/tailscaled.state" ];
|
||||
}
|
||||
|
||||
];
|
||||
|
|
|
@ -1,21 +1,28 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
{
|
||||
config = lib.mkIf (config.hardware.gpu == "nvidia") (lib.mkMerge [
|
||||
{
|
||||
#TODO: Setup CUDA
|
||||
hardware.graphics.enable = true;
|
||||
hardware.graphics.extraPackages = with pkgs; [
|
||||
nvidia-vaapi-driver
|
||||
];
|
||||
services.xserver.videoDrivers = [ "nvidia" ];
|
||||
hardware.nvidia.open = true;
|
||||
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.latest;
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
environment.variables = {
|
||||
LIBVA_DRIVER_NAME = "nvidia";
|
||||
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
|
||||
NVD_BACKEND = "direct";
|
||||
};
|
||||
}
|
||||
]);
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
config = lib.mkIf (config.hardware.gpu == "nvidia") (
|
||||
lib.mkMerge [
|
||||
{
|
||||
#TODO: Setup CUDA
|
||||
hardware.graphics.enable = true;
|
||||
hardware.graphics.extraPackages = with pkgs; [
|
||||
nvidia-vaapi-driver
|
||||
];
|
||||
services.xserver.videoDrivers = [ "nvidia" ];
|
||||
hardware.nvidia.open = true;
|
||||
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.latest;
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
environment.variables = {
|
||||
LIBVA_DRIVER_NAME = "nvidia";
|
||||
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
|
||||
NVD_BACKEND = "direct";
|
||||
};
|
||||
}
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue