parent
7dc0421ed8
commit
1918359fd8
19
flake.nix
19
flake.nix
|
@ -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, ... }:
|
nixosModule = { config, lib, pkgs, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
let cfg = config.xeserv.services.gohello-http;
|
let cfg = config.xeserv.services.gohello;
|
||||||
in {
|
in {
|
||||||
options.xeserv.services.gohello-http = {
|
options.xeserv.services.gohello = {
|
||||||
enable = mkEnableOption "Enables the gohello HTTP service";
|
enable = mkEnableOption "Enables the gohello HTTP service";
|
||||||
|
|
||||||
domain = mkOption rec {
|
domain = mkOption rec {
|
||||||
|
@ -85,7 +91,7 @@
|
||||||
systemd.services."xeserv.gohello" = {
|
systemd.services."xeserv.gohello" = {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
serviceConfig = let pkg = pkgs.hello; #self.packages.${system}.default;
|
serviceConfig = let pkg = self.packages.${pkgs.system}.default;
|
||||||
in {
|
in {
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
ExecStart = "${pkg}/bin/web-server";
|
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 {
|
nixosConfigurations.container = nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [
|
modules = [
|
||||||
|
@ -122,6 +123,8 @@
|
||||||
networking.firewall.allowedTCPPorts = [ 80 ];
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||||
|
|
||||||
services.nginx.enable = true;
|
services.nginx.enable = true;
|
||||||
|
|
||||||
|
xeserv.services.gohello.enable = true;
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
3
main.go
3
main.go
|
@ -5,7 +5,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -16,7 +15,7 @@ func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
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)
|
log.Printf("listening for HTTP on %s", *bindhost)
|
||||||
|
|
Loading…
Reference in New Issue