{ description = "hostapps"; inputs = { nixpkgs = { url = "github:nixos/nixpkgs/nixos-unstable"; }; flake-utils = { url = "github:numtide/flake-utils"; }; poetry2nix = { url = "github:nix-community/poetry2nix"; inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-utils.follows = "flake-utils"; }; make-shell = { url = "github:ursi/nix-make-shell"; }; zig = { url = "github:mitchellh/zig-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; 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, make-shell, zig, zls, } @ inputs: flake-utils.lib.eachDefaultSystem ( system: let version = self.lastModifiedDate; pkgs = import nixpkgs { inherit system; config.permittedInsecurePackages = [ "python3.11-requests-2.29.0" "python3.11-cryptography-40.0.2" ]; }; make-shell = import inputs.make-shell { inherit system pkgs; }; inherit (poetry2nix.lib.mkPoetry2Nix {inherit pkgs;}) mkPoetryApplication overrides; in { packages = { hostapps = mkPoetryApplication { python = pkgs.python311; projectDir = ./.; propagatedBuildInputs = [ pkgs.inetutils pkgs.openssh pkgs.sshpass ]; overrides = overrides.withDefaults ( self: super: { pyansi = super.pyansi.overridePythonAttrs ( old: { buildInputs = old.buildInputs ++ [self.poetry]; } ); # annotated-types = super.annotated-types.overridePythonAttrs ( # old: { # buildInputs = old.buildInputs ++ [self.hatchling]; # } # ); # pydantic-core = super.pydantic-core.overridePythonAttrs ( # old: { # buildInputs = old.buildInputs ++ [self.maturin]; # } # ); } ); }; hostapps-zig = let cache = src: pkgs.stdenvNoCC.mkDerivation { inherit src; name = "hostapps-zig-cache"; buildInputs = [ zig.packages.${pkgs.system}.master ]; dontUseZigInstall = true; dontUseZigBuild = true; dontConfigure = true; dontFixup = true; preBuild = '' export ZIG_GLOBAL_CACHE_DIR=$(mktemp -d) ''; buildPhase = '' runHook preBuild zig build --fetch runHook postBuild ''; installPhase = '' runHook preInstall cp -r --reflink=auto $ZIG_GLOBAL_CACHE_DIR/p $out runHook postInstall ''; outputHash = "sha256-GUddHnPI5zAU2JpQ1R9qjWyrYF7ytmroQxbz2kjj6ro="; outputHashMode = "recursive"; }; in pkgs.stdenvNoCC.mkDerivation ( attrs: { pname = "hostapps-zig"; version = "0.0.0"; src = ./.; buildInputs = [ zig.packages.${pkgs.system}.master ]; preBuild = '' export ZIG_GLOBAL_CACHE_DIR=$(mktemp -d) cp -r --reflink=auto ${cache attrs.src} $ZIG_GLOBAL_CACHE_DIR/p 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 zig.packages.${system}.master zls.packages.${system}.zls ]; env = { name = project; }; }; } ); }