Skip to content

Commit

Permalink
Unfinished work
Browse files Browse the repository at this point in the history
  • Loading branch information
yousiki committed Mar 18, 2024
1 parent 10a886c commit 52af9d5
Show file tree
Hide file tree
Showing 11 changed files with 326 additions and 64 deletions.
106 changes: 105 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
fenix.overlays.default
nvfetcher.overlays.default
sops-nix.overlays.default
(final: prev: {
inherit (self.outputs.packages.${prev.system}) clash-meta cloudflare-warp lporg;
})
];
nixpkgs.config = {
allowUnfree = true;
Expand Down Expand Up @@ -127,6 +130,9 @@
sops-nix.inputs.nixpkgs.follows = "nixpkgs";

nixos-hardware.url = "github:NixOS/nixos-hardware/master";

arion.url = "github:hercules-ci/arion";
arion.inputs.nixpkgs.follows = "nixpkgs";
};

nixConfig = rec {
Expand Down
2 changes: 1 addition & 1 deletion src/configurations/nixos/hakase/_configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
# };
users.users.yousiki = {
isNormalUser = true;
extraGroups = ["wheel"]; # Enable ‘sudo’ for the user.
extraGroups = ["wheel" "docker"]; # Enable ‘sudo’ for the user.
shell = pkgs.zsh;
};

Expand Down
1 change: 1 addition & 0 deletions src/configurations/nixos/hakase/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ globals.inputs.nixpkgs.lib.nixosSystem {
nas
nvidia-gpu
sops
virtualisation
vscode-server
]);
}
75 changes: 36 additions & 39 deletions src/packages/clash-meta.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,39 @@
sources,
...
}:
if pkgs ? clash-meta
then
pkgs.buildGoModule rec {
inherit (sources.clash-meta) pname src;

version = pkgs.lib.removePrefix "v" sources.clash-meta.version;

vendorHash = "sha256-tvPR5kAta4MlMTwjfxwVOacRr2nVpfalbN08mfxml64=";

# Do not build testing suit
excludedPackages = ["./test"];

ldflags = [
"-s"
"-w"
"-X github.com/MetaCubeX/mihomo/constant.Version=${version}"
];

tags = [
"with_gvisor"
];

# network required
doCheck = false;

postInstall = ''
mv $out/bin/mihomo $out/bin/clash-meta
'';

meta = with pkgs.lib; {
description = "Another Clash Kernel";
homepage = "https://github.com/MetaCubeX/mihomo";
changelog = "https://github.com/MetaCubeX/mihomo/releases/tag/${version}";
mainProgram = "clash-meta";
license = licenses.gpl3Only;
maintainers = with maintainers; [yousiki];
};
}
else null
pkgs.buildGoModule rec {
inherit (sources.clash-meta) pname src;

version = pkgs.lib.removePrefix "v" sources.clash-meta.version;

vendorHash = "sha256-tvPR5kAta4MlMTwjfxwVOacRr2nVpfalbN08mfxml64=";

# Do not build testing suit
excludedPackages = ["./test"];

ldflags = [
"-s"
"-w"
"-X github.com/MetaCubeX/mihomo/constant.Version=${version}"
];

tags = [
"with_gvisor"
];

# network required
doCheck = false;

postInstall = ''
mv $out/bin/mihomo $out/bin/clash-meta
'';

meta = with pkgs.lib; {
description = "Another Clash Kernel";
homepage = "https://github.com/MetaCubeX/mihomo";
changelog = "https://github.com/MetaCubeX/mihomo/releases/tag/${version}";
mainProgram = "clash-meta";
license = licenses.gpl3Only;
maintainers = with maintainers; [yousiki];
};
}
97 changes: 97 additions & 0 deletions src/packages/cloudflare-warp.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Another Clash Kernel.
# Note that pkgs.*.overrideAttrs doesn't support buildGoModule
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/networking/clash-meta/default.nix
{
pkgs,
sources,
...
}: let
recipe = {
stdenv,
lib,
fetchurl,
dpkg,
autoPatchelfHook,
makeWrapper,
copyDesktopItems,
makeDesktopItem,
dbus,
nftables,
cairo,
gtk3,
libpcap,
...
}:
stdenv.mkDerivation rec {
pname = "cloudflare-warp";
version = "2024.2.62";

src = fetchurl {
url = "https://pkg.cloudflareclient.com/pool/jammy/main/c/cloudflare-warp/cloudflare-warp_2024.2.62-1_amd64.deb";
hash = "sha256-pq5sqAQu3UGEjj7fKctUN/JgJa/XzitCC7kEanHw0ug=";
};

nativeBuildInputs = [
dpkg
autoPatchelfHook
makeWrapper
copyDesktopItems
];

buildInputs = [
dbus
stdenv.cc.cc.lib
cairo
gtk3
libpcap
];

desktopItems = [
(makeDesktopItem {
name = "com.cloudflare.WarpCli";
desktopName = "Cloudflare Zero Trust Team Enrollment";
categories = ["Utility" "Security" "ConsoleOnly"];
noDisplay = true;
mimeTypes = ["x-scheme-handler/com.cloudflare.warp"];
exec = "warp-cli teams-enroll-token %u";
startupNotify = false;
terminal = true;
})
];

autoPatchelfIgnoreMissingDeps = [
"libpcap.so.0.8"
];

installPhase = ''
runHook preInstall
mv usr $out
mv bin $out
mv etc $out
mv lib/systemd/system $out/lib/systemd/
substituteInPlace $out/lib/systemd/system/warp-svc.service \
--replace "ExecStart=" "ExecStart=$out"
substituteInPlace $out/lib/systemd/user/warp-taskbar.service \
--replace "ExecStart=" "ExecStart=$out"
runHook postInstall
'';

postInstall = ''
wrapProgram $out/bin/warp-svc --prefix PATH : ${lib.makeBinPath [nftables]}
'';

meta = with lib; {
description = "Replaces the connection between your device and the Internet with a modern, optimized, protocol";
homepage = "https://pkg.cloudflareclient.com/packages/cloudflare-warp";
sourceProvenance = with sourceTypes; [binaryNativeCode];
license = licenses.unfree;
maintainers = with maintainers; [yousiki];
platforms = ["x86_64-linux"];
};
};
in
if pkgs.system == "x86_64-linux"
then pkgs.callPackage recipe {}
else null
15 changes: 0 additions & 15 deletions src/packages/default.nix

This file was deleted.

4 changes: 0 additions & 4 deletions src/packages/nvfetcher.nix

This file was deleted.

Loading

0 comments on commit 52af9d5

Please sign in to comment.