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:
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