diff --git a/flake.nix b/flake.nix index 871153ec..ee525ef7 100644 --- a/flake.nix +++ b/flake.nix @@ -200,52 +200,6 @@ }; }); - nixosModules.appview = { - config, - pkgs, - lib, - ... - }: - with lib; { - options = { - services.tangled-appview = { - enable = mkOption { - type = types.bool; - default = false; - description = "Enable tangled appview"; - }; - port = mkOption { - type = types.int; - default = 3000; - description = "Port to run the appview on"; - }; - cookie_secret = mkOption { - type = types.str; - default = "00000000000000000000000000000000"; - description = "Cookie secret"; - }; - }; - }; - - config = mkIf config.services.tangled-appview.enable { - systemd.services.tangled-appview = { - description = "tangled appview service"; - wantedBy = ["multi-user.target"]; - - serviceConfig = { - ListenStream = "0.0.0.0:${toString config.services.tangled-appview.port}"; - ExecStart = "${self.packages.${pkgs.system}.appview}/bin/appview"; - Restart = "always"; - }; - - environment = { - TANGLED_DB_PATH = "appview.db"; - TANGLED_COOKIE_SECRET = config.services.tangled-appview.cookie_secret; - }; - }; - }; - }; - nixosModules.knot = { config, pkgs, @@ -448,5 +402,6 @@ }) ]; }; + nixosModules.appview = import ./nix/modules/appview.nix {inherit self;}; }; } diff --git a/nix/modules/appview.nix b/nix/modules/appview.nix new file mode 100644 index 00000000..0b7fe908 --- /dev/null +++ b/nix/modules/appview.nix @@ -0,0 +1,45 @@ +{self}: { + config, + pkgs, + lib, + ... +}: +with lib; { + options = { + services.tangled-appview = { + enable = mkOption { + type = types.bool; + default = false; + description = "Enable tangled appview"; + }; + port = mkOption { + type = types.int; + default = 3000; + description = "Port to run the appview on"; + }; + cookie_secret = mkOption { + type = types.str; + default = "00000000000000000000000000000000"; + description = "Cookie secret"; + }; + }; + }; + + config = mkIf config.services.tangled-appview.enable { + systemd.services.tangled-appview = { + description = "tangled appview service"; + wantedBy = ["multi-user.target"]; + + serviceConfig = { + ListenStream = "0.0.0.0:${toString config.services.tangled-appview.port}"; + ExecStart = "${self.packages.${pkgs.system}.appview}/bin/appview"; + Restart = "always"; + }; + + environment = { + TANGLED_DB_PATH = "appview.db"; + TANGLED_COOKIE_SECRET = config.services.tangled-appview.cookie_secret; + }; + }; + }; +}