hostapps/flake.nix

181 lines
5.1 KiB
Nix
Raw Normal View History

2022-05-28 14:14:08 -05:00
{
description = "hostapps";
inputs = {
nixpkgs = {
url = "github:nixos/nixpkgs/nixos-unstable";
};
2023-10-30 15:57:52 -05:00
flake-utils = {
url = "github:numtide/flake-utils";
};
2023-10-30 15:48:40 -05:00
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
2023-10-30 15:57:52 -05:00
inputs.flake-utils.follows = "flake-utils";
2022-10-09 09:57:03 -05:00
};
2023-10-29 21:33:23 -05:00
make-shell = {
url = "github:ursi/nix-make-shell";
2023-03-24 10:53:20 -05:00
};
2024-05-14 14:44:33 -05:00
# 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";
# };
2022-05-28 14:14:08 -05:00
};
2023-10-29 21:33:23 -05:00
outputs = {
self,
nixpkgs,
2023-10-30 15:48:40 -05:00
poetry2nix,
2023-10-29 21:33:23 -05:00
flake-utils,
2024-05-14 14:44:33 -05:00
...
2023-10-29 21:33:23 -05:00
} @ inputs:
2022-10-09 09:57:03 -05:00
flake-utils.lib.eachDefaultSystem
2023-10-29 21:33:23 -05:00
(
system: let
2024-05-14 17:00:35 -05:00
# version = self.lastModifiedDate;
2023-10-29 21:33:23 -05:00
pkgs = import nixpkgs {
inherit system;
2024-09-21 16:15:00 -05:00
config.permittedInsecurePackages = [];
2023-10-29 21:33:23 -05:00
};
2024-05-14 17:00:35 -05:00
zig_hook = pkgs.zig_0_12.hook.overrideAttrs {
zig_default_flags = "-Dcpu=baseline -Doptimize=ReleaseFast";
};
2023-10-29 21:33:23 -05:00
make-shell = import inputs.make-shell {
inherit system pkgs;
};
2023-10-30 15:48:40 -05:00
inherit (poetry2nix.lib.mkPoetry2Nix {inherit pkgs;}) mkPoetryApplication overrides;
2023-10-29 21:33:23 -05:00
in {
2024-01-12 22:47:10 -06:00
packages = {
hostapps = mkPoetryApplication {
2024-09-21 16:15:00 -05:00
python = pkgs.python3;
2024-01-12 22:47:10 -06:00
projectDir = ./.;
propagatedBuildInputs = [
2024-09-21 16:21:21 -05:00
pkgs.git
2024-01-12 22:47:10 -06:00
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:
2024-05-14 17:00:35 -05:00
pkgs.stdenv.mkDerivation {
2024-01-12 22:47:10 -06:00
inherit src;
name = "hostapps-zig-cache";
2024-05-14 17:00:35 -05:00
nativeBuildInputs = [pkgs.git zig_hook];
2024-05-14 16:48:09 -05:00
# buildInputs = [
# pkgs.zig_0_12
# ];
2024-01-12 22:47:10 -06:00
dontConfigure = true;
2024-05-14 16:48:09 -05:00
dontUseZigBuild = true;
dontUseZigInstall = true;
2024-01-12 22:47:10 -06:00
dontFixup = true;
2024-05-14 16:48:09 -05:00
# preBuild = ''
# export ZIG_GLOBAL_CACHE_DIR=$(mktemp -d)
# '';
2024-01-12 22:47:10 -06:00
buildPhase = ''
runHook preBuild
zig build --fetch
runHook postBuild
'';
installPhase = ''
runHook preInstall
2024-05-14 16:48:09 -05:00
cp -r --reflink=auto $ZIG_GLOBAL_CACHE_DIR $out
2024-01-12 22:47:10 -06:00
runHook postInstall
'';
2024-05-14 17:00:35 -05:00
# outputHash = pkgs.lib.fakeHash;
outputHash = "sha256-DilCltrfYt7XpHbNNyylBwhantmhNkhHxILjhdmUqOA=";
2024-01-12 22:47:10 -06:00
outputHashMode = "recursive";
};
in
2024-05-14 17:00:35 -05:00
pkgs.stdenv.mkDerivation (
2024-01-12 22:47:10 -06:00
attrs: {
pname = "hostapps-zig";
version = "0.0.0";
src = ./.;
2024-05-14 16:48:09 -05:00
nativeBuildInputs = [
pkgs.git
2024-05-14 17:00:35 -05:00
zig_hook
2024-01-12 22:47:10 -06:00
];
2024-05-14 16:48:09 -05:00
# buildInputs = [
# pkgs.zig_0_12
# ];
2024-01-12 22:47:10 -06:00
preBuild = ''
2024-05-14 16:48:09 -05:00
rm -rf $ZIG_GLOBAL_CACHE_DIR
cp -r --reflink=auto ${cache attrs.src} $ZIG_GLOBAL_CACHE_DIR
2024-01-12 22:47:10 -06:00
chmod -R u+rwX $ZIG_GLOBAL_CACHE_DIR
'';
2024-05-14 16:48:09 -05:00
# buildPhase = ''
# runHook preBuild
# zig build -Doptimize=ReleaseSafe
# runHook postBuild
# '';
2024-01-12 22:47:10 -06:00
2024-05-14 16:48:09 -05:00
# installPhase = ''
# runHook preInstall
# mkdir -p $out/bin
# cp zig-out/bin/hostapps $out/bin
# runHook postInstall
# '';
2024-01-12 22:47:10 -06:00
}
);
2023-10-29 21:33:23 -05:00
};
defaultPackage = self.packages.${system}.hostapps;
devShells.default = let
python = pkgs.python312.withPackages (
ps:
with ps; [
# poetry-core
]
);
project = "hostapps";
2022-10-09 09:57:03 -05:00
in
2023-10-29 21:33:23 -05:00
make-shell {
packages = [
python
2023-10-30 13:59:27 -05:00
pkgs.inetutils
2022-10-09 09:57:03 -05:00
pkgs.openssh
2023-10-29 21:33:23 -05:00
pkgs.poetry
2023-10-30 13:59:27 -05:00
pkgs.sshpass
2024-05-14 14:44:33 -05:00
pkgs.zig_0_12
pkgs.zls
2022-10-09 09:57:03 -05:00
];
2023-10-29 21:33:23 -05:00
env = {
2024-01-12 22:47:10 -06:00
name = project;
2022-10-09 09:57:03 -05:00
};
2023-10-29 21:33:23 -05:00
};
}
);
2022-05-28 14:14:08 -05:00
}