nix fmt .
This commit is contained in:
parent
03629e8561
commit
aadf1c170b
@ -1,6 +1,9 @@
|
|||||||
{ config, pkgs, lib, ... }:
|
{
|
||||||
|
config,
|
||||||
let
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
gitea_uidgid = 995;
|
gitea_uidgid = 995;
|
||||||
|
|
||||||
tailscale_subnet = {
|
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";
|
turn_cert_dir = "/var/lib/caddy/.local/share/caddy/certificates/acme-v02.api.letsencrypt.org-directory/turn.jakstys.lt";
|
||||||
|
|
||||||
# functions
|
# functions
|
||||||
mountLatest = ({mountpoint, zfs_name}:
|
mountLatest = (
|
||||||
''
|
{
|
||||||
|
mountpoint,
|
||||||
|
zfs_name,
|
||||||
|
}: ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
${pkgs.util-linux}/bin/umount ${mountpoint}/.snapshot-latest &>/dev/null || :
|
${pkgs.util-linux}/bin/umount ${mountpoint}/.snapshot-latest &>/dev/null || :
|
||||||
mkdir -p ${mountpoint}/.snapshot-latest
|
mkdir -p ${mountpoint}/.snapshot-latest
|
||||||
@ -53,29 +59,31 @@ let
|
|||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
umountLatest = ({mountpoint, ...}:
|
umountLatest = (
|
||||||
''set -euo pipefail
|
{mountpoint, ...}: '' set -euo pipefail
|
||||||
${pkgs.util-linux}/bin/umount ${mountpoint}/.snapshot-latest
|
${pkgs.util-linux}/bin/umount ${mountpoint}/.snapshot-latest
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
in {
|
in {
|
||||||
imports =
|
imports = [
|
||||||
[
|
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./zfs.nix
|
./zfs.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
nixpkgs.overlays = [ (self: super: {
|
nixpkgs.overlays = [
|
||||||
|
(self: super: {
|
||||||
systemd = super.systemd.overrideAttrs (old: {
|
systemd = super.systemd.overrideAttrs (old: {
|
||||||
patches = (old.patches or []) ++ [
|
patches =
|
||||||
|
(old.patches or [])
|
||||||
|
++ [
|
||||||
(super.fetchpatch {
|
(super.fetchpatch {
|
||||||
url = "https://github.com/systemd/systemd/commit/e7f64b896201da4a11da158c35865604cf02062f.patch";
|
url = "https://github.com/systemd/systemd/commit/e7f64b896201da4a11da158c35865604cf02062f.patch";
|
||||||
sha256 = "sha256-AvBkrD9n5ux1o167yKg1eJK8C300vBS/ks3Gbvy5vjw=";
|
sha256 = "sha256-AvBkrD9n5ux1o167yKg1eJK8C300vBS/ks3Gbvy5vjw=";
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
} ) ];
|
})
|
||||||
|
];
|
||||||
|
|
||||||
boot.initrd.network = {
|
boot.initrd.network = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@ -220,20 +228,25 @@ in {
|
|||||||
autosnap = true;
|
autosnap = true;
|
||||||
autoprune = true;
|
autoprune = true;
|
||||||
};
|
};
|
||||||
datasets = lib.mapAttrs' (name: value: {
|
datasets =
|
||||||
|
lib.mapAttrs' (name: value: {
|
||||||
name = value.zfs_name;
|
name = value.zfs_name;
|
||||||
value = {use_template = ["prod"];};
|
value = {use_template = ["prod"];};
|
||||||
}) backup_paths;
|
})
|
||||||
|
backup_paths;
|
||||||
extraArgs = ["--verbose"];
|
extraArgs = ["--verbose"];
|
||||||
};
|
};
|
||||||
|
|
||||||
borgbackup.jobs = lib.mapAttrs' (name: value:
|
borgbackup.jobs = lib.mapAttrs' (name: value: let
|
||||||
let
|
snapshot = {
|
||||||
snapshot = { mountpoint = value.mountpoint; zfs_name = value.zfs_name; };
|
mountpoint = value.mountpoint;
|
||||||
|
zfs_name = value.zfs_name;
|
||||||
|
};
|
||||||
rwpath = value.mountpoint + "/.snapshot-latest";
|
rwpath = value.mountpoint + "/.snapshot-latest";
|
||||||
in {
|
in {
|
||||||
name = name;
|
name = name;
|
||||||
value = {
|
value =
|
||||||
|
{
|
||||||
doInit = true;
|
doInit = true;
|
||||||
repo = "zh2769@zh2769.rsync.net:hel1-a.servers.jakst";
|
repo = "zh2769@zh2769.rsync.net:hel1-a.servers.jakst";
|
||||||
encryption = {
|
encryption = {
|
||||||
@ -253,12 +266,12 @@ in {
|
|||||||
weekly = 4;
|
weekly = 4;
|
||||||
monthly = 3;
|
monthly = 3;
|
||||||
};
|
};
|
||||||
} // lib.optionalAttrs (value ? patterns) {
|
}
|
||||||
|
// lib.optionalAttrs (value ? patterns) {
|
||||||
patterns = value.patterns;
|
patterns = value.patterns;
|
||||||
};
|
};
|
||||||
}) backup_paths;
|
}) backup_paths;
|
||||||
|
|
||||||
|
|
||||||
headscale = {
|
headscale = {
|
||||||
enable = true;
|
enable = true;
|
||||||
serverUrl = "https://vpn.jakstys.lt";
|
serverUrl = "https://vpn.jakstys.lt";
|
||||||
@ -442,11 +455,31 @@ in {
|
|||||||
federation_rc_concurrent = 3;
|
federation_rc_concurrent = 3;
|
||||||
allow_profile_lookup_over_federation = false;
|
allow_profile_lookup_over_federation = false;
|
||||||
thumbnail_sizes = [
|
thumbnail_sizes = [
|
||||||
{ width = 32; height = 32; method = "crop"; }
|
{
|
||||||
{ width = 96; height = 96; method = "crop"; }
|
width = 32;
|
||||||
{ width = 320; height = 240; method = "scale"; }
|
height = 32;
|
||||||
{ width = 640; height = 480; method = "scale"; }
|
method = "crop";
|
||||||
{ width = 800; height = 600; method = "scale"; }
|
}
|
||||||
|
{
|
||||||
|
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 = {
|
user_directory = {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
@ -551,23 +584,30 @@ in {
|
|||||||
semantic-checks: on
|
semantic-checks: on
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
hostName = "hel1-a";
|
hostName = "hel1-a";
|
||||||
domain = "jakstys.lt";
|
domain = "jakstys.lt";
|
||||||
firewall = let
|
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 {
|
in {
|
||||||
allowedTCPPorts = [
|
allowedTCPPorts = [
|
||||||
53
|
53
|
||||||
80 443
|
80
|
||||||
3478 5349 5350 # coturn
|
443
|
||||||
|
3478
|
||||||
|
5349
|
||||||
|
5350 # coturn
|
||||||
];
|
];
|
||||||
allowedUDPPorts = [
|
allowedUDPPorts = [
|
||||||
53 443
|
53
|
||||||
|
443
|
||||||
41641
|
41641
|
||||||
];
|
];
|
||||||
allowedUDPPortRanges = coturn;
|
allowedUDPPortRanges = coturn;
|
||||||
@ -602,7 +642,8 @@ in {
|
|||||||
"d /run/matrix-synapse 0700 matrix-synapse matrix-synapse -"
|
"d /run/matrix-synapse 0700 matrix-synapse matrix-synapse -"
|
||||||
];
|
];
|
||||||
|
|
||||||
systemd.services = {
|
systemd.services =
|
||||||
|
{
|
||||||
"make-snapshot-dirs" = let
|
"make-snapshot-dirs" = let
|
||||||
vals = builtins.attrValues backup_paths;
|
vals = builtins.attrValues backup_paths;
|
||||||
mountpoints = builtins.catAttrs "mountpoint" vals;
|
mountpoints = builtins.catAttrs "mountpoint" vals;
|
||||||
@ -700,14 +741,14 @@ in {
|
|||||||
|
|
||||||
zfs-scrub.unitConfig.OnFailure = "unit-status-mail@zfs-scrub.service";
|
zfs-scrub.unitConfig.OnFailure = "unit-status-mail@zfs-scrub.service";
|
||||||
nixos-upgrade.unitConfig.OnFailure = "unit-status-mail@nixos-upgrade.service";
|
nixos-upgrade.unitConfig.OnFailure = "unit-status-mail@nixos-upgrade.service";
|
||||||
|
}
|
||||||
} // lib.mapAttrs' (name: value: {
|
// lib.mapAttrs' (name: value: {
|
||||||
name = "borgbackup-job-${name}";
|
name = "borgbackup-job-${name}";
|
||||||
value = {
|
value = {
|
||||||
unitConfig.OnFailure = "unit-status-mail@borgbackup-job-${name}.service";
|
unitConfig.OnFailure = "unit-status-mail@borgbackup-job-${name}.service";
|
||||||
};
|
};
|
||||||
}) backup_paths;
|
})
|
||||||
|
backup_paths;
|
||||||
|
|
||||||
systemd.paths = {
|
systemd.paths = {
|
||||||
cert-watcher = {
|
cert-watcher = {
|
||||||
@ -722,4 +763,3 @@ in {
|
|||||||
# Do not change
|
# Do not change
|
||||||
system.stateVersion = "22.11";
|
system.stateVersion = "22.11";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
flake.nix
21
flake.nix
@ -9,10 +9,15 @@
|
|||||||
deploy-rs.inputs.utils.follows = "flake-utils";
|
deploy-rs.inputs.utils.follows = "flake-utils";
|
||||||
|
|
||||||
flake-utils.url = "github:numtide/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 {
|
nixosConfigurations.hel1-a = nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [
|
modules = [
|
||||||
@ -36,15 +41,15 @@
|
|||||||
|
|
||||||
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
|
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
|
||||||
}
|
}
|
||||||
// flake-utils.lib.eachDefaultSystem (system:
|
// flake-utils.lib.eachDefaultSystem (system: let
|
||||||
let
|
|
||||||
pkgs = import nixpkgs {inherit system;};
|
pkgs = import nixpkgs {inherit system;};
|
||||||
in
|
in {
|
||||||
{
|
devShells.default = with pkgs;
|
||||||
devShells.default = with pkgs; mkShell {
|
mkShell {
|
||||||
name = "rules_nixpkgs_shell";
|
name = "rules_nixpkgs_shell";
|
||||||
packages = [bash];
|
packages = [bash];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
formatter = pkgs.alejandra;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,43 +1,51 @@
|
|||||||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||||
# and may be overwritten by future invocations. Please make changes
|
# and may be overwritten by future invocations. Please make changes
|
||||||
# to /etc/nixos/configuration.nix instead.
|
# to /etc/nixos/configuration.nix instead.
|
||||||
{ config, lib, pkgs, modulesPath, ... }:
|
|
||||||
|
|
||||||
{
|
{
|
||||||
imports =
|
config,
|
||||||
[ (modulesPath + "/profiles/qemu-guest.nix") ];
|
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.availableKernelModules = ["ata_piix" "virtio_pci" "virtio_scsi" "xhci_pci" "sd_mod" "sr_mod"];
|
||||||
boot.initrd.kernelModules = [];
|
boot.initrd.kernelModules = [];
|
||||||
boot.kernelModules = [];
|
boot.kernelModules = [];
|
||||||
boot.extraModulePackages = [];
|
boot.extraModulePackages = [];
|
||||||
|
|
||||||
fileSystems."/" =
|
fileSystems."/" = {
|
||||||
{ device = "rpool/nixos/root";
|
device = "rpool/nixos/root";
|
||||||
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
fsType = "zfs";
|
||||||
|
options = ["zfsutil" "X-mount.mkdir"];
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/home" =
|
fileSystems."/home" = {
|
||||||
{ device = "rpool/nixos/home";
|
device = "rpool/nixos/home";
|
||||||
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
fsType = "zfs";
|
||||||
|
options = ["zfsutil" "X-mount.mkdir"];
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/var/lib" =
|
fileSystems."/var/lib" = {
|
||||||
{ device = "rpool/nixos/var/lib";
|
device = "rpool/nixos/var/lib";
|
||||||
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
fsType = "zfs";
|
||||||
|
options = ["zfsutil" "X-mount.mkdir"];
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/var/log" =
|
fileSystems."/var/log" = {
|
||||||
{ device = "rpool/nixos/var/log";
|
device = "rpool/nixos/var/log";
|
||||||
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
fsType = "zfs";
|
||||||
|
options = ["zfsutil" "X-mount.mkdir"];
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/boot" =
|
fileSystems."/boot" = {
|
||||||
{ device = "bpool/nixos/root";
|
device = "bpool/nixos/root";
|
||||||
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
|
fsType = "zfs";
|
||||||
|
options = ["zfsutil" "X-mount.mkdir"];
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/boot/efis/scsi-0QEMU_QEMU_HARDDISK_9233346-part1" =
|
fileSystems."/boot/efis/scsi-0QEMU_QEMU_HARDDISK_9233346-part1" = {
|
||||||
{ device = "/dev/disk/by-uuid/B6D7-D52E";
|
device = "/dev/disk/by-uuid/B6D7-D52E";
|
||||||
fsType = "vfat";
|
fsType = "vfat";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,11 +15,12 @@ let
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
in {
|
in {
|
||||||
hel1a = pkgs.krops.writeDeploy "deploy-hel1a" {
|
hel1a = pkgs.krops.writeDeploy "deploy-hel1a" {
|
||||||
source = source;
|
source = source;
|
||||||
target = lib.mkTarget "motiejus@hel1-a.jakstys.lt" // {
|
target =
|
||||||
|
lib.mkTarget "motiejus@hel1-a.jakstys.lt"
|
||||||
|
// {
|
||||||
sudo = true;
|
sudo = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
9
zfs.nix
9
zfs.nix
@ -1,6 +1,9 @@
|
|||||||
{ config, pkgs, ... }:
|
{
|
||||||
|
config,
|
||||||
{ boot.supportedFilesystems = [ "zfs" ];
|
pkgs,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
boot.supportedFilesystems = ["zfs"];
|
||||||
networking.hostId = "cd1a441c";
|
networking.hostId = "cd1a441c";
|
||||||
boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
|
boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
|
||||||
boot.loader.efi.efiSysMountPoint = "/boot/efi";
|
boot.loader.efi.efiSysMountPoint = "/boot/efi";
|
||||||
|
Loading…
Reference in New Issue
Block a user