mirror of
https://github.com/tuxdotrs/trok.git
synced 2026-09-19 15:09:03 +05:30
Compare commits
2 Commits
6c13858d46
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
adf7c84269
|
|||
|
a86a290e88
|
57
flake.lock
generated
57
flake.lock
generated
@@ -1,5 +1,23 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1788450739,
|
||||
"narHash": "sha256-glZLQlzIn1fXH6PazR2iUmTo7kzzyYSshrWhLS9TqCU=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "31729ca8cbdb4fa927b34e5f4353e6a83f39e993",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1740547748,
|
||||
@@ -16,9 +34,46 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1788057806,
|
||||
"narHash": "sha256-DTQSMxzDWmT0zhguthvegnVkn7CFqGCv4IHCzk5ZUpM=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "596e2e3940e09b2abbeb03f75fa1828c57fcd72c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
}
|
||||
},
|
||||
"treefmt-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1786901030,
|
||||
"narHash": "sha256-WSFCsDSE5ffgD2MqzkM2CYjeFiKhRF/dJUN8uedb6YE=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "27b3b12a8e6375f28ebe122f07d230ca5459bbfa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
66
flake.nix
66
flake.nix
@@ -1,33 +1,43 @@
|
||||
{
|
||||
description = "Simple tunneler in Go that exposes local ports to the internet";
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
description =
|
||||
"Simple tunneler in Go that exposes local ports to the internet";
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
}:
|
||||
let
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
|
||||
forAllSystems =
|
||||
function: nixpkgs.lib.genAttrs systems (system: function nixpkgs.legacyPackages.${system});
|
||||
in
|
||||
{
|
||||
packages = forAllSystems (pkgs: rec {
|
||||
default = trok;
|
||||
trok = pkgs.callPackage ./package.nix { };
|
||||
});
|
||||
|
||||
nixosModules.default = ./module.nix;
|
||||
|
||||
devShells = forAllSystems (pkgs: {
|
||||
default = pkgs.callPackage ./shell.nix { };
|
||||
});
|
||||
treefmt-nix = {
|
||||
url = "github:numtide/treefmt-nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = inputs:
|
||||
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
imports = [ inputs.treefmt-nix.flakeModule ];
|
||||
|
||||
systems =
|
||||
[ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
||||
|
||||
perSystem = { config, pkgs, ... }: {
|
||||
treefmt = {
|
||||
projectRootFile = "flake.nix";
|
||||
|
||||
programs = {
|
||||
nixfmt.enable = true;
|
||||
gofumpt.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
packages = rec {
|
||||
default = tfolio;
|
||||
tfolio = pkgs.callPackage ./nix/package.nix { };
|
||||
};
|
||||
|
||||
devShells.default = pkgs.callPackage ./nix/shell.nix { };
|
||||
};
|
||||
|
||||
flake.nixosModules.default = ./nix/module.nix;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.services.trok;
|
||||
{ config, lib, pkgs, ... }:
|
||||
with lib;
|
||||
let cfg = config.services.trok;
|
||||
in {
|
||||
options.services.trok = {
|
||||
enable = mkEnableOption "Enable trok";
|
||||
@@ -38,19 +33,20 @@ in {
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [cfg.port];
|
||||
networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];
|
||||
|
||||
systemd.services = {
|
||||
trok = {
|
||||
description = "trok server";
|
||||
after = ["network.target"];
|
||||
wantedBy = ["multi-user.target"];
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = "trok";
|
||||
Group = "trok";
|
||||
ExecStart = "${getExe pkgs.trok} server -a ${cfg.host}:${toString cfg.port}";
|
||||
ExecStart =
|
||||
"${getExe pkgs.trok} server -a ${cfg.host}:${toString cfg.port}";
|
||||
Restart = "always";
|
||||
|
||||
LockPersonality = true;
|
||||
@@ -73,7 +69,7 @@ in {
|
||||
RestrictRealtime = true;
|
||||
RestrictSUIDSGID = true;
|
||||
SystemCallArchitectures = "native";
|
||||
SystemCallFilter = ["@system-service"];
|
||||
SystemCallFilter = [ "@system-service" ];
|
||||
UMask = "0077";
|
||||
};
|
||||
};
|
||||
@@ -89,8 +85,6 @@ in {
|
||||
};
|
||||
};
|
||||
|
||||
users.groups = mkIf (cfg.group == "trok") {
|
||||
${cfg.group} = {};
|
||||
};
|
||||
users.groups = mkIf (cfg.group == "trok") { ${cfg.group} = { }; };
|
||||
};
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
{
|
||||
lib,
|
||||
buildGoModule,
|
||||
}:
|
||||
{ lib, buildGoModule }:
|
||||
buildGoModule {
|
||||
pname = "trok";
|
||||
version = "0.2.0";
|
||||
|
||||
src = ./.;
|
||||
src = ../.;
|
||||
vendorHash = "sha256-KwcLxkW3pbzujjc6JOZRwATlAA/qndf4FWpkJANv2z8=";
|
||||
|
||||
meta = {
|
||||
4
nix/shell.nix
Normal file
4
nix/shell.nix
Normal file
@@ -0,0 +1,4 @@
|
||||
{ callPackage, go, }:
|
||||
let mainPkg = callPackage ./package.nix { };
|
||||
in mainPkg.overrideAttrs
|
||||
(oa: { nativeBuildInputs = [ go ] ++ (oa.nativeBuildInputs or [ ]); })
|
||||
Reference in New Issue
Block a user