blob: 9a8ec32e7af370733045191ea97af8b881ac8dfd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
{
description = "systemd-networkd Web UI (Go + HTML/JS)";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
# Kehitysympäristö
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
go_1_24
gopls # LSP-tuki
];
shellHook = ''
echo "Development shell for systemd-networkd Web UI"
echo "Go version: $(go version)"
'';
};
# Sovelluksen buildattava paketti
packages.default = pkgs.buildGoModule {
pname = "networkd-webui";
version = "0.1.0";
src = ./.;
vendorHash = null; # täytetään `nix develop` -> `go mod vendor` -> `nix hash`
subPackages = [ "." ];
ldflags = [ "-s" "-w" ];
};
# Deploymenttiin tarkoitettu NixOS service module
nixosModules.default = { config, pkgs, lib, ... }: {
options.services.networkd-webui = {
enable = lib.mkEnableOption "systemd-networkd Web UI";
port = lib.mkOption {
type = lib.types.port;
default = 8080;
description = "Port for the web UI.";
};
};
config = lib.mkIf config.services.networkd-webui.enable {
systemd.services.networkd-webui = {
description = "systemd-networkd Web UI";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${self.packages.${system}.default}/bin/networkd-webui -port ${toString config.services.networkd-webui.port}";
Restart = "on-failure";
DynamicUser = true;
ProtectSystem = "strict";
ProtectHome = true;
NoNewPrivileges = true;
};
};
};
};
});
}
|