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

This commit is contained in:
Kevin Veen-Birkenbach
2025-12-05 22:47:13 +01:00
parent 46efb7d187
commit 9517c79342

View File

@@ -46,36 +46,47 @@
} }
); );
# Packages: nix build .#pkgmgr / .#default packages = forAllSystems (system:
packages = forAllSystems (system: let
let pkgs = nixpkgs.legacyPackages.${system};
pkgs = nixpkgs.legacyPackages.${system}; python = pkgs.python311;
python = pkgs.python311; pypkgs = pkgs.python311Packages;
pypkgs = pkgs.python311Packages;
# Be robust: ansible-core if available, otherwise ansible. # Optional: ansible mit in den Closure nehmen
ansiblePkg = ansiblePkg =
if pkgs ? ansible-core then pkgs.ansible-core if pkgs ? ansible-core then pkgs.ansible-core
else pkgs.ansible; else pkgs.ansible;
in in
rec { rec {
pkgmgr = pkgs.stdenv.mkDerivation { pkgmgr = pkgs.stdenv.mkDerivation {
pname = "package-manager"; pname = "package-manager";
version = "0.1.0"; version = "0.1.0";
src = ./.; src = ./.;
installPhase = '' # Nix soll *kein* configure / build ausführen (also auch kein make)
mkdir -p $out/bin dontConfigure = true;
cp main.py $out/bin/pkgmgr dontBuild = true;
chmod +x $out/bin/pkgmgr
''; # 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 # Apps: nix run .#pkgmgr / .#default