Add nixos module
This commit is contained in:
parent
1b9d4854c6
commit
4fbec8744a
57
flake.nix
57
flake.nix
|
|
@ -7,6 +7,13 @@
|
||||||
|
|
||||||
outputs = { self, nixpkgs }: nixpkgs.lib.foldAttrs (item: acc: item // acc) { } (map
|
outputs = { self, nixpkgs }: nixpkgs.lib.foldAttrs (item: acc: item // acc) { } (map
|
||||||
(system: with nixpkgs.legacyPackages."${system}"; {
|
(system: with nixpkgs.legacyPackages."${system}"; {
|
||||||
|
devShells."${system}".default = mkShell {
|
||||||
|
nativeBuildInputs = [
|
||||||
|
nodejs_20
|
||||||
|
tmux
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
packages."${system}".default = buildNpmPackage {
|
packages."${system}".default = buildNpmPackage {
|
||||||
pname = "todo-list";
|
pname = "todo-list";
|
||||||
version = "1.0.0";
|
version = "1.0.0";
|
||||||
|
|
@ -18,11 +25,53 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells."${system}".default = mkShell {
|
nixosModules.default = { config, lib, ... }:
|
||||||
nativeBuildInputs = [
|
let
|
||||||
nodejs_20
|
inherit (lib) mkEnableOption mkIf mkOption mkMerge types recursiveUpdate mkForce;
|
||||||
tmux
|
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" ]);
|
}) [ "x86_64-linux" "aarch64-linux" ]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue