flake.nix,nix/modules: add package option for all the nixos modules #334

merged
opened by ptr.pet targeting master from ptr.pet/core: master
Changed files
+84 -47
nix
+27 -3
flake.nix
···
};
});
-
nixosModules.appview = import ./nix/modules/appview.nix {inherit self;};
-
nixosModules.knot = import ./nix/modules/knot.nix {inherit self;};
-
nixosModules.spindle = import ./nix/modules/spindle.nix {inherit self;};
+
nixosModules.appview = {
+
lib,
+
pkgs,
+
...
+
}: {
+
imports = [./nix/modules/appview.nix];
+
+
services.tangled-appview.package = lib.mkDefault self.packages.${pkgs.system}.appview;
+
};
+
nixosModules.knot = {
+
lib,
+
pkgs,
+
...
+
}: {
+
imports = [./nix/modules/knot.nix];
+
+
services.tangled-knot.package = lib.mkDefault self.packages.${pkgs.system}.knot;
+
};
+
nixosModules.spindle = {
+
lib,
+
pkgs,
+
...
+
}: {
+
imports = [./nix/modules/spindle.nix];
+
+
services.tangled-spindle.package = lib.mkDefault self.packages.${pkgs.system}.spindle;
+
};
nixosConfigurations.vm = import ./nix/vm.nix {inherit self nixpkgs;};
};
}
+40 -35
nix/modules/appview.nix
···
-
{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";
+
}: let
+
cfg = config.services.tangled-appview;
+
in
+
with lib; {
+
options = {
+
services.tangled-appview = {
+
enable = mkOption {
+
type = types.bool;
+
default = false;
+
description = "Enable tangled appview";
+
};
+
package = mkOption {
+
type = types.package;
+
description = "Package to use for the 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"];
+
config = mkIf cfg.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";
-
};
+
serviceConfig = {
+
ListenStream = "0.0.0.0:${toString cfg.port}";
+
ExecStart = "${cfg.package}/bin/appview";
+
Restart = "always";
+
};
-
environment = {
-
TANGLED_DB_PATH = "appview.db";
-
TANGLED_COOKIE_SECRET = config.services.tangled-appview.cookie_secret;
+
environment = {
+
TANGLED_DB_PATH = "appview.db";
+
TANGLED_COOKIE_SECRET = cfg.cookie_secret;
+
};
};
};
-
};
-
}
+
}
+11 -6
nix/modules/knot.nix
···
-
{self}: {
+
{
config,
pkgs,
lib,
···
description = "Enable a tangled knot";
};
+
package = mkOption {
+
type = types.package;
+
description = "Package to use for the knot";
+
};
+
appviewEndpoint = mkOption {
type = types.str;
default = "https://tangled.sh";
···
};
config = mkIf cfg.enable {
-
environment.systemPackages = with pkgs; [
-
git
-
self.packages."${pkgs.system}".knot
+
environment.systemPackages = [
+
pkgs.git
+
cfg.package
];
system.activationScripts.gitConfig = ''
···
mode = "0555";
text = ''
#!${pkgs.stdenv.shell}
-
${self.packages.${pkgs.system}.knot}/bin/knot keys \
+
${cfg.package}/bin/knot keys \
-output authorized-keys \
-internal-api "http://${cfg.server.internalListenAddr}" \
-git-dir "${cfg.repo.scanPath}" \
···
"KNOT_SERVER_HOSTNAME=${cfg.server.hostname}"
];
EnvironmentFile = cfg.server.secretFile;
-
ExecStart = "${self.packages.${pkgs.system}.knot}/bin/knot server";
+
ExecStart = "${cfg.package}/bin/knot server";
Restart = "always";
};
};
+6 -3
nix/modules/spindle.nix
···
-
{self}: {
+
{
config,
-
pkgs,
lib,
...
}: let
···
default = false;
description = "Enable a tangled spindle";
};
+
package = mkOption {
+
type = types.package;
+
description = "Package to use for the spindle";
+
};
server = {
listenAddr = mkOption {
···
"SPINDLE_PIPELINES_NIXERY=${cfg.pipelines.nixery}"
"SPINDLE_PIPELINES_WORKFLOW_TIMEOUT=${cfg.pipelines.workflowTimeout}"
];
-
ExecStart = "${self.packages.${pkgs.system}.spindle}/bin/spindle";
+
ExecStart = "${cfg.package}/bin/spindle";
Restart = "always";
};
};