Skip to content
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

Add NixOS packages upgradeable #1361

Merged
merged 4 commits into from
Jan 18, 2024

Conversation

Micah-Kolide
Copy link
Contributor

@Micah-Kolide Micah-Kolide commented Sep 21, 2023

Adding a xml exec parser for NixOS packages. nix-env with -c can check package version and output into xml or json format. Json doesn't seem to return versionDiff, which is super useful on the check side, so I chose to add the XML parsing to the exec datatypes.

osquery> SELECT * FROM kolide_nix_upgradeable;
+----------------------------------+---------------------+---------------------+-----------------+-------+
| fullkey                          | parent              | key                 | value           | query |
+----------------------------------+---------------------+---------------------+-----------------+-------+
| items/item/0/-pname              | items/item/0        | -pname              | nix             | *     |
| items/item/0/-maxComparedVersion | items/item/0        | -maxComparedVersion | 2.17.0          | *     |
| items/item/0/-name               | items/item/0        | -name               | nix-2.18.0      | *     |
| items/item/0/-outputName         | items/item/0        | -outputName         |                 | *     |
| items/item/0/-system             | items/item/0        | -system             | unknown         | *     |
| items/item/0/-version            | items/item/0        | -version            | 2.18.0          | *     |
| items/item/0/-versionDiff        | items/item/0        | -versionDiff        | >               | *     |
| items/item/0/output/-name        | items/item/0/output | -name               | out             | *     |
| items/item/0/-attrPath           | items/item/0        | -attrPath           | 1               | *     |
| items/item/1/-pname              | items/item/1        | -pname              | nss-cacert      | *     |
| items/item/1/-system             | items/item/1        | -system             | unknown         | *     |
| items/item/1/-versionDiff        | items/item/1        | -versionDiff        | =               | *     |
| items/item/1/output/-name        | items/item/1/output | -name               | out             | *     |
| items/item/1/-attrPath           | items/item/1        | -attrPath           | 0               | *     |
| items/item/1/-outputName         | items/item/1        | -outputName         |                 | *     |
| items/item/1/-version            | items/item/1        | -version            | 3.92            | *     |
| items/item/1/-maxComparedVersion | items/item/1        | -maxComparedVersion | 3.92            | *     |
| items/item/1/-name               | items/item/1        | -name               | nss-cacert-3.92 | *     |
+----------------------------------+---------------------+---------------------+-----------------+-------+

This is super early in testing on a mac not a full NixOS install, but the general idea should work.

@Micah-Kolide
Copy link
Contributor Author

There are some questions here around multi-user installs / NixOS profiles as packages are only listed on a per profile basis. I'm looking into it more, but I might have to change this into a custom parser for handling multi profiles.

@Micah-Kolide
Copy link
Contributor Author

NixOS hosts a Nixpkgs releases, and lists them in a GitHub repo. If we need to go the release tracker path then we should be able to pull from these sources.

@Micah-Kolide
Copy link
Contributor Author

Lots of helpful info on NixOS package management here.

@CLAassistant
Copy link

CLAassistant commented Dec 22, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@directionless directionless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Micah-Kolide What's the state on this one? It looks almost ready, though the commands would need to shift to the Allowedcmd framework

@Micah-Kolide Micah-Kolide force-pushed the micah/add_nixos_package_manager_parser branch from 70c3543 to 6c08a0e Compare January 17, 2024 22:23
@Micah-Kolide Micah-Kolide marked this pull request as ready for review January 18, 2024 16:44
@Micah-Kolide
Copy link
Contributor Author

Micah-Kolide commented Jan 18, 2024

I think this will need some more testing on the linux side, but this may just work out as hoped. seph figured we could run with it and verify data after a merge. I didn't get a good NixOS environment set up for my own testing yet, so I was hoping we might be able to use a test NixOS machine from @RebeccaMahany?

I'm going to be working on re-setting up my NixOS build, but if it wouldn't be a hassle, then I would appreciate the help with testing it.

@Micah-Kolide Micah-Kolide added this pull request to the merge queue Jan 18, 2024
Merged via the queue into main with commit 33c6fd9 Jan 18, 2024
26 checks passed
@Micah-Kolide Micah-Kolide deleted the micah/add_nixos_package_manager_parser branch January 18, 2024 17:14
@RebeccaMahany
Copy link
Contributor

Relates to #868

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants