From 959deb8dbc5c7559c17a377ece1b698a47dbef8d Mon Sep 17 00:00:00 2001 From: cy Date: Thu, 20 Mar 2025 11:03:22 -0400 Subject: [PATCH 1/7] try helix --- flake.lock | 43 ++++++++++++++++++++++++++++++++++++++++++- flake.nix | 5 +++++ home/yt/ytnix.nix | 13 +++++++++++++ overlay/default.nix | 1 + 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/flake.lock b/flake.lock index 4bf9015..ddda4b4 100644 --- a/flake.lock +++ b/flake.lock @@ -448,6 +448,30 @@ "type": "github" } }, + "helix": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": "nixpkgs_4", + "rust-overlay": [ + "rust-overlay" + ] + }, + "locked": { + "lastModified": 1742479163, + "narHash": "sha256-YC0zdGyZMu7seA2Jm1mxtcxE4lSeVwvCPMfWzJ8+o/c=", + "owner": "helix-editor", + "repo": "helix", + "rev": "b7d735ffe66a03ab5970e5f860923aada50d4e4c", + "type": "github" + }, + "original": { + "owner": "helix-editor", + "repo": "helix", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -827,6 +851,22 @@ } }, "nixpkgs_4": { + "locked": { + "lastModified": 1740560979, + "narHash": "sha256-Vr3Qi346M+8CjedtbyUevIGDZW8LcA1fTG0ugPY/Hic=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5135c59491985879812717f4c9fea69604e7f26f", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { "locked": { "lastModified": 1742276595, "narHash": "sha256-bsg9y3NoMGu0jgTI5XbxvzQFc9JtZB51i500WlVws80=", @@ -973,13 +1013,14 @@ "flake-parts": "flake-parts_2", "flake-utils": "flake-utils", "garage": "garage", + "helix": "helix", "home-manager": "home-manager", "lanzaboote": "lanzaboote", "lix-module": "lix-module", "nil": "nil", "nix-index-database": "nix-index-database", "nix-ld": "nix-ld", - "nixpkgs": "nixpkgs_4", + "nixpkgs": "nixpkgs_5", "nixpkgs-stable": "nixpkgs-stable_2", "nixvim": "nixvim", "nvim-github-theme": "nvim-github-theme", diff --git a/flake.nix b/flake.nix index b469e18..54a1b90 100644 --- a/flake.nix +++ b/flake.nix @@ -92,6 +92,11 @@ flake-utils.follows = "flake-utils"; }; }; + helix = { + url = "github:helix-editor/helix"; + inputs.flake-utils.follows = "flake-utils"; + inputs.rust-overlay.follows = "rust-overlay"; + }; nvim-github-theme = { url = "github:projekt0n/github-nvim-theme"; diff --git a/home/yt/ytnix.nix b/home/yt/ytnix.nix index 1731475..6ce06ec 100644 --- a/home/yt/ytnix.nix +++ b/home/yt/ytnix.nix @@ -152,4 +152,17 @@ }; programs.nix-index-database.comma.enable = true; + programs.helix = { + enable = true; + settings = { + theme = "github_dark"; + editor = { + line-number = "relative"; + lsp.display-messages = true; + }; + keys.insert = { + "C-[" = "normal_mode"; + }; + }; + }; } diff --git a/overlay/default.nix b/overlay/default.nix index cd9f038..d8780e2 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -24,6 +24,7 @@ in meta.mainProgram = "garage"; } ); + helix = pkgFrom inputs.helix "default"; } ) ] From 8ffe43a4414500d1a11b2d50e5c735e98c051633 Mon Sep 17 00:00:00 2001 From: cy Date: Thu, 20 Mar 2025 16:10:39 -0400 Subject: [PATCH 2/7] attic: always prefer streams --- overlay/attic/prefetch-8-chunks.patch | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/overlay/attic/prefetch-8-chunks.patch b/overlay/attic/prefetch-8-chunks.patch index 3786541..eafc514 100644 --- a/overlay/attic/prefetch-8-chunks.patch +++ b/overlay/attic/prefetch-8-chunks.patch @@ -1,7 +1,16 @@ diff --git a/server/src/api/binary_cache.rs b/server/src/api/binary_cache.rs -index 02e4857..71eeee8 100644 +index 02e4857..b522154 100644 --- a/server/src/api/binary_cache.rs +++ b/server/src/api/binary_cache.rs +@@ -215,7 +215,7 @@ async fn get_nar( + let chunk = chunks[0].as_ref().unwrap(); + let remote_file = &chunk.remote_file.0; + let storage = state.storage().await?; +- match storage.download_file_db(remote_file, false).await? { ++ match storage.download_file_db(remote_file, true).await? { + Download::Url(url) => Ok(Redirect::temporary(&url).into_response()), + Download::AsyncRead(stream) => { + let stream = ReaderStream::new(stream).map_err(|e| { @@ -262,7 +262,7 @@ async fn get_nar( // TODO: Make num_prefetch configurable @@ -11,3 +20,4 @@ index 02e4857..71eeee8 100644 tracing::error!(%e, "Stream error"); e }); + From c67622ba36b205d1d1f8d2ab268142ba538b6157 Mon Sep 17 00:00:00 2001 From: cy Date: Thu, 20 Mar 2025 19:43:22 -0400 Subject: [PATCH 3/7] refactor rclone, use same serviceConfig for all mounts --- hosts/chunk/rclone.nix | 66 ++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/hosts/chunk/rclone.nix b/hosts/chunk/rclone.nix index 09f5b18..31cdf54 100644 --- a/hosts/chunk/rclone.nix +++ b/hosts/chunk/rclone.nix @@ -4,6 +4,32 @@ lib, ... }: +let + mkServiceConfig = remote: mount: { + Type = "notify"; + TimeoutSec = "5min 20s"; + ExecStartPre = "/usr/bin/env mkdir -p ${mount}"; + ExecStart = '' + ${lib.getExe pkgs.rclone} mount \ + --config ${config.sops.secrets."rclone/config".path} \ + --allow-other \ + --cache-dir /var/cache/rclone \ + --transfers 32 \ + --vfs-cache-mode full \ + --vfs-cache-min-free-space 5G \ + --dir-cache-time 30d \ + --no-checksum \ + --no-modtime \ + --vfs-fast-fingerprint \ + --vfs-read-chunk-size 4M \ + --vfs-read-chunk-streams 32 \ + --sftp-concurrency 128 \ + --sftp-chunk-size 255k \ + ${remote} ${mount} + ''; + ExecStop = "${lib.getExe' pkgs.fuse "fusermount"} -zu ${mount}"; + }; +in { systemd.services.immich-mount = { enable = true; @@ -12,21 +38,7 @@ after = [ "network-online.target" ]; requiredBy = [ "podman-immich-server.service" ]; before = [ "podman-immich-server.service" ]; - serviceConfig = { - Type = "notify"; - ExecStartPre = "/usr/bin/env mkdir -p /mnt/photos"; - ExecStart = '' - ${lib.getExe pkgs.rclone} mount \ - --config ${config.sops.secrets."rclone/config".path} \ - --cache-dir /var/cache/rclone \ - --transfers=32 \ - --dir-cache-time 30d \ - --vfs-cache-mode writes \ - --vfs-cache-max-size 2G \ - photos: /mnt/photos - ''; - ExecStop = "${lib.getExe' pkgs.fuse "fusermount"} -u /mnt/photos"; - }; + serviceConfig = mkServiceConfig "photos:" "/mnt/photos"; }; systemd.services.garage-mount = { @@ -36,28 +48,6 @@ after = [ "network-online.target" ]; requiredBy = [ "garage.service" ]; before = [ "garage.service" ]; - serviceConfig = { - Type = "notify"; - ExecStartPre = "/usr/bin/env mkdir -p /mnt/garage"; - ExecStart = '' - ${lib.getExe pkgs.rclone} mount \ - --config ${config.sops.secrets."rclone/config".path} \ - --allow-other \ - --cache-dir /var/cache/rclone \ - --transfers 32 \ - --vfs-cache-mode full \ - --vfs-cache-min-free-space 5G \ - --dir-cache-time 30d \ - --no-checksum \ - --no-modtime \ - --vfs-fast-fingerprint \ - --vfs-read-chunk-size 4M \ - --vfs-read-chunk-streams 64 \ - --sftp-concurrency 128 \ - --sftp-chunk-size 255k \ - rsyncnet:garage /mnt/garage - ''; - ExecStop = "${lib.getExe' pkgs.fuse "fusermount"} -u /mnt/garage"; - }; + serviceConfig = mkServiceConfig "rsyncnet:garage" "/mnt/garage"; }; } From 31e8487a3f1d3fd3671ba47a6749a6117e992585 Mon Sep 17 00:00:00 2001 From: cy Date: Thu, 20 Mar 2025 19:44:29 -0400 Subject: [PATCH 4/7] immich: backup database to disk (not mount) --- hosts/chunk/immich.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hosts/chunk/immich.nix b/hosts/chunk/immich.nix index 6541770..f2636f1 100644 --- a/hosts/chunk/immich.nix +++ b/hosts/chunk/immich.nix @@ -9,6 +9,7 @@ let thumbsLocation = "/opt/immich/thumbs"; profileLocation = "/opt/immich/profile"; dbDataLocation = "/opt/immich/postgres"; + backupsLocation = "/opt/immich/backups"; in { virtualisation.oci-containers.containers = { @@ -21,6 +22,7 @@ in "${uploadLocation}:/usr/src/app/upload" "${thumbsLocation}:/usr/src/app/upload/thumbs" "${profileLocation}:/usr/src/app/upload/profile" + "${backupsLocation}:/usr/src/app/upload/backups" ]; environment = { REDIS_HOSTNAME = "immich-redis"; From 9400279febe41d5283e377fdff61196d4416e2e2 Mon Sep 17 00:00:00 2001 From: cy Date: Thu, 20 Mar 2025 19:44:45 -0400 Subject: [PATCH 5/7] garage: use 128M block_size --- hosts/chunk/garage.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts/chunk/garage.nix b/hosts/chunk/garage.nix index 81b4af3..6a25df2 100644 --- a/hosts/chunk/garage.nix +++ b/hosts/chunk/garage.nix @@ -15,7 +15,7 @@ replication_factor = 1; db_engine = "lmdb"; disable_scrub = true; - block_size = "10M"; + block_size = "128M"; compression_level = "none"; }; environmentFile = config.sops.secrets."garage/env".path; From 55267c5154af54c5eae292bba2a30c51e0923cd1 Mon Sep 17 00:00:00 2001 From: cy Date: Thu, 20 Mar 2025 19:45:22 -0400 Subject: [PATCH 6/7] attic: don't chunk, s3 at localhost, start after garage --- modules/attic.nix | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/attic.nix b/modules/attic.nix index c08afe1..a43d444 100644 --- a/modules/attic.nix +++ b/modules/attic.nix @@ -30,12 +30,31 @@ in type = "s3"; region = "us-east-1"; bucket = "attic"; - endpoint = "https://s3.cy7.sh"; + # attic must be patched to never serve pre-signed s3 urls directly + # otherwise it will redirect clients to this localhost endpoint + endpoint = "http://127.0.0.1:3900"; }; garbage-collection = { default-retention-period = "1 month"; }; + + chunking = { + # disable chunking since garage does its own + nar-size-threshold = 0; + # defaults + min-size = 16384; + avg-size = 65536; + max-size = 262144; + }; + }; + }; + + systemd.services.atticd = { + requires = [ "garage.service" ]; + after = [ "garage.service" ]; + environment = { + RUST_LOG = "INFO"; }; }; From 8c921fc1ab4d703cffd19bee965280845ff1ad24 Mon Sep 17 00:00:00 2001 From: cy Date: Thu, 20 Mar 2025 19:46:04 -0400 Subject: [PATCH 7/7] nixvim: enable yamlls; home/chunk: remove attic-server --- home/nixvim/default.nix | 8 +------- home/yt/chunk.nix | 4 ---- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/home/nixvim/default.nix b/home/nixvim/default.nix index 0ce28d6..5199812 100644 --- a/home/nixvim/default.nix +++ b/home/nixvim/default.nix @@ -167,6 +167,7 @@ installCargo = false; }; eslint.enable = true; + yamlls.enable = true; }; }; plugins.treesitter = { @@ -198,13 +199,6 @@ settings.current_line_blame = true; }; - plugins.copilot-chat = { - enable = true; - settings = { - model = "claude-3.5-sonnet"; - }; - }; - plugins.cmp-buffer.enable = true; plugins.cmp-emoji.enable = true; plugins.cmp-nvim-lsp.enable = true; diff --git a/home/yt/chunk.nix b/home/yt/chunk.nix index ad024cd..474abfc 100644 --- a/home/yt/chunk.nix +++ b/home/yt/chunk.nix @@ -14,8 +14,4 @@ programs.home-manager.enable = true; systemd.user.startServices = "sd-switch"; - - home.packages = with pkgs; [ - attic-server - ]; }