From ab590545184198e6479a8ac1564df2234d8808ef Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 19 Aug 2023 12:34:22 +0200 Subject: [PATCH 1/4] modules: services: rename 'nix-cache' I'm about to modify the module to use a different cache implementation, so this name is more appropriate. --- hosts/nixos/porthos/services.nix | 2 +- modules/services/default.nix | 2 +- modules/services/{nix-serve => nix-cache}/default.nix | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) rename modules/services/{nix-serve => nix-cache}/default.nix (85%) diff --git a/hosts/nixos/porthos/services.nix b/hosts/nixos/porthos/services.nix index 7653eb5..0342864 100644 --- a/hosts/nixos/porthos/services.nix +++ b/hosts/nixos/porthos/services.nix @@ -93,7 +93,7 @@ in enable = true; passwordFile = secrets."nextcloud/password".path; }; - nix-serve = { + nix-cache = { enable = true; secretKeyFile = secrets."nix-serve/cache-key".path; }; diff --git a/modules/services/default.nix b/modules/services/default.nix index 86badf5..b27570d 100644 --- a/modules/services/default.nix +++ b/modules/services/default.nix @@ -20,7 +20,7 @@ ./navidrome ./nextcloud ./nginx - ./nix-serve + ./nix-cache ./paperless ./pirate ./podgrab diff --git a/modules/services/nix-serve/default.nix b/modules/services/nix-cache/default.nix similarity index 85% rename from modules/services/nix-serve/default.nix rename to modules/services/nix-cache/default.nix index 0cf1573..4c04acf 100644 --- a/modules/services/nix-serve/default.nix +++ b/modules/services/nix-cache/default.nix @@ -1,11 +1,11 @@ # Binary cache through nix-serve { config, lib, pkgs, ... }: let - cfg = config.my.services.nix-serve; + cfg = config.my.services.nix-cache; in { - options.my.services.nix-serve = with lib; { - enable = mkEnableOption "nix-serve binary cache"; + options.my.services.nix-cache = with lib; { + enable = mkEnableOption "nix binary cache"; port = mkOption { type = types.port; @@ -16,7 +16,7 @@ in secretKeyFile = mkOption { type = types.str; - example = "/run/secrets/nix-serve"; + example = "/run/secrets/nix-cache"; description = "Secret signing key for the cache"; }; From 19d2916e1c8cdbf48a74026c78d39b1dbd1285df Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 19 Aug 2023 12:36:05 +0200 Subject: [PATCH 2/4] hosts: nixos: porthos: secrets: rename 'nix-cache' To go with the module rename. --- .../secrets/{nix-serve => nix-cache}/cache-key.age | Bin hosts/nixos/porthos/secrets/secrets.nix | 2 +- hosts/nixos/porthos/services.nix | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename hosts/nixos/porthos/secrets/{nix-serve => nix-cache}/cache-key.age (100%) diff --git a/hosts/nixos/porthos/secrets/nix-serve/cache-key.age b/hosts/nixos/porthos/secrets/nix-cache/cache-key.age similarity index 100% rename from hosts/nixos/porthos/secrets/nix-serve/cache-key.age rename to hosts/nixos/porthos/secrets/nix-cache/cache-key.age diff --git a/hosts/nixos/porthos/secrets/secrets.nix b/hosts/nixos/porthos/secrets/secrets.nix index 498aebf..8eac0f5 100644 --- a/hosts/nixos/porthos/secrets/secrets.nix +++ b/hosts/nixos/porthos/secrets/secrets.nix @@ -52,7 +52,7 @@ in publicKeys = all; }; - "nix-serve/cache-key.age".publicKeys = all; + "nix-cache/cache-key.age".publicKeys = all; "paperless/password.age".publicKeys = all; "paperless/secret-key.age".publicKeys = all; diff --git a/hosts/nixos/porthos/services.nix b/hosts/nixos/porthos/services.nix index 0342864..a4bf485 100644 --- a/hosts/nixos/porthos/services.nix +++ b/hosts/nixos/porthos/services.nix @@ -95,7 +95,7 @@ in }; nix-cache = { enable = true; - secretKeyFile = secrets."nix-serve/cache-key".path; + secretKeyFile = secrets."nix-cache/cache-key".path; }; nginx = { enable = true; From 6d9d835e1ce48a45013f846608aa4da55a4fcce0 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 19 Aug 2023 14:16:19 +0200 Subject: [PATCH 3/4] modules: services: nix-cache: use harmonia --- modules/services/nix-cache/default.nix | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/modules/services/nix-cache/default.nix b/modules/services/nix-cache/default.nix index 4c04acf..b3bdbf3 100644 --- a/modules/services/nix-cache/default.nix +++ b/modules/services/nix-cache/default.nix @@ -1,5 +1,5 @@ -# Binary cache through nix-serve -{ config, lib, pkgs, ... }: +# Binary cache +{ config, lib, ... }: let cfg = config.my.services.nix-cache; in @@ -32,19 +32,15 @@ in }; config = lib.mkIf cfg.enable { - services.nix-serve = { + services.harmonia = { enable = true; - bindAddress = "127.0.0.1"; + settings = { + bind = "127.0.0.1:${toString cfg.port}"; + inherit (cfg) priority; + }; - inherit (cfg) - port - secretKeyFile - ; - - package = pkgs.nix-serve-ng; - - extraParams = "--priority=${toString cfg.priority}"; + signKeyPath = cfg.secretKeyFile; }; my.services.nginx.virtualHosts = [ From e4541d4eccec9ec113d4ac53ee14ea450fa80503 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 19 Aug 2023 14:40:54 +0200 Subject: [PATCH 4/4] flake: bump inputs --- flake.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index 658ff11..cdfdef7 100644 --- a/flake.lock +++ b/flake.lock @@ -131,11 +131,11 @@ ] }, "locked": { - "lastModified": 1691856649, - "narHash": "sha256-1/KYCwNyOPpUoyno9Yj3zMHITQaW+wPzVlJFPOPPCo4=", + "lastModified": 1692260837, + "narHash": "sha256-2FpkX1zl+7ni7djK7NeE1ZGupRUwZgjW+RPCSBgDf4k=", "owner": "nix-community", "repo": "home-manager", - "rev": "406d34d919e9e8b831b531782cf5ef6995188566", + "rev": "6a94c1a59737783c282c4031555a289c28b961e4", "type": "github" }, "original": { @@ -147,11 +147,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1691654369, - "narHash": "sha256-gSILTEx1jRaJjwZxRlnu3ZwMn1FVNk80qlwiCX8kmpo=", + "lastModified": 1692356644, + "narHash": "sha256-AYkPFT+CbCVSBmh0WwIzPpwhEJ4Yy3A7JZvUkGJIg5o=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ce5e4a6ef2e59d89a971bc434ca8ca222b9c7f5e", + "rev": "8ecc900b2f695d74dea35a92f8a9f9b32c8ea33d", "type": "github" }, "original": { @@ -163,11 +163,11 @@ }, "nur": { "locked": { - "lastModified": 1691871985, - "narHash": "sha256-xSuUcMfHQO/GlZsGXHcJpi/22XsrRmw99usQx53bdCw=", + "lastModified": 1692437027, + "narHash": "sha256-gWtVFoPw7HhbKGLp7vupVbCNAvNMQS5+2PujOt2QbRk=", "owner": "nix-community", "repo": "NUR", - "rev": "107240729dc0fdd4afa1728aaa03d1df0d70a2e8", + "rev": "b47c7b8d313f9739a7fbb572413c959a362c244a", "type": "github" }, "original": { @@ -192,11 +192,11 @@ ] }, "locked": { - "lastModified": 1691747570, - "narHash": "sha256-J3fnIwJtHVQ0tK2JMBv4oAmII+1mCdXdpeCxtIsrL2A=", + "lastModified": 1692274144, + "narHash": "sha256-BxTQuRUANQ81u8DJznQyPmRsg63t4Yc+0kcyq6OLz8s=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "c5ac3aa3324bd8aebe8622a3fc92eeb3975d317a", + "rev": "7e3517c03d46159fdbf8c0e5c97f82d5d4b0c8fa", "type": "github" }, "original": {