{ description = "hostapps"; inputs = { nixpkgs = { url = "github:nixos/nixpkgs/nixos-unstable"; }; flake-utils = { url = "github:numtide/flake-utils"; }; make-shell = { url = "github:ursi/nix-make-shell"; }; # zig = { # url = "github:mitchellh/zig-overlay"; # inputs.nixpkgs.follows = "nixpkgs"; # inputs.flake-utils.follows = "flake-utils"; # }; # zls = { # url = "github:zigtools/zls"; # inputs.nixpkgs.follows = "nixpkgs"; # inputs.zig-overlay.follows = "zig"; # inputs.flake-utils.follows = "flake-utils"; # }; }; outputs = { self, nixpkgs, # poetry2nix, flake-utils, ... } @ inputs: flake-utils.lib.eachDefaultSystem ( system: let pkgs = import nixpkgs { inherit system; config.permittedInsecurePackages = []; }; zig_hook = pkgs.zig_0_13.hook.overrideAttrs { zig_default_flags = "-Dcpu=baseline -Doptimize=ReleaseFast"; }; make-shell = import inputs.make-shell { inherit system pkgs; }; # inherit (poetry2nix.lib.mkPoetry2Nix {inherit pkgs;}) mkPoetryApplication overrides; in { packages = { hostapps-python = pkgs.python3.pkgs.buildPythonPackage { pname = "hostapps"; version = "0.1.0"; pyproject = true; src = ./.; propagatedBuildInputs = with pkgs.python3.pkgs; [ click poetry-core pydantic pynetbox ]; doCheck = false; }; hostapps-zig = let cache = src: pkgs.stdenv.mkDerivation { inherit src; name = "hostapps-zig-cache"; nativeBuildInputs = [pkgs.git zig_hook]; dontConfigure = true; dontUseZigBuild = true; dontUseZigInstall = true; dontFixup = true; buildPhase = '' runHook preBuild zig build --fetch runHook postBuild ''; installPhase = '' runHook preInstall cp -r --reflink=auto $ZIG_GLOBAL_CACHE_DIR $out runHook postInstall ''; # outputHash = pkgs.lib.fakeHash; outputHash = "sha256-OOBbn07bYUxYEudlone34/jJd4Aw1pEtEQVIrnZdqHY="; outputHashMode = "recursive"; }; in pkgs.stdenv.mkDerivation ( attrs: { pname = "hostapps-zig"; version = "0.0.0"; src = ./.; nativeBuildInputs = [ pkgs.git pkgs.inetutils pkgs.openssh zig_hook ]; preBuild = '' rm -rf $ZIG_GLOBAL_CACHE_DIR cp -r --reflink=auto ${cache attrs.src} $ZIG_GLOBAL_CACHE_DIR chmod -R u+rwX $ZIG_GLOBAL_CACHE_DIR ''; # buildPhase = '' # runHook preBuild # zig build -Doptimize=ReleaseSafe # runHook postBuild # ''; # installPhase = '' # runHook preInstall # mkdir -p $out/bin # cp zig-out/bin/hostapps $out/bin # runHook postInstall # ''; } ); }; defaultPackage = self.packages.${system}.hostapps; devShells.default = let python = pkgs.python312.withPackages ( ps: with ps; [ # poetry-core ] ); project = "hostapps"; in make-shell { packages = [ python pkgs.inetutils pkgs.openssh pkgs.poetry pkgs.sshpass pkgs.zig_0_13 ]; env = { name = project; }; }; } ); }