{ description = "Development environment flake"; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; }; 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"; src = ./.; npmDepsHash = "sha256-CAV5SbdfW0+eOeCHPquAJioFRqaxMY7MMMkip+1y0Nc="; installPhase = '' mkdir -p $out cp -r dist/. $out ''; }; 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" ]); }