2023-08-22 20:05:09 +00:00
|
|
|
{ lib
|
|
|
|
, fetchFromGitHub
|
2023-10-09 19:29:22 +00:00
|
|
|
, fetchpatch
|
|
|
|
, stdenv
|
|
|
|
, python3
|
|
|
|
, bubblewrap
|
|
|
|
, systemd
|
2024-01-02 11:29:13 +00:00
|
|
|
, pandoc
|
|
|
|
, kmod
|
|
|
|
, gnutar
|
|
|
|
, util-linux
|
|
|
|
, cpio
|
2024-01-25 14:12:00 +00:00
|
|
|
, bash
|
|
|
|
, coreutils
|
|
|
|
, btrfs-progs
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
# Python packages
|
2023-08-22 20:05:09 +00:00
|
|
|
, setuptools
|
2023-10-09 19:29:22 +00:00
|
|
|
, setuptools-scm
|
|
|
|
, wheel
|
2023-08-22 20:05:09 +00:00
|
|
|
, buildPythonApplication
|
|
|
|
, pytestCheckHook
|
2023-10-09 19:29:22 +00:00
|
|
|
, pefile
|
|
|
|
|
|
|
|
# Optional dependencies
|
|
|
|
, withQemu ? false
|
|
|
|
, qemu
|
|
|
|
, OVMF
|
2023-08-22 20:05:09 +00:00
|
|
|
}:
|
|
|
|
let
|
|
|
|
# For systemd features used by mkosi, see
|
|
|
|
# https://github.com/systemd/mkosi/blob/19bb5e274d9a9c23891905c4bcbb8f68955a701d/action.yaml#L64-L72
|
2024-01-25 14:12:00 +00:00
|
|
|
systemdForMkosi = systemd.override {
|
2023-10-09 19:29:22 +00:00
|
|
|
withRepart = true;
|
|
|
|
withBootloader = true;
|
|
|
|
withSysusers = true;
|
|
|
|
withFirstboot = true;
|
2023-08-22 20:05:09 +00:00
|
|
|
withEfi = true;
|
|
|
|
withUkify = true;
|
|
|
|
};
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
python3pefile = python3.withPackages (ps: with ps; [
|
|
|
|
pefile
|
|
|
|
]);
|
2023-08-22 20:05:09 +00:00
|
|
|
in
|
|
|
|
buildPythonApplication rec {
|
|
|
|
pname = "mkosi";
|
2024-01-25 14:12:00 +00:00
|
|
|
version = "20.1";
|
2023-08-22 20:05:09 +00:00
|
|
|
format = "pyproject";
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
outputs = [ "out" "man" ];
|
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "systemd";
|
|
|
|
repo = "mkosi";
|
2023-10-09 19:29:22 +00:00
|
|
|
rev = "v${version}";
|
2024-01-25 14:12:00 +00:00
|
|
|
hash = "sha256-gkn5d9ybfrV/QYKSUyzyHAouU++NCEBDT22zFMrEZt8=";
|
2023-08-22 20:05:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# Fix ctypes finding library
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/7307
|
2023-10-09 19:29:22 +00:00
|
|
|
postPatch = lib.optionalString stdenv.isLinux ''
|
|
|
|
substituteInPlace mkosi/run.py \
|
|
|
|
--replace 'ctypes.util.find_library("c")' "'${stdenv.cc.libc}/lib/libc.so.6'"
|
|
|
|
substituteInPlace mkosi/__init__.py \
|
|
|
|
--replace '/usr/lib/systemd/ukify' "${systemdForMkosi}/lib/systemd/ukify"
|
|
|
|
'' + lib.optionalString withQemu ''
|
|
|
|
substituteInPlace mkosi/qemu.py \
|
|
|
|
--replace '/usr/share/ovmf/x64/OVMF_VARS.fd' "${OVMF.variables}" \
|
|
|
|
--replace '/usr/share/ovmf/x64/OVMF_CODE.fd' "${OVMF.firmware}"
|
2023-08-22 20:05:09 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2024-01-02 11:29:13 +00:00
|
|
|
pandoc
|
2023-08-22 20:05:09 +00:00
|
|
|
setuptools
|
2023-10-09 19:29:22 +00:00
|
|
|
setuptools-scm
|
|
|
|
wheel
|
2023-08-22 20:05:09 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
2024-01-25 14:12:00 +00:00
|
|
|
bash
|
|
|
|
btrfs-progs
|
2023-08-22 20:05:09 +00:00
|
|
|
bubblewrap
|
2024-01-25 14:12:00 +00:00
|
|
|
coreutils
|
2024-01-02 11:29:13 +00:00
|
|
|
cpio
|
|
|
|
gnutar
|
|
|
|
kmod
|
|
|
|
systemdForMkosi
|
|
|
|
util-linux
|
2023-10-09 19:29:22 +00:00
|
|
|
] ++ lib.optional withQemu [
|
|
|
|
qemu
|
2023-08-22 20:05:09 +00:00
|
|
|
];
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
postBuild = ''
|
|
|
|
./tools/make-man-page.sh
|
2023-08-22 20:05:09 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
checkInputs = [
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"mkosi"
|
|
|
|
];
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/share/man/man1
|
|
|
|
mv mkosi/resources/mkosi.1 $out/share/man/man1/
|
|
|
|
'';
|
|
|
|
|
|
|
|
makeWrapperArgs = [
|
|
|
|
"--set MKOSI_INTERPRETER ${python3pefile}/bin/python3"
|
|
|
|
"--prefix PYTHONPATH : \"$PYTHONPATH\""
|
|
|
|
];
|
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Build legacy-free OS images";
|
|
|
|
homepage = "https://github.com/systemd/mkosi";
|
2023-10-09 19:29:22 +00:00
|
|
|
changelog = "https://github.com/systemd/mkosi/releases/tag/v${version}";
|
2023-08-22 20:05:09 +00:00
|
|
|
license = licenses.lgpl21Only;
|
|
|
|
mainProgram = "mkosi";
|
|
|
|
maintainers = with maintainers; [ malt3 katexochen ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|