-
-
Notifications
You must be signed in to change notification settings - Fork 56
vmupdate: add support for nixos #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -218,7 +218,7 @@ def _print_changes(self, changes): | |
| if changes["installed"]: | ||
| for pkg in changes["installed"]: | ||
| result.out += self._print_to_string( | ||
| pkg, changes["installed"][pkg]) | ||
| pkg, ", ".join(changes["installed"][pkg])) | ||
| else: | ||
| result.out += self._print_to_string("None") | ||
|
|
||
|
|
@@ -227,17 +227,17 @@ def _print_changes(self, changes): | |
| for pkg in changes["updated"]: | ||
| result.out += self._print_to_string( | ||
| pkg, | ||
| str(changes["updated"][pkg]["old"])[2:-2] | ||
| ", ".join((changes["updated"][pkg]["old"])) | ||
| + " -> " + | ||
| str(changes["updated"][pkg]["new"])[2:-2]) | ||
| ", ".join((changes["updated"][pkg]["new"])) | ||
| else: | ||
| result.out += self._print_to_string("None") | ||
|
|
||
| result.out += self._print_to_string("Removed packages:") | ||
| if changes["removed"]: | ||
| for pkg in changes["removed"]: | ||
| result.out += self._print_to_string( | ||
| pkg, changes["removed"][pkg]) | ||
| pkg, ", ".join(changes["removed"][pkg])) | ||
| else: | ||
| result.out += self._print_to_string("None") | ||
| return result | ||
|
|
@@ -276,7 +276,10 @@ def upgrade_internal(self, remove_obsolete: bool) -> ProcessResult: | |
| Just run upgrade via CLI. | ||
| """ | ||
| cmd = [self.package_manager, | ||
| "--noconfirm" if self.package_manager == "pacman" else "-y", | ||
| *( | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i just extended the existing pattern but please let me know if you'd prefer I clean this up in some way. as-is package manager specifics are leaking into this common module.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is already fixed in #164, but it waits for resolving conflicts
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI the other PR is merged now, you can rebase to resolve the conflict. |
||
| ["--noconfirm"] if self.package_manager == "pacman" | ||
| else [] if self.package_manager == "qubes-nixos-rebuild" else "-y" | ||
| ), | ||
| *self.get_action(remove_obsolete)] | ||
|
|
||
| return self.run_cmd(cmd) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # coding=utf-8 | ||
| # | ||
| # The Qubes OS Project, http://www.qubes-os.org | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License | ||
| # as published by the Free Software Foundation; either version 2 | ||
| # of the License, or (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program; if not, write to the Free Software | ||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
| # USA. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # coding=utf-8 | ||
| # | ||
| # The Qubes OS Project, http://www.qubes-os.org | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License | ||
| # as published by the Free Software Foundation; either version 2 | ||
| # of the License, or (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program; if not, write to the Free Software | ||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
| # USA. | ||
|
|
||
| from typing import List, Dict | ||
|
|
||
| from source.common.package_manager import PackageManager | ||
| from source.common.process_result import ProcessResult | ||
|
|
||
|
|
||
| class NIXOSCLI(PackageManager): | ||
| def __init__(self, log_handler, log_level): | ||
| super().__init__(log_handler, log_level) | ||
| self.package_manager = "qubes-nixos-rebuild" | ||
|
|
||
| def refresh(self, hard_fail: bool) -> ProcessResult: | ||
| """ | ||
| Use package manager to refresh available packages. | ||
|
|
||
| Note: Is a no-op in NixOS because the qubes-nixos-rebuild | ||
| wrapper takes care of it, and having just sync could cause problems. | ||
|
|
||
| :return: (exit_code, stdout, stderr) | ||
| """ | ||
| cmd = ["true"] | ||
| return self.run_cmd(cmd) | ||
|
|
||
| def get_packages(self) -> Dict[str, List[str]]: | ||
| """ | ||
| Use nix to return the installed packages and their versions. | ||
| """ | ||
|
|
||
| cmd = ["qubes-nixos-get-packages"] | ||
| # EXAMPLE OUTPUT: | ||
| # qubes-core-agent-linux: ∅ → 4.3.5, +1413.6 KiB | ||
| # python3: ∅ → 3.11.9, 3.12.4, +229814.3 KiB | ||
| # dns-root-data: ∅ → 2024-06-20 | ||
|
|
||
| result = self.run_cmd(cmd, realtime=False) | ||
|
|
||
| packages: Dict[str, List[str]] = {} | ||
| for line in result.out.splitlines(): | ||
| package, info = line.split(":", 1) | ||
| versions = info.lstrip("∅ → ").split(", ") | ||
| for version in versions: | ||
| if not version.startswith("+"): | ||
| packages.setdefault(package, []).append(version) | ||
|
|
||
| return packages | ||
|
|
||
| def get_action(self, remove_obsolete) -> List[str]: | ||
| """ | ||
| qubes-nixos-rebuild will handle obsoletions itself | ||
| """ | ||
| return [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has a syntax error: not closed
(