spoofdpi: update package name, nixos module

This commit is contained in:
L-Nafaryus 2023-12-26 15:16:21 +05:00
parent 4d4d44c5c7
commit 4d715dad8b
No known key found for this signature in database
GPG Key ID: C76D8DCD2727DBB7
15 changed files with 334 additions and 7 deletions

View File

@ -1,6 +1,6 @@
# self.devShells.${system} # self.devShells.${system}
# #
{ self, nixpkgs, ... }: { self, nixpkgs, crane, ... }:
let let
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" ]; forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" ];
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
@ -9,9 +9,12 @@ in forAllSystems(system: let
pkgs = nixpkgsFor.${system}; pkgs = nixpkgsFor.${system};
bpkgs = self.packages.${system}; bpkgs = self.packages.${system};
blib = self.lib; blib = self.lib;
cranelib = crane.lib.${system};
in { in {
netgen = import ./netgen.nix { inherit pkgs bpkgs; }; netgen = import ./netgen.nix { inherit pkgs bpkgs; };
openfoam = import ./openfoam.nix { inherit pkgs bpkgs; }; openfoam = import ./openfoam.nix { inherit pkgs bpkgs; };
rust = import ./rust.nix { inherit pkgs cranelib; };
}) })

4
devShells/rust.nix Normal file
View File

@ -0,0 +1,4 @@
{ pkgs, cranelib, ... }:
cranelib.devShell {
packages = [];
}

View File

@ -46,6 +46,26 @@
"type": "github" "type": "github"
} }
}, },
"crane": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1702956644,
"narHash": "sha256-6XxZSkhb/OkxIx705RHTTLYZ2qemmEC7tODD8f21gKw=",
"owner": "ipetkov",
"repo": "crane",
"rev": "537ebb11db883f9076e37d83e3c7ee69a4abb48c",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"darwin": { "darwin": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -282,6 +302,7 @@
"inputs": { "inputs": {
"agenix": "agenix", "agenix": "agenix",
"cachix": "cachix", "cachix": "cachix",
"crane": "crane",
"home-manager": "home-manager_2", "home-manager": "home-manager_2",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }

View File

@ -11,9 +11,10 @@
home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; };
cachix = { url = "github:cachix/devenv/v0.6.3"; inputs.nixpkgs.follows = "nixpkgs"; }; cachix = { url = "github:cachix/devenv/v0.6.3"; inputs.nixpkgs.follows = "nixpkgs"; };
agenix = { url = "github:ryantm/agenix"; inputs.nixpkgs.follows = "nixpkgs"; }; agenix = { url = "github:ryantm/agenix"; inputs.nixpkgs.follows = "nixpkgs"; };
crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; };
}; };
outputs = inputs @ { self, nixpkgs, home-manager, agenix, ... }: { outputs = inputs @ { self, nixpkgs, home-manager, agenix, crane, ... }: {
lib = import ./lib {}; lib = import ./lib {};
@ -25,6 +26,7 @@
agenix.nixosModules.default agenix.nixosModules.default
./nixosConfigurations/astora ./nixosConfigurations/astora
./nixosModules/bonfire.nix ./nixosModules/bonfire.nix
self.nixosModules.spoofdpi
]; ];
specialArgs = { inherit inputs; }; specialArgs = { inherit inputs; };
}; };
@ -32,6 +34,8 @@
nixosModules = { nixosModules = {
bonfire = import ./nixosModules/bonfire.nix; bonfire = import ./nixosModules/bonfire.nix;
spoofdpi = import ./nixosModules/spoofdpi { inherit self; };
}; };
templates = { templates = {
@ -42,6 +46,6 @@
apps = import ./apps { inherit self nixpkgs; }; apps = import ./apps { inherit self nixpkgs; };
devShells = import ./devShells { inherit self nixpkgs; }; devShells = import ./devShells { inherit self nixpkgs crane; };
}; };
} }

View File

@ -0,0 +1,43 @@
{ self, ... }:
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.spoofdpi;
pkg = self.packages.${pkgs.system}.spoofdpi;
in {
options.services.spoofdpi = {
enable = mkEnableOption "Enables the SpoofDPI service";
address = mkOption rec {
type = types.str;
default = "127.0.0.1";
example = default;
description = "Listen address";
};
port = mkOption rec {
type = types.str;
default = "8080";
example = default;
description = "Port";
};
dns = mkOption rec {
type = types.str;
default = "8.8.8.8";
example = default;
description = "DNS server";
};
};
config = mkIf cfg.enable {
systemd.services.spoofdpi = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Restart = "on-failure";
ExecStart = "${pkg}/bin/spoof-dpi -no-banner -addr ${cfg.address} -port ${cfg.port} -dns ${cfg.dns}";
DynamicUser = "yes";
};
};
};
}

View File

@ -15,5 +15,5 @@ in forAllSystems(system: let pkgs = nixpkgsFor.${system}; in {
openfoam = pkgs.callPackage ./openfoam {}; openfoam = pkgs.callPackage ./openfoam {};
spoof-dpi = pkgs.callPackage ./spoof-dpi {}; spoofdpi = pkgs.callPackage ./spoofdpi {};
}) })

1
packages/lit/.envrc Normal file
View File

@ -0,0 +1 @@
use flake

2
packages/lit/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
result*

169
packages/lit/Cargo.lock generated Normal file
View File

@ -0,0 +1,169 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "anstream"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
[[package]]
name = "anstyle-parse"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
dependencies = [
"anstyle",
"windows-sys",
]
[[package]]
name = "clap"
version = "4.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2"
dependencies = [
"clap_builder",
]
[[package]]
name = "clap_builder"
version = "4.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_lex"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
[[package]]
name = "colorchoice"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]]
name = "rust-example"
version = "0.1.0"
dependencies = [
"clap",
]
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "utf8parse"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
[[package]]
name = "windows_i686_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
[[package]]
name = "windows_i686_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"

10
packages/lit/Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "rust-example"
version = "0.1.0"
edition = "2021"
[[bin]]
name = "lit"
[dependencies]
clap = "4.4.11"

8
packages/lit/README.md Normal file
View File

@ -0,0 +1,8 @@
# Basic Rust Example
* Creating/updating `Cargo.lock`
```shell
touch Cargo.lock
nix develop
cargo check
```

7
packages/lit/default.nix Normal file
View File

@ -0,0 +1,7 @@
{ lib, pkgs, cranelib, ... }:
cranelib.buildPackage {
src = cranelib.cleanCargoSource (cranelib.path ./.);
strictDeps = true;
buildInputs = [];
}

52
packages/lit/flake.nix Normal file
View File

@ -0,0 +1,52 @@
{
description = "Basic rust template";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; };
};
outputs = inputs @ { self, nixpkgs, crane, ... }:
let
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" ];
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in {
packages = forAllSystems (system: {
lit = let
pkgs = nixpkgsFor.${system};
cranelib = crane.lib.${system};
in cranelib.buildPackage {
src = cranelib.cleanCargoSource (cranelib.path ./.);
strictDeps = true;
buildInputs = [];
};
default = self.packages.${system}.lit;
});
checks = forAllSystems (system: {
inherit (self.packages.${system}.lit);
lit-fmt = let cranelib = crane.lib.${system}; in cranelib.cargoFmt {
src = cranelib.cleanCargoSource (cranelib.path ./.);
};
});
apps = forAllSystems (system: {
default = {
type = "app";
program = "${self.packages.${system}.lit}/bin/lit";
};
});
devShells = forAllSystems (system: {
default = crane.lib.${system}.devShell {
checks = self.checks.${system};
packages = [];
};
});
};
}

3
packages/lit/src/main.rs Normal file
View File

@ -0,0 +1,3 @@
fn main() {
println!("Hello, nix!");
}

View File

@ -5,14 +5,14 @@
vendorHash ? "sha256-ib9xRklkLfrDCuLf7zDkJE8lJiNiUMPZ01MDxvqho6o=", ... vendorHash ? "sha256-ib9xRklkLfrDCuLf7zDkJE8lJiNiUMPZ01MDxvqho6o=", ...
}: }:
pkgs.buildGoModule { pkgs.buildGoModule {
pname = "spoof-dpi"; pname = "spoofdpi";
inherit version; inherit version;
src = pkgs.fetchFromGitHub { src = pkgs.fetchFromGitHub {
owner = "xzvc"; owner = "xvzc";
repo = "SpoofDPI"; repo = "SpoofDPI";
rev = version; rev = version;
hash = "sha256-kPCdOZl4m7KBb970TjJokXorKfnCvuV5Uq7lFQIh1z8="; hash = hash;
}; };
inherit vendorHash; inherit vendorHash;