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 show should handle all systems #193

Open
Tracked by #162
srid opened this issue Aug 3, 2024 · 2 comments
Open
Tracked by #162

om show should handle all systems #193

srid opened this issue Aug 3, 2024 · 2 comments
Assignees
Labels
question Further information is requested
Milestone

Comments

@srid
Copy link
Member

srid commented Aug 3, 2024

image

The flake in question is from a private repo, but here's a copy:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
    flake-parts.url = "github:hercules-ci/flake-parts";
  };
  outputs = inputs:
    inputs.flake-parts.lib.mkFlake { inherit inputs; } {
      systems = [ "x86_64-linux" ]; # iconv doesn't work on macOS
      perSystem = { pkgs, lib, ... }: {
        formatter = pkgs.nixpkgs-fmt;
        apps.default.program = lib.getExe (pkgs.writeShellApplication {
          // snip fields
        });
        devShells.default = pkgs.mkShell {
          packages = [ pkgs.httrack pkgs.wget ];
        };
      };
    };
}

Notice the systems = [ "x86_64-linux" ] - which means running om show won't show anything. Perhaps it should still show other systems. Maybe spit out an error saying no output for current system, and that the user can run om show . --all-systems to display for all systems? Need to figure out UX.

@srid srid added the question Further information is requested label Aug 3, 2024
@srid srid added this to the v2 milestone Aug 3, 2024
@srid srid mentioned this issue Aug 9, 2024
9 tasks
@srid
Copy link
Member Author

srid commented Aug 20, 2024

Consider how this would work if IFD is used.

@niksingh710
Copy link
Contributor

Need to figure out UX.

The UX could be something like:

Image

Note

The UX Screenshot is a hardcoded value (reason explained below).

FlakeOutputs::get_by_path

/// let val = tree.get_by_path(&["aarch64-darwin", "default"]);
/// ```
pub fn get_by_path(&self, path: &[&str]) -> Option<&Self> {
let mut current = self;
for key in path {
let map = current.get_attrset()?;
current = map.get(*key)?;
}
Some(current)
}

The method tree.get_by_path(&[...]) takes a System type and then provides the output.

To implement the --all-systems flag, we need to gather a vec![] of all supported System types for each FlakeOutputs. Currently, the only system accessible is the host system on which om is running. Hence, fetching all supported systems for the flake will be necessary.

One more thing I observed is that omnix show . has the print_flake_output_table hardcoded with a set of values like ("packages", "devshells", "nixosConfigurations", ...). This limits the show command to only present the outputs from this predefined set, which I believe are considered standard outputs for the flake.

For example:

Image

With the current setup, om show will not display flake.something = {}, whereas nix flake show would. Instead of hardcoding these outputs, it seems more appropriate to show all available outputs. This would provide more flexibility and better align with how nix flake show works.

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

No branches or pull requests

3 participants