juspay / omnix

🚧 A Nix wrapper to improve developer experience
https://omnix.page
GNU Affero General Public License v3.0
68 stars 5 forks source link

`om show` should display system configurations #161

Closed srid closed 1 month ago

srid commented 1 month ago

om show should display nixosConfigurations and darwinConfigurations as well. Currently it doesn't:

image
shivaraj-bh commented 1 month ago

https://github.com/srid/nixos-config/blob/ab552c356dfb19fdea55ae700b4963750b498b99/flake.nix#L51-L53 darwinConfigurations is present but doesn’t show up in nix flake show github:srid/nixos-config —json:

{
  "checks": {
    "aarch64-darwin": {
      "treefmt": {
        "name": "treefmt-check",
        "type": "derivation"
      }
    },
    "aarch64-linux": {
      "treefmt": {}
    },
    "x86_64-linux": {
      "treefmt": {}
    }
  },
  "darwinConfigurations": {
    "type": "unknown"
  },
  "darwinModules": {
    "type": "unknown"
  },
  "darwinModules_": {
    "type": "unknown"
  },
  "devShells": {
    "aarch64-darwin": {
      "default": {
        "name": "nix-shell",
        "type": "derivation"
      }
    },
    "aarch64-linux": {
      "default": {}
    },
    "x86_64-linux": {
      "default": {}
    }
  },
  "formatter": {
    "aarch64-darwin": {
      "description": "one CLI to format the code tree",
      "name": "treefmt",
      "type": "derivation"
    },
    "aarch64-linux": {},
    "x86_64-linux": {}
  },
  "homeModules": {
    "type": "unknown"
  },
  "legacyPackages": {
    "aarch64-darwin": {},
    "aarch64-linux": {},
    "x86_64-linux": {}
  },
  "nixos-flake": {
    "type": "unknown"
  },
  "nixosConfigurations": {
    "immediacy": {
      "type": "nixos-configuration"
    }
  },
  "nixosModules": {
    "common": {
      "type": "nixos-module"
    },
    "default": {
      "type": "nixos-module"
    },
    "home-manager": {
      "type": "nixos-module"
    },
    "my-home": {
      "type": "nixos-module"
    },
    "nixosFlake": {
      "type": "nixos-module"
    }
  },
  "packages": {
    "aarch64-darwin": {
      "activate": {
        "description": "Activate NixOS/nix-darwin/home-manager configurations",
        "name": "activate",
        "type": "derivation"
      },
      "default": {
        "description": "Activate NixOS/nix-darwin/home-manager configurations",
        "name": "activate",
        "type": "derivation"
      },
      "update": {
        "name": "update-main-flake-inputs",
        "type": "derivation"
      }
    },
    "aarch64-linux": {
      "activate": {},
      "default": {},
      "update": {}
    },
    "x86_64-linux": {
      "activate": {},
      "default": {},
      "update": {}
    }
  }
}

Is it because the type is unknown and nix doesn’t recognise it? how else should we fetch darwinConfigurations?

shivaraj-bh commented 1 month ago

darwinConfigurations falls under Known but unchecked community attribute: https://github.com/NixOS/nix/blob/8ce4287409319e04f46ed1352deb956c30e35fc6/src/nix/flake.cc#L774-L786

srid commented 1 month ago

We could adopt https://github.com/DeterminateSystems/flake-schemas which does (or is designed to) recognize it.

EDIT: I believe FlakeHub itself uses it.

srid commented 1 month ago

https://github.com/juspay/omnix/blob/f63f6442de42b5bb272bdb8566fff49c97a71b9d/crates/nix_rs/src/flake/schema.rs#L15-L17

srid commented 1 month ago

Easiest way to use flake-schemas probably is to use their fork of Nix, just for nix flake show:

https://github.com/NixOS/nix/pull/8892

(Until it gets upstreamed)

shivaraj-bh commented 1 month ago

nixosConfigurations based on the current flake output schema is done here: https://github.com/juspay/omnix/pull/165

flake-schemas is being tried out here: https://github.com/juspay/omnix/pull/166