Skip to content

Commit

Permalink
Merge pull request #67 from epics-extensions/nixos-23.11
Browse files Browse the repository at this point in the history
NixOS 23.11
  • Loading branch information
minijackson committed May 23, 2024
2 parents 60bafc4 + f6b9a09 commit 2ec05c0
Show file tree
Hide file tree
Showing 18 changed files with 248 additions and 106 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ outputs
# Some files generated by CI, to ensure the working tree is clean on CI
/manpage
/public

# Created by running IOCs
.iocsh_history

# Created by running NixOS tests in interactive mode
.nixos-test-history
2 changes: 1 addition & 1 deletion doc/nixos/guides/_pre-requisites.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ For example:
``` {.diff filename="flake.nix"}
{
# ...
+ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
+ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
+ inputs.epnix.url = "github:epics-extensions/EPNix";

# ...
Expand Down
74 changes: 40 additions & 34 deletions doc/nixos/guides/phoebus-alarm.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ The Phoebus Alarm Logging Service can also be called the Phoebus Alarm Logger.
# Single server Phoebus Alarm setup

To configure Phoebus Alarm, Phoebus Alarm Logger, Apache Kafka, and ElasticSearch on a single server,
add this to your configuration:
add this to your configuration,
while taking care of replacing the IP address
and Kafka's `clusterId`:

``` nix
{config, lib, ...}: let
kafkaPort = toString config.services.apache-kafka.port;
# Replace this with your machine's IP address
{lib, pkgs, ...}: let
# Replace this with your machine's external IP address
# or DNS domain name
ip = "192.168.1.42";
kafkaListenSockAddr = "${ip}:${kafkaPort}";
kafkaListenSockAddr = "${ip}:9092";
kafkaControllerListenSockAddr = "${ip}:9093";
in {
# The Phoebus Alarm server also automatically enables the Phoebus Alarm Logger
services.phoebus-alarm-server = {
Expand All @@ -48,43 +50,48 @@ in {
services.phoebus-alarm-logger.settings."bootstrap.servers" = kafkaListenSockAddr;
services.elasticsearch = {
enable = true;
package = pkgs.elasticsearch7;
};
# Single-server Kafka setup
services.apache-kafka = {
enable = true;
logDirs = ["/var/lib/apache-kafka"];
# Tell Apache Kafka to listen on this IP address
# If you don't have a DNS domain name, it's best to set a specific, non-local IP address.
extraProperties = ''
listeners=PLAINTEXT://${kafkaListenSockAddr}
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
'';
# Replace with a randomly generated uuid. You can get one by running:
# nix shell 'nixpkgs#apacheKafka' -c kafka-storage.sh random-uuid
clusterId = "xxxxxxxxxxxxxxxxxxxxxx";
formatLogDirs = true;
settings = {
listeners = [
"PLAINTEXT://${kafkaListenSockAddr}"
"CONTROLLER://${kafkaControllerListenSockAddr}"
];
# Adapt depending on your security constraints
"listener.security.protocol.map" = [
"PLAINTEXT:PLAINTEXT"
"CONTROLLER:PLAINTEXT"
];
"controller.quorum.voters" = [
"1@${kafkaControllerListenSockAddr}"
];
"controller.listener.names" = ["CONTROLLER"];
"node.id" = 1;
"process.roles" = ["broker" "controller"];
"log.dirs" = ["/var/lib/apache-kafka"];
"offsets.topic.replication.factor" = 1;
"transaction.state.log.replication.factor" = 1;
"transaction.state.log.min.isr" = 1;
};
};
systemd.services.apache-kafka = {
after = ["zookeeper.service"];
unitConfig.StateDirectory = "apache-kafka";
};
systemd.services.apache-kafka.unitConfig.StateDirectory = "apache-kafka";
# Open kafka to the outside world
networking.firewall.allowedTCPPorts = [9092];
services.zookeeper = {
services.elasticsearch = {
enable = true;
extraConf = ''
# Port conflicts by default with phoebus-alarm-logger's port
admin.enableServer=false
'';
package = pkgs.elasticsearch7;
};
# Open kafka to the outside world
networking.firewall.allowedTCPPorts = [
config.services.apache-kafka.port
];
# Elasticsearch, needed by Phoebus Alarm Logger, is not free software (SSPL | Elastic License).
# To accept the license, add the code below:
nixpkgs.config.allowUnfreePredicate = pkg:
Expand Down Expand Up @@ -205,4 +212,3 @@ Here is a list of options you might want to set:
::: callout-warning
Currently, Phoebus Alarm Server only supports plain SMTP.
:::

8 changes: 2 additions & 6 deletions doc/nixos/tutorials/archiver-appliance.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Fill the file with these lines:
{
description = "Configuration for running Archiver Appliance in a VM";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
inputs.epnix.url = "github:epics-extensions/EPNix";
outputs = { self, nixpkgs, epnix }: {
Expand All @@ -72,11 +72,7 @@ Fill the file with these lines:
}
```

```{=html}
<!-- TODO: replace raw html with the kbd shortcode once we are using Quarto 1.3 -->
<!-- https://quarto.org/docs/authoring/markdown-basics.html#keyboard-shortcuts -->
```
Save and quit by typing `<kbd>`{=html}Ctrl-x`</kbd>`{=html}, `<kbd>`{=html}y`</kbd>`{=html}, and `<kbd>`{=html}Enter`</kbd>`{=html},
Save and quit by typing {{< kbd Ctrl-x >}}, {{< kbd y >}}, and {{< kbd Enter >}},
and run `nixos-rebuild test` to test your changes.

Some explanations:
Expand Down
124 changes: 119 additions & 5 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 17 additions & 7 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{
description = "A Nix flake containing EPICS-related modules and packages";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
inputs.bash-lib = {
url = "github:minijackson/bash-lib";
inputs.nixpkgs.follows = "nixpkgs";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
bash-lib = {
url = "github:minijackson/bash-lib";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
inputs.flake-utils.url = "github:numtide/flake-utils";

outputs = {
self,
Expand All @@ -19,7 +25,11 @@
systemDependentOutputs = system: let
pkgs = import nixpkgs {
inherit system;
overlays = [overlay inputs.bash-lib.overlay];
overlays = [
overlay
inputs.bash-lib.overlay
inputs.poetry2nix.overlays.default
];
};
in {
packages = flake-utils.lib.flattenTree pkgs.epnix;
Expand All @@ -46,7 +56,7 @@
category = "development tools";
}
{
package = pkgs.quarto;
package = pkgs.quartoMinimal;
category = "development tools";
}
{
Expand Down
6 changes: 5 additions & 1 deletion ioc/modules/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ with lib; {
};

config = {
nixpkgs.overlays = [epnix.inputs.bash-lib.overlay epnix.overlays.default];
nixpkgs.overlays = [
epnix.inputs.poetry2nix.overlays.default
epnix.inputs.bash-lib.overlay
epnix.overlays.default
];
};
}
2 changes: 0 additions & 2 deletions nixos/modules/phoebus/alarm-logger.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ in {
"bootstrap.servers" = lib.mkOption {
description = "Location of the Kafka server";
type = lib.types.str;
default = "localhost:${toString config.services.apache-kafka.port}";
defaultText = lib.literalExpression ''"localhost:''${toString config.services.apache-kafka.port}"'';
};

date_span_units = lib.mkOption {
Expand Down
2 changes: 0 additions & 2 deletions nixos/modules/phoebus/alarm-server.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ in {
"org.phoebus.applications.alarm/server" = lib.mkOption {
description = "Kafka server host:port";
type = lib.types.str;
default = "localhost:${toString config.services.apache-kafka.port}";
defaultText = lib.literalExpression ''"localhost:''${toString config.services.apache-kafka.port}"'';
};

# Waiting for: https://github.com/ControlSystemStudio/phoebus/issues/2843
Expand Down
Loading

0 comments on commit 2ec05c0

Please sign in to comment.