abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authorpatrick-scho2025-04-08 21:42:32 +0200
committerpatrick-scho2025-04-08 21:42:32 +0200
commit4eda259f142c2ba004e9182ec196f50999e562aa (patch)
tree9f36a7d5e4d26acb02a5877b72d8b8768a36ad28
parent1bdd1b40fbab8e6844d0fa834b15f733056365ee (diff)
downloadchirp-4eda259f142c2ba004e9182ec196f50999e562aa.tar.gz
chirp-4eda259f142c2ba004e9182ec196f50999e562aa.zip
add flake.nix
-rw-r--r--flake.nix56
1 files changed, 56 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..fd691a8
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,56 @@
+{
+ description = "Chirp!";
+
+ inputs = {
+ zig.url = "github:mitchellh/zig-overlay";
+ };
+
+ outputs = {
+ self,
+ zig,
+ pkgs,
+ }: let
+ nixosModule = {
+ config,
+ lib,
+ pkgs,
+ ...
+ }: {
+ options.services.chirp = {
+ enable = lib.mkEnableOption "Chirp";
+
+ port = lib.mkOption {
+ type = lib.types.port;
+ default = 8080;
+ description = "Port to listen on";
+ };
+ };
+
+ config = lib.mkIf config.services.chirp.enable {
+ systemd.services.chirp = {
+ description = "Chirp SystemD Service!";
+ wantedBy = ["multi-user.target"];
+ after = ["network.target"];
+ serviceConfig = {
+ ExecStart = "${zig.packages.master}";
+ Restart = "always";
+ Type = "simple";
+ DynamicUser = "yes";
+ };
+ environment = {
+ PORT = toString config.services.chirp.port;
+ };
+ };
+ };
+ };
+ in {
+ # TODO: packages.default build
+ apps.default = {
+ type = "app";
+ program = "${zig.packages.${pkgs.system}."0.14.0"} build run";
+ };
+ }
+ // {
+ nixosModules.default = nixosModule;
+ };
+}