From 9517c79342c64754a101813cea1cf260df7263ac Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 5 Dec 2025 22:47:13 +0100 Subject: [PATCH] Refactor flake.nix to use stdenv.mkDerivation instead of buildPythonApplication, disable configure/build phases, add minimal installPhase to avoid triggering Makefile. See ChatGPT conversation: https://chatgpt.com/share/69332bc4-a128-800f-a69c-fdc24c4cc7fe --- flake.nix | 63 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/flake.nix b/flake.nix index e304c7d..4f643e3 100644 --- a/flake.nix +++ b/flake.nix @@ -46,36 +46,47 @@ } ); - # Packages: nix build .#pkgmgr / .#default - packages = forAllSystems (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - python = pkgs.python311; - pypkgs = pkgs.python311Packages; +packages = forAllSystems (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + python = pkgs.python311; + pypkgs = pkgs.python311Packages; - # Be robust: ansible-core if available, otherwise ansible. - ansiblePkg = - if pkgs ? ansible-core then pkgs.ansible-core - else pkgs.ansible; - in - rec { - pkgmgr = pkgs.stdenv.mkDerivation { - pname = "package-manager"; - version = "0.1.0"; + # Optional: ansible mit in den Closure nehmen + ansiblePkg = + if pkgs ? ansible-core then pkgs.ansible-core + else pkgs.ansible; + in + rec { + pkgmgr = pkgs.stdenv.mkDerivation { + pname = "package-manager"; + version = "0.1.0"; - src = ./.; + src = ./.; - installPhase = '' - mkdir -p $out/bin - cp main.py $out/bin/pkgmgr - chmod +x $out/bin/pkgmgr - ''; - }; + # Nix soll *kein* configure / build ausführen (also auch kein make) + dontConfigure = true; + dontBuild = true; + + # Wenn du Python/Ansible im Runtime-Closure haben willst: + buildInputs = [ + python + pypkgs.pyyaml + ansiblePkg + ]; + + installPhase = '' + mkdir -p "$out/bin" + cp main.py "$out/bin/pkgmgr" + chmod +x "$out/bin/pkgmgr" + ''; + }; + + # default package just points to pkgmgr + default = pkgmgr; + } +); - # default package just points to pkgmgr - default = pkgmgr; - } - ); # Apps: nix run .#pkgmgr / .#default