Compare commits

...

7 commits

11 changed files with 124 additions and 53 deletions

43
flake.lock generated
View file

@ -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",

View file

@ -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";

View file

@ -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;

View file

@ -14,8 +14,4 @@
programs.home-manager.enable = true;
systemd.user.startServices = "sd-switch";
home.packages = with pkgs; [
attic-server
];
}

View file

@ -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";
};
};
};
}

View file

@ -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;

View file

@ -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";

View file

@ -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";
};
}

View file

@ -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";
};
};

View file

@ -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
});

View file

@ -24,6 +24,7 @@ in
meta.mainProgram = "garage";
}
);
helix = pkgFrom inputs.helix "default";
}
)
]