From 5c548b909e8b1e479d7132b600c31f1bd246a0d9 Mon Sep 17 00:00:00 2001 From: Aaron Manning Date: Tue, 15 Sep 2026 18:22:22 +1000 Subject: [PATCH] nixos module --- flake.nix | 15 +++++++++++---- module.nix | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 module.nix diff --git a/flake.nix b/flake.nix index c8b556c..0935017 100644 --- a/flake.nix +++ b/flake.nix @@ -6,9 +6,16 @@ }; outputs = { self, nixpkgs }: - let - system = "x86_64-linux"; - in { - packages.${system}.default = nixpkgs.legacyPackages.${system}.callPackage ./. { }; + let + system = "x86_64-linux"; + package = nixpkgs.legacyPackages.${system}.callPackage ./. { }; + in { + packages.${system}.default = package; + + nixosModules.default = { + imports = [ ./module.nix ]; + + _module.args.package = package; }; + }; } diff --git a/module.nix b/module.nix new file mode 100644 index 0000000..d41d0fb --- /dev/null +++ b/module.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, package, ... }: + +let + cfg = config.custom.minimal-youtube; +in +{ + options.custom.minimal-youtube = { + enable = lib.mkEnableOption "minimal-youtube web app"; + port = lib.mkOption { + type = lib.types.port; + default = 8080; + }; + }; + + config.systemd.services.minimal-youtube = { + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + ExecStart = + "${package}/bin/minimal-youtube --port ${toString cfg.port}"; + + Restart = "always"; + }; + }; +} +