1
0
Fork 0

Add nixos module

This commit is contained in:
Tomas Balsys 2024-10-27 04:36:17 +02:00
parent 1b9d4854c6
commit 4fbec8744a
1 changed files with 55 additions and 6 deletions

View File

@ -7,6 +7,13 @@
outputs = { self, nixpkgs }: nixpkgs.lib.foldAttrs (item: acc: item // acc) { } (map
(system: with nixpkgs.legacyPackages."${system}"; {
devShells."${system}".default = mkShell {
nativeBuildInputs = [
nodejs_20
tmux
];
};
packages."${system}".default = buildNpmPackage {
pname = "todo-list";
version = "1.0.0";
@ -18,11 +25,53 @@
'';
};
devShells."${system}".default = mkShell {
nativeBuildInputs = [
nodejs_20
tmux
nixosModules.default = { config, lib, ... }:
let
inherit (lib) mkEnableOption mkIf mkOption mkMerge types recursiveUpdate mkForce;
cfg = config.services.todo-list;
in
{
options.services.todo-list = {
enable = mkEnableOption "Todo list";
hostname = mkOption {
type = types.str;
example = "todo.example.com";
description = "The hostname to serve site on.";
};
nginx = mkOption {
type = types.submodule (
recursiveUpdate
(import (nixpkgs + "/nixos/modules/services/web-servers/nginx/vhost-options.nix") { inherit config lib; })
{ }
);
default = { };
example = ''
{
serverAliases = [
"list.''${config.networking.domain}"
];
# To enable encryption and let let's encrypt take care of certificate
forceSSL = true;
enableACME = true;
}
'';
description = ''
With this option, you can customize the nginx virtualHost settings.
'';
};
};
config = mkIf cfg.enable {
services.nginx.virtualHosts.${cfg.hostname} = mkMerge [
cfg.nginx
{
root = mkForce self.packages."${system}".default;
locations."/".tryFiles = "$uri $uri/ /index.html";
}
];
};
};
}) [ "x86_64-linux" "aarch64-linux" ]);
}