1{
2 lib,
3 fetchurl,
4 boost,
5 cmake,
6 extra-cmake-modules,
7 kparts,
8 kpmcore,
9 kirigami2,
10 kservice,
11 libatasmart,
12 libxcb,
13 yaml-cpp,
14 libpwquality,
15 parted,
16 polkit-qt,
17 python3,
18 qtbase,
19 qtquickcontrols,
20 qtsvg,
21 qttools,
22 qtwebengine,
23 util-linux,
24 tzdata,
25 ckbcomp,
26 xkeyboard_config,
27 mkDerivation,
28 nixos-extensions ? false,
29 # passthru.tests
30 calamares-nixos,
31}:
32
33mkDerivation rec {
34 pname = "calamares";
35 version = "3.3.13";
36
37 # release including submodule
38 src = fetchurl {
39 url = "https://github.com/calamares/calamares/releases/download/v${version}/calamares-${version}.tar.gz";
40 sha256 = "sha256-5Jz32JTgK6BImM0HcMtXi04k39CAirdmC/lbskVmSNQ=";
41 };
42
43 # On major changes, or when otherwise required, you *must* :
44 # 1. reformat the patches,
45 # 2. `git am path/to/00*.patch` them into a calamares worktree,
46 # 3. rebase to the more recent calamares version,
47 # 4. and export the patches again via
48 # `git -c format.signoff=false format-patch v${version} --no-numbered --zero-commit --no-signature`.
49 patches = lib.optionals nixos-extensions [
50 ./0001-Modifies-the-users-module-to-only-set-passwords-of-u.patch
51 ./0002-Makes-calamares-search-run-current-system-sw-share-c.patch
52 ./0003-Uses-pkexec-within-modules-in-order-to-run-calamares.patch
53 ./0004-Adds-unfree-qml-to-packagechooserq.patch
54 ./0005-Modifies-finished-module-to-add-some-NixOS-resources.patch
55 ./0006-Remove-options-for-unsupported-partition-types.patch
56 ./0007-Fix-setting-the-kayboard-layout-on-GNOME-wayland.patch
57 ./0008-Change-default-location-where-calamares-searches-for.patch
58 ];
59
60 nativeBuildInputs = [
61 cmake
62 extra-cmake-modules
63 ];
64 buildInputs = [
65 boost
66 kparts.dev
67 kpmcore.out
68 kservice.dev
69 kirigami2
70 libatasmart
71 libxcb
72 yaml-cpp
73 libpwquality
74 parted
75 polkit-qt
76 python3
77 qtbase
78 qtquickcontrols
79 qtsvg
80 qttools
81 qtwebengine.dev
82 util-linux
83 ];
84
85 cmakeFlags = [
86 "-DPYTHON_LIBRARY=${python3}/lib/lib${python3.libPrefix}.so"
87 "-DPYTHON_INCLUDE_DIR=${python3}/include/${python3.libPrefix}"
88 "-DCMAKE_VERBOSE_MAKEFILE=True"
89 "-DWITH_PYTHONQT:BOOL=ON"
90 ];
91
92 POLKITQT-1_POLICY_FILES_INSTALL_DIR = "$(out)/share/polkit-1/actions";
93
94 postPatch = ''
95 # Run calamares without root. Other patches make it functional as a normal user
96 sed -e "s,pkexec calamares,calamares -D6," \
97 -i calamares.desktop
98
99 sed -e "s,X-AppStream-Ignore=true,&\nStartupWMClass=calamares," \
100 -i calamares.desktop
101
102 # Fix desktop reference with wayland
103 mv calamares.desktop io.calamares.calamares.desktop
104
105 sed -e "s,calamares.desktop,io.calamares.calamares.desktop," \
106 -i CMakeLists.txt
107
108 sed -e "s,/usr/bin/calamares,$out/bin/calamares," \
109 -i com.github.calamares.calamares.policy
110
111 sed -e 's,/usr/share/zoneinfo,${tzdata}/share/zoneinfo,' \
112 -i src/modules/locale/SetTimezoneJob.cpp \
113 -i src/libcalamares/locale/TimeZone.cpp
114
115 sed -e 's,/usr/share/X11/xkb/rules/base.lst,${xkeyboard_config}/share/X11/xkb/rules/base.lst,' \
116 -i src/modules/keyboard/keyboardwidget/keyboardglobal.cpp
117
118 sed -e 's,"ckbcomp","${ckbcomp}/bin/ckbcomp",' \
119 -i src/modules/keyboard/keyboardwidget/keyboardpreview.cpp
120
121 sed "s,\''${POLKITQT-1_POLICY_FILES_INSTALL_DIR},''${out}/share/polkit-1/actions," \
122 -i CMakeLists.txt
123 '';
124
125 passthru.tests = {
126 inherit calamares-nixos;
127 };
128
129 meta = with lib; {
130 description = "Distribution-independent installer framework";
131 homepage = "https://calamares.io/";
132 license = with licenses; [
133 gpl3Plus
134 bsd2
135 cc0
136 ];
137 maintainers = with maintainers; [
138 manveru
139 vlinkz
140 ];
141 platforms = platforms.linux;
142 mainProgram = "calamares";
143 };
144}