From ba58283f1f2485605887395d1cfbe48fbaddcb38 Mon Sep 17 00:00:00 2001 From: Rouven Seifert Date: Mon, 23 Oct 2023 10:12:21 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8nixify=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.lock | 25 +++++++++++++++++++++++++ flake.nix | 43 +++++++++++++++++++++++++++++++++++++++++++ module.nix | 28 ++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 module.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ad709eb --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1697915759, + "narHash": "sha256-WyMj5jGcecD+KC8gEs+wFth1J1wjisZf8kVZH13f1Zo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "51d906d2341c9e866e48c2efcaac0f2d70bfd43e", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..18f00bb --- /dev/null +++ b/flake.nix @@ -0,0 +1,43 @@ +{ + description = "iFSR Manual"; + + outputs = { self, nixpkgs }: + let + supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system}); + in + { + + overlays.default = (_final: prev: { + inherit (self.packages.${prev.system}) ese-manual; + }); + + nixosModules.default = { + imports = [ ./module.nix ]; + + nixpkgs.overlays = [ self.overlays.default ]; + }; + + packages = forAllSystems (system: rec { + + default = ese-manual; + + ese-manual = pkgs.${system}.stdenvNoCC.mkDerivation { + name = "ese-manual"; + src = ./.; + buildInputs = with pkgs.${system}.python3Packages; [ + mkdocs-material + ]; + # phases = [ "unpackPhase" "installPhase" ]; + buildPhase = '' + mkdocs build + ''; + installPhase = '' + mkdir -p $out + cp -r site/* $out + ''; + }; + }); + }; +} diff --git a/module.nix b/module.nix new file mode 100644 index 0000000..e99231b --- /dev/null +++ b/module.nix @@ -0,0 +1,28 @@ +{ lib, pkgs, config, ... }: +let + cfg = config.services.ese-manual; +in +{ + options.services.kpp = { + enable = mkEnableOption "ese-manual"; + hostName = mkOption { + type = types.nullOr types.str; + default = null; + example = "manual.example.com"; + description = '' + The hostname the application should be served on. + If it is `null`, nginx will not be automatically configured. + ''; + }; + + }; + + config = lib.mkIf cfg.enable { + services.nginx = lib.mkIf (cfg.hostName != null) { + enable = true; + virtualHosts.${cfg.hostName} = { + root = pkgs.ese-manual; + }; + }; + }; +}