working module

Signed-off-by: Xe <me@christine.website>
This commit is contained in:
Cadey Ratio 2022-03-26 17:37:12 +00:00
parent 7dc0421ed8
commit 1918359fd8
2 changed files with 12 additions and 10 deletions

View File

@ -66,11 +66,17 @@
};
};
defaultApp = utils.lib.mkApp { drv = self.packages.${system}.default; };
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [ go gopls gotools go-tools ];
};
}) // {
nixosModule = { config, lib, pkgs, ... }:
with lib;
let cfg = config.xeserv.services.gohello-http;
let cfg = config.xeserv.services.gohello;
in {
options.xeserv.services.gohello-http = {
options.xeserv.services.gohello = {
enable = mkEnableOption "Enables the gohello HTTP service";
domain = mkOption rec {
@ -85,7 +91,7 @@
systemd.services."xeserv.gohello" = {
wantedBy = [ "multi-user.target" ];
serviceConfig = let pkg = pkgs.hello; #self.packages.${system}.default;
serviceConfig = let pkg = self.packages.${pkgs.system}.default;
in {
Restart = "on-failure";
ExecStart = "${pkg}/bin/web-server";
@ -104,12 +110,7 @@
};
};
};
defaultApp = utils.lib.mkApp { drv = self.packages.${system}.default; };
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [ go gopls gotools go-tools ];
};
}) // {
nixosConfigurations.container = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
@ -122,6 +123,8 @@
networking.firewall.allowedTCPPorts = [ 80 ];
services.nginx.enable = true;
xeserv.services.gohello.enable = true;
})
];
};

View File

@ -5,7 +5,6 @@ import (
"fmt"
"log"
"net/http"
"os"
)
var (
@ -16,7 +15,7 @@ func main() {
flag.Parse()
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "PORTABLE=%s\n", os.Getenv("PORTABLE"))
fmt.Fprintln(w, "hello world :)")
})
log.Printf("listening for HTTP on %s", *bindhost)