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

om health: Add --json #379

Merged
merged 9 commits into from
Jan 16, 2025
Merged

om health: Add --json #379

merged 9 commits into from
Jan 16, 2025

Conversation

shivaraj-bh
Copy link
Member

resolves #374

❯ om health —json > health.json
❯ cat health.json
{
  "trusted-users": {
    "title": "Trusted Users",
    "info": "trusted-users = root shivaraj",
    "result": "Green",
    "required": true
  },
  "caches": {
    "title": "Nix Caches in use",
    "info": "substituters = https://cache.nixos.org/ https://euler.cachix.org/ https://newton.cachix.org/ https://om.cachix.org/",
    "result": "Green",
    "required": true
  },
  "max-jobs": {
    "title": "Max Jobs",
    "info": "max-jobs = 8",
    "result": "Green",
    "required": true
  },
  "nix-version": {
    "title": "Minimum Nix Version",
    "info": "nix version = 2.24.10",
    "result": "Green",
    "required": true
  },
  "rosetta": {
    "title": "Rosetta Not Active",
    "info": "apple emulation = None",
    "result": "Green",
    "required": true
  },
  "direnv-install-check": {
    "title": "Direnv installation",
    "info": "direnv location = Some(\"/Users/shivaraj/.nix-profile/bin/direnv\")",
    "result": "Green",
    "required": false
  },
  "shell": {
    "title": "Shell dotfiles",
    "info": "Shell=Zsh; HOME=\"/Users/shivaraj\"; Managed: {\".zshrc\": \"/nix/store/rxw82293y8b3nc65k2d49ji9i8kbc375-hm_.zshrc\", \".zshenv\": \"/nix/store/csica6diirv3swl0gqhwvpkyh8r7fhfw-hm_.zshenv\"}; Unmanaged: {\".zprofile\": \"/Users/shivaraj/.zprofile\"}",
    "result": {
      "Red": {
        "msg": "Default Shell: Zsh is not managed by Nix",
        "suggestion": "You can use `home-manager` to manage shell configuration. See <https://github.com/juspay/nixos-unified-template>"
      }
    },
    "required": false
  },
  "flake-enabled": {
    "title": "Flakes Enabled",
    "info": "experimental-features = flakes fetch-tree nix-command",
    "result": "Green",
    "required": true
  }
}

crates/omnix-health/src/traits.rs Outdated Show resolved Hide resolved
crates/omnix-health/src/check/min_nix_version.rs Outdated Show resolved Hide resolved
crates/omnix-health/src/check/shell.rs Outdated Show resolved Hide resolved
crates/omnix-health/src/lib.rs Outdated Show resolved Hide resolved
crates/omnix-health/src/lib.rs Outdated Show resolved Hide resolved
@srid
Copy link
Member

srid commented Jan 16, 2025

I see the required flag, but not enabled? If a check is disabled, how does it show up in the JSON?

image

@shivaraj-bh
Copy link
Member Author

I see the required flag, but not enabled? If a check is disabled, how does it show up in the JSON?

image

enabled field is not part of

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
pub struct Check {
/// A user-facing title of this check
///
/// This value is expected to be unique across all checks.
pub title: String,
/// The user-facing information used to conduct this check
/// TODO: Use Markdown
pub info: String,
/// The result of running this check
pub result: CheckResult,
/// Whether this check is mandatory
///
/// Failures are considered non-critical if this is false.
pub required: bool,
}

@shivaraj-bh
Copy link
Member Author

I see the required flag, but not enabled? If a check is disabled, how does it show up in the JSON?

image

If a check is disabled, it will be only the key with empty hashmap as its value.

Copy link
Member

@srid srid left a comment

Choose a reason for hiding this comment

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

LGTM

crates/omnix-health/src/check/shell.rs Outdated Show resolved Hide resolved
@srid srid changed the title omnix-health: json output om health: Add --json Jan 16, 2025
@srid srid merged commit a589724 into main Jan 16, 2025
7 checks passed
@srid srid deleted the om-health-json branch January 16, 2025 19:15
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.

Add om health --json
2 participants