-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add nixos module for the store
Signed-off-by: Brian McGee <[email protected]>
- Loading branch information
1 parent
acc3291
commit c55d77f
Showing
7 changed files
with
94 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
} { | ||
imports = [ | ||
./nix | ||
./nixos | ||
]; | ||
systems = [ | ||
"x86_64-linux" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
flake.nixosModules = { | ||
store = import ./store.nix; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
lib, | ||
pkgs, | ||
config, | ||
... | ||
}: let | ||
cfg = config.services.nvix.store; | ||
in { | ||
options.services.nvix.store = with lib; { | ||
enable = mkEnableOption (mdDoc "Enable NVIX Store"); | ||
package = mkOption { | ||
type = types.package; | ||
default = pkgs.nvix; | ||
defaultText = literalExpression "pkgs.nvix"; | ||
description = mdDoc "Package to use for nits."; | ||
}; | ||
listen = { | ||
address = mkOption { | ||
type = types.str; | ||
default = "localhost:5000"; | ||
description = "interface and port to listen on"; | ||
}; | ||
}; | ||
metrics = { | ||
address = mkOption { | ||
type = types.str; | ||
default = "localhost:5050"; | ||
description = "interface and port to listen on"; | ||
}; | ||
}; | ||
nats = { | ||
url = mkOption { | ||
type = types.str; | ||
example = "nats://localhost:4222"; | ||
description = mdDoc "NATS server url."; | ||
}; | ||
credentialsFile = mkOption { | ||
type = types.path; | ||
example = "/mnt/shared/user.creds"; | ||
description = mdDoc "Path to a file containing a NATS credentials file"; | ||
}; | ||
}; | ||
verbosity = mkOption { | ||
type = types.int; | ||
default = 1; | ||
example = "2"; | ||
description = mdDoc "Selects the log verbosity."; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
systemd.services.nvix-store = { | ||
after = ["network.target"]; | ||
wantedBy = ["sysinit.target"]; | ||
|
||
description = "NVIX Store"; | ||
startLimitIntervalSec = 0; | ||
|
||
# the agent will restart itself after a successful deployment | ||
restartIfChanged = false; | ||
|
||
environment = lib.filterAttrs (_: v: v != null) { | ||
NATS_URL = cfg.nats.url; | ||
NATS_CREDENTIALS_FILE = cfg.nats.credentialsFile; | ||
LISTEN_ADDRESS = cfg.listen.address; | ||
METRICS_ADDRESS = cfg.metrics.address; | ||
LOG_LEVEL = "${builtins.toString cfg.verbosity}"; | ||
}; | ||
|
||
serviceConfig = with lib; { | ||
Restart = mkDefault "on-failure"; | ||
RestartSec = 1; | ||
|
||
User = "nvix-store"; | ||
DynamicUser = true; | ||
StateDirectory = "nvix-store"; | ||
ExecStart = "${cfg.package}/bin/nvix store"; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters