nixify

This commit is contained in:
Rouven Seifert 2023-10-23 10:12:21 +02:00
parent e5dc6d7e46
commit ba58283f1f
Signed by untrusted user: rouven.seifert
GPG key ID: B95E8FE6B11C4D09
3 changed files with 96 additions and 0 deletions

25
flake.lock Normal file
View file

@ -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
}

43
flake.nix Normal file
View file

@ -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
'';
};
});
};
}

28
module.nix Normal file
View file

@ -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;
};
};
};
}