{ 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, ... } @ inputs: flake-utils.lib.eachDefaultSystem ( system: let # version = self.lastModifiedDate; pkgs = import nixpkgs { inherit system; config.permittedInsecurePackages = []; }; zig_hook = pkgs.zig_0_12.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 = 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 = mkPoetryApplication { # python = pkgs.python3; # projectDir = ./.; # propagatedBuildInputs = [ # pkgs.git # 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.stdenv.mkDerivation { inherit src; name = "hostapps-zig-cache"; nativeBuildInputs = [pkgs.git zig_hook]; # buildInputs = [ # pkgs.zig_0_12 # ]; dontConfigure = true; dontUseZigBuild = true; dontUseZigInstall = 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 $out runHook postInstall ''; # outputHash = pkgs.lib.fakeHash; outputHash = "sha256-DilCltrfYt7XpHbNNyylBwhantmhNkhHxILjhdmUqOA="; outputHashMode = "recursive"; }; in pkgs.stdenv.mkDerivation ( attrs: { pname = "hostapps-zig"; version = "0.0.0"; src = ./.; nativeBuildInputs = [ pkgs.git zig_hook ]; # buildInputs = [ # pkgs.zig_0_12 # ]; 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_12 pkgs.zls ]; env = { name = project; }; }; } ); }