mirror of
https://codeberg.org/privacy1st/nix-git
synced 2024-12-23 02:36:05 +01:00
refactor: btrfs-mount-options module
This commit is contained in:
parent
3439bd5ac5
commit
045858b536
@ -61,11 +61,13 @@ in
|
|||||||
../../modules/spin-down.nix
|
../../modules/spin-down.nix
|
||||||
|
|
||||||
../../modules/btrfs-scrub.nix
|
../../modules/btrfs-scrub.nix
|
||||||
|
../../modules/btrfs-mount-options.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.hostName = "yodaNas";
|
networking.hostName = "yodaNas";
|
||||||
boot.initrd.luks.devices."luks-3d974bd0-f373-469b-8e9c-2d5516e9f0f5".allowDiscards = true;
|
boot.initrd.luks.devices."luks-3d974bd0-f373-469b-8e9c-2d5516e9f0f5".allowDiscards = true;
|
||||||
yoda.btrfs-scrub = ["/" "/mnt/data" "/mnt/backup"];
|
yoda.btrfsFileSystems = ["/" "/mnt/data" "/mnt/backup"];
|
||||||
|
#yoda.btrfsMounts = yoda.btrfsFileSystems;
|
||||||
|
|
||||||
boot.kernelParams = [];
|
boot.kernelParams = [];
|
||||||
|
|
||||||
|
@ -60,12 +60,14 @@ in
|
|||||||
#../../modules/spin-down.nix
|
#../../modules/spin-down.nix
|
||||||
|
|
||||||
../../modules/btrfs-scrub.nix
|
../../modules/btrfs-scrub.nix
|
||||||
|
../../modules/btrfs-mount-options.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.hostName = "yodaTab";
|
networking.hostName = "yodaTab";
|
||||||
boot.initrd.luks.devices."luks-ba8b94d0-7f70-496a-ad87-eadc5e852aad".allowDiscards = true;
|
boot.initrd.luks.devices."luks-ba8b94d0-7f70-496a-ad87-eadc5e852aad".allowDiscards = true;
|
||||||
boot.initrd.luks.devices."512gb".allowDiscards = true;
|
boot.initrd.luks.devices."512gb".allowDiscards = true;
|
||||||
yoda.btrfs-scrub = ["/"];
|
yoda.btrfsFileSystems = ["/"];
|
||||||
|
#yoda.btrfsMounts = yoda.btrfsFileSystems;
|
||||||
|
|
||||||
boot.kernelParams = [];
|
boot.kernelParams = [];
|
||||||
|
|
||||||
|
@ -60,11 +60,13 @@ in
|
|||||||
#../../modules/spin-down.nix
|
#../../modules/spin-down.nix
|
||||||
|
|
||||||
../../modules/btrfs-scrub.nix
|
../../modules/btrfs-scrub.nix
|
||||||
|
../../modules/btrfs-mount-options.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.hostName = "yodaTux";
|
networking.hostName = "yodaTux";
|
||||||
boot.initrd.luks.devices."luks-ea7099e3-320d-4eb3-a4c3-9910a9af817b".allowDiscards = true;
|
boot.initrd.luks.devices."luks-ea7099e3-320d-4eb3-a4c3-9910a9af817b".allowDiscards = true;
|
||||||
yoda.btrfs-scrub = ["/"];
|
yoda.btrfsFileSystems = ["/"];
|
||||||
|
#yoda.btrfsMounts = yoda.btrfsFileSystems;
|
||||||
|
|
||||||
# Systemd Journal entry:
|
# Systemd Journal entry:
|
||||||
# S Sat Sep 23 16:11:52 2023 p4 kernel: TSC found unstable after boot, most likely due to broken BIOS. Use 'tsc=unstable'.
|
# S Sat Sep 23 16:11:52 2023 p4 kernel: TSC found unstable after boot, most likely due to broken BIOS. Use 'tsc=unstable'.
|
||||||
|
@ -61,11 +61,13 @@ in
|
|||||||
#../../modules/spin-down.nix
|
#../../modules/spin-down.nix
|
||||||
|
|
||||||
../../modules/btrfs-scrub.nix
|
../../modules/btrfs-scrub.nix
|
||||||
|
../../modules/btrfs-mount-options.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.hostName = "yodaYoga";
|
networking.hostName = "yodaYoga";
|
||||||
boot.initrd.luks.devices."luks-a8521407-e25b-4f26-8e7a-a56fcbfd2e35".allowDiscards = true;
|
boot.initrd.luks.devices."luks-a8521407-e25b-4f26-8e7a-a56fcbfd2e35".allowDiscards = true;
|
||||||
yoda.btrfs-scrub = ["/"];
|
yoda.btrfsFileSystems = ["/"];
|
||||||
|
#yoda.btrfsMounts = yoda.btrfsFileSystems;
|
||||||
|
|
||||||
boot.kernelParams = [];
|
boot.kernelParams = [];
|
||||||
|
|
||||||
|
@ -80,24 +80,6 @@
|
|||||||
MaxFileSec=7day
|
MaxFileSec=7day
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# BTRFS mount options.
|
|
||||||
#
|
|
||||||
# compress=
|
|
||||||
# `nixos-generate-config` does not detect mount options, so we add them here.
|
|
||||||
# https://nixos.wiki/wiki/Btrfs#Compression
|
|
||||||
#
|
|
||||||
# noatime
|
|
||||||
# Under read intensive work-loads, specifying noatime significantly improves performance because no new access time information needs to be written.
|
|
||||||
# https://man.archlinux.org/man/btrfs.5#NOTES_ON_GENERIC_MOUNT_OPTIONS
|
|
||||||
#
|
|
||||||
# commit=
|
|
||||||
# The number of seconds between periodic commits to the filesystem. This is 30 seconds by default. Increasing this value reduces the frequency of periodic writes which can reduce wear on the disk. However, this also increases the risk of data loss during the event of an untimely crash.
|
|
||||||
# https://www.jwillikers.com/btrfs-mount-options
|
|
||||||
#
|
|
||||||
fileSystems = {
|
|
||||||
"/".options = [ "compress=zstd" "noatime" "commit=120" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
nix.settings.auto-optimise-store = true;
|
nix.settings.auto-optimise-store = true;
|
||||||
|
|
||||||
# https://nixos.wiki/wiki/Storage_optimization#Automation
|
# https://nixos.wiki/wiki/Storage_optimization#Automation
|
||||||
|
43
modules/btrfs-mount-options.nix
Normal file
43
modules/btrfs-mount-options.nix
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# BTRFS mount options.
|
||||||
|
#
|
||||||
|
# compress=
|
||||||
|
# `nixos-generate-config` does not detect mount options, so we add them here.
|
||||||
|
# https://nixos.wiki/wiki/Btrfs#Compression
|
||||||
|
#
|
||||||
|
# noatime
|
||||||
|
# Under read intensive work-loads, specifying noatime significantly improves performance because no new access time information needs to be written.
|
||||||
|
# https://man.archlinux.org/man/btrfs.5#NOTES_ON_GENERIC_MOUNT_OPTIONS
|
||||||
|
#
|
||||||
|
# commit=
|
||||||
|
# The number of seconds between periodic commits to the filesystem. This is 30 seconds by default. Increasing this value reduces the frequency of periodic writes which can reduce wear on the disk. However, this also increases the risk of data loss during the event of an untimely crash.
|
||||||
|
# https://www.jwillikers.com/btrfs-mount-options
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
{ lib, config, options, pkgs, modulesPath, ... }:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.yoda.btrfsMounts;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
yoda.btrfsMounts = mkOption {
|
||||||
|
type = types.listOf types.path;
|
||||||
|
default = config.yoda.btrfsFileSystems;
|
||||||
|
example = ["/" "/mnt/data"];
|
||||||
|
description = ''
|
||||||
|
List containing each BTRFS mountpoint.
|
||||||
|
If each BTRFS filesystem is only mounted once, this can be left at its default value.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf (length cfg > 0) {
|
||||||
|
# For each element (e.g. "/") in `cfg` create this config:
|
||||||
|
# fileSystems."/".options = [ "compress=zstd" "noatime" "commit=120" ];
|
||||||
|
fileSystems = builtins.listToAttrs (builtins.map (fs: {
|
||||||
|
name = fs;
|
||||||
|
value = { options = [ "compress=zstd" "noatime" "commit=120" ]; };
|
||||||
|
}) cfg);
|
||||||
|
};
|
||||||
|
}
|
@ -17,11 +17,11 @@
|
|||||||
{ lib, config, options, pkgs, modulesPath, ... }:
|
{ lib, config, options, pkgs, modulesPath, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.yoda.btrfs-scrub;
|
cfg = config.yoda.btrfsFileSystems;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
yoda.btrfs-scrub = mkOption {
|
yoda.btrfsFileSystems = mkOption {
|
||||||
type = types.listOf types.path;
|
type = types.listOf types.path;
|
||||||
default = ["/"];
|
default = ["/"];
|
||||||
example = ["/" "/mnt/data"];
|
example = ["/" "/mnt/data"];
|
||||||
|
Loading…
Reference in New Issue
Block a user