nix fmt .

This commit is contained in:
Motiejus Jakštys 2023-04-03 16:50:52 +03:00
parent 03629e8561
commit aadf1c170b
6 changed files with 313 additions and 256 deletions

View File

@ -1,6 +1,9 @@
{ config, pkgs, lib, ... }:
let
{
config,
pkgs,
lib,
...
}: let
gitea_uidgid = 995;
tailscale_subnet = {
@ -44,8 +47,11 @@ let
turn_cert_dir = "/var/lib/caddy/.local/share/caddy/certificates/acme-v02.api.letsencrypt.org-directory/turn.jakstys.lt";
# functions
mountLatest = ({mountpoint, zfs_name}:
''
mountLatest = (
{
mountpoint,
zfs_name,
}: ''
set -euo pipefail
${pkgs.util-linux}/bin/umount ${mountpoint}/.snapshot-latest &>/dev/null || :
mkdir -p ${mountpoint}/.snapshot-latest
@ -53,29 +59,31 @@ let
''
);
umountLatest = ({mountpoint, ...}:
''set -euo pipefail
umountLatest = (
{mountpoint, ...}: '' set -euo pipefail
${pkgs.util-linux}/bin/umount ${mountpoint}/.snapshot-latest
''
);
in {
imports =
[
imports = [
./hardware-configuration.nix
./zfs.nix
];
nixpkgs.overlays = [ (self: super: {
nixpkgs.overlays = [
(self: super: {
systemd = super.systemd.overrideAttrs (old: {
patches = (old.patches or []) ++ [
patches =
(old.patches or [])
++ [
(super.fetchpatch {
url = "https://github.com/systemd/systemd/commit/e7f64b896201da4a11da158c35865604cf02062f.patch";
sha256 = "sha256-AvBkrD9n5ux1o167yKg1eJK8C300vBS/ks3Gbvy5vjw=";
})
];
});
} ) ];
})
];
boot.initrd.network = {
enable = true;
@ -220,20 +228,25 @@ in {
autosnap = true;
autoprune = true;
};
datasets = lib.mapAttrs' (name: value: {
datasets =
lib.mapAttrs' (name: value: {
name = value.zfs_name;
value = {use_template = ["prod"];};
}) backup_paths;
})
backup_paths;
extraArgs = ["--verbose"];
};
borgbackup.jobs = lib.mapAttrs' (name: value:
let
snapshot = { mountpoint = value.mountpoint; zfs_name = value.zfs_name; };
borgbackup.jobs = lib.mapAttrs' (name: value: let
snapshot = {
mountpoint = value.mountpoint;
zfs_name = value.zfs_name;
};
rwpath = value.mountpoint + "/.snapshot-latest";
in {
name = name;
value = {
value =
{
doInit = true;
repo = "zh2769@zh2769.rsync.net:hel1-a.servers.jakst";
encryption = {
@ -253,12 +266,12 @@ in {
weekly = 4;
monthly = 3;
};
} // lib.optionalAttrs (value ? patterns) {
}
// lib.optionalAttrs (value ? patterns) {
patterns = value.patterns;
};
}) backup_paths;
headscale = {
enable = true;
serverUrl = "https://vpn.jakstys.lt";
@ -442,11 +455,31 @@ in {
federation_rc_concurrent = 3;
allow_profile_lookup_over_federation = false;
thumbnail_sizes = [
{ width = 32; height = 32; method = "crop"; }
{ width = 96; height = 96; method = "crop"; }
{ width = 320; height = 240; method = "scale"; }
{ width = 640; height = 480; method = "scale"; }
{ width = 800; height = 600; method = "scale"; }
{
width = 32;
height = 32;
method = "crop";
}
{
width = 96;
height = 96;
method = "crop";
}
{
width = 320;
height = 240;
method = "scale";
}
{
width = 640;
height = 480;
method = "scale";
}
{
width = 800;
height = 600;
method = "scale";
}
];
user_directory = {
enabled = true;
@ -551,23 +584,30 @@ in {
semantic-checks: on
'';
};
};
networking = {
hostName = "hel1-a";
domain = "jakstys.lt";
firewall = let
coturn = with config.services.coturn; [ { from = min-port; to = max-port; } ];
coturn = with config.services.coturn; [
{
from = min-port;
to = max-port;
}
];
in {
allowedTCPPorts = [
53
80 443
3478 5349 5350 # coturn
80
443
3478
5349
5350 # coturn
];
allowedUDPPorts = [
53 443
53
443
41641
];
allowedUDPPortRanges = coturn;
@ -602,7 +642,8 @@ in {
"d /run/matrix-synapse 0700 matrix-synapse matrix-synapse -"
];
systemd.services = {
systemd.services =
{
"make-snapshot-dirs" = let
vals = builtins.attrValues backup_paths;
mountpoints = builtins.catAttrs "mountpoint" vals;
@ -700,14 +741,14 @@ in {
zfs-scrub.unitConfig.OnFailure = "unit-status-mail@zfs-scrub.service";
nixos-upgrade.unitConfig.OnFailure = "unit-status-mail@nixos-upgrade.service";
} // lib.mapAttrs' (name: value: {
}
// lib.mapAttrs' (name: value: {
name = "borgbackup-job-${name}";
value = {
unitConfig.OnFailure = "unit-status-mail@borgbackup-job-${name}.service";
};
}) backup_paths;
})
backup_paths;
systemd.paths = {
cert-watcher = {
@ -722,4 +763,3 @@ in {
# Do not change
system.stateVersion = "22.11";
}

View File

@ -9,10 +9,15 @@
deploy-rs.inputs.utils.follows = "flake-utils";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, deploy-rs, flake-utils }: {
outputs = {
self,
nixpkgs,
deploy-rs,
flake-utils,
}:
{
nixosConfigurations.hel1-a = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
@ -36,15 +41,15 @@
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
}
// flake-utils.lib.eachDefaultSystem (system:
let
// flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
in
{
devShells.default = with pkgs; mkShell {
in {
devShells.default = with pkgs;
mkShell {
name = "rules_nixpkgs_shell";
packages = [bash];
};
formatter = pkgs.alejandra;
});
}

View File

@ -1,43 +1,51 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/profiles/qemu-guest.nix") ];
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [(modulesPath + "/profiles/qemu-guest.nix")];
boot.initrd.availableKernelModules = ["ata_piix" "virtio_pci" "virtio_scsi" "xhci_pci" "sd_mod" "sr_mod"];
boot.initrd.kernelModules = [];
boot.kernelModules = [];
boot.extraModulePackages = [];
fileSystems."/" =
{ device = "rpool/nixos/root";
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
fileSystems."/" = {
device = "rpool/nixos/root";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/home" =
{ device = "rpool/nixos/home";
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
fileSystems."/home" = {
device = "rpool/nixos/home";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/var/lib" =
{ device = "rpool/nixos/var/lib";
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
fileSystems."/var/lib" = {
device = "rpool/nixos/var/lib";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/var/log" =
{ device = "rpool/nixos/var/log";
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
fileSystems."/var/log" = {
device = "rpool/nixos/var/log";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/boot" =
{ device = "bpool/nixos/root";
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
fileSystems."/boot" = {
device = "bpool/nixos/root";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
};
fileSystems."/boot/efis/scsi-0QEMU_QEMU_HARDDISK_9233346-part1" =
{ device = "/dev/disk/by-uuid/B6D7-D52E";
fileSystems."/boot/efis/scsi-0QEMU_QEMU_HARDDISK_9233346-part1" = {
device = "/dev/disk/by-uuid/B6D7-D52E";
fsType = "vfat";
};

View File

@ -15,11 +15,12 @@ let
};
}
];
in {
hel1a = pkgs.krops.writeDeploy "deploy-hel1a" {
source = source;
target = lib.mkTarget "motiejus@hel1-a.jakstys.lt" // {
target =
lib.mkTarget "motiejus@hel1-a.jakstys.lt"
// {
sudo = true;
};
};

View File

@ -1,6 +1,9 @@
{ config, pkgs, ... }:
{ boot.supportedFilesystems = [ "zfs" ];
{
config,
pkgs,
...
}: {
boot.supportedFilesystems = ["zfs"];
networking.hostId = "cd1a441c";
boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
boot.loader.efi.efiSysMountPoint = "/boot/efi";