From 03df443aa8feb2a444f01368d425f24937f060a8 Mon Sep 17 00:00:00 2001 From: Werner Kroneman Date: Thu, 5 Dec 2024 15:33:12 +0200 Subject: [PATCH] Added sharkey-service nixos module --- flake.nix | 31 ++----------------------------- sharkey-service.nix | 7 +++++-- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/flake.nix b/flake.nix index e32d28bea5..eb09f76208 100644 --- a/flake.nix +++ b/flake.nix @@ -3,36 +3,9 @@ outputs = { self, nixpkgs }: { - nixosConfigurations.container = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = - [ - ( import ./sharkey-service.nix ) - ({ pkgs, ... }: { - boot.isContainer = true; + nixosModules.sharkey-service = args : import ./sharkey-service.nix ( args // { sharkey = self.packages.sharkey; } ); - # Let 'nixos-version --json' know about the Git revision - # of this flake. - system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; - - # Network configuration. - networking.useDHCP = false; - networking.firewall.allowedTCPPorts = [ 3000 ]; - - system.stateVersion = "24.04"; - - services.sharkey = { - enable = true; - package = (pkgs.callPackage ./sharkey.nix {}); - settings = { - url = "https://sharkey.localhost"; - }; - redis.createLocally = true; - database.createLocally = true; - }; - }) - ]; - }; + packages."x86_64-linux".sharkey = nixpkgs.legacyPackages."x86_64-linux".callPackage ./sharkey.nix { }; }; } diff --git a/sharkey-service.nix b/sharkey-service.nix index 4f5551086c..64fa85fb6a 100644 --- a/sharkey-service.nix +++ b/sharkey-service.nix @@ -2,6 +2,7 @@ config, pkgs, lib, + sharkey, ... }: @@ -186,9 +187,11 @@ in { options = { + + + services.sharkey = { enable = lib.mkEnableOption "sharkey"; - package = (pkgs.callPackage ./sharkey.nix { }); inherit settings; database = { createLocally = lib.mkOption { @@ -340,7 +343,7 @@ in ${pkgs.replace-secret}/bin/replace-secret '@MEILISEARCH_KEY@' "${cfg.meilisearch.keyFile}" /run/sharkey/default.yml ''); serviceConfig = { - ExecStart = "${cfg.package}/bin/sharkey migrateandstart"; + ExecStart = "${sharkey}/bin/sharkey migrateandstart"; RuntimeDirectory = "sharkey"; RuntimeDirectoryMode = "700"; StateDirectory = "sharkey";