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

Use flake-schemas #166

Merged
merged 20 commits into from
Aug 2, 2024
Merged

Use flake-schemas #166

merged 20 commits into from
Aug 2, 2024

Conversation

shivaraj-bh
Copy link
Member

@shivaraj-bh shivaraj-bh commented Jul 19, 2024

This PR enforces nix flake show to use nix compiled from https://github.com/DeterminateSystems/nix-src/tree/flake-schemas by default (see NixOS/nix#8892). This allows defining a custom schema of the user's choice, with the default set to https://github.com/DeterminateSystems/flake-schemas.

TODO:

  • Wrap om with nix-flake-schemas script Allow overriding the nix with flake-schemas via NIX_FLAKE_SCHEMAS_BIN env
  • Use flake-schemas in omnix-gui
  • parse type of flake output from flake-schemas
  • nix_rs ChangeLog

resolves #161

@shivaraj-bh
Copy link
Member Author

cargo run -p omnix-cli -- show github:srid/nixos-config:

📦 Packages

Run: nix build github:srid/nixos-config#<name>
──────────┬───────────────────────────────────────────────────────
 name     │ description
══════════┼═══════════════════════════════════════════════════════
 activate │ Activate NixOS/nix-darwin/home-manager configurations
 default  │ Activate NixOS/nix-darwin/home-manager configurations
 update   │ N/A
──────────┴───────────────────────────────────────────────────────

🐚 Devshells

Run: nix develop github:srid/nixos-config#<name>
─────────┬─────────────
 name    │ description
═════════┼═════════════
 default │ N/A
─────────┴─────────────

🔍 Checks

Run: nix flake check
─────────┬─────────────
 name    │ description
═════════┼═════════════
 treefmt │ N/A
─────────┴─────────────

🐧 NixOS Configurations

Run: nixos-rebuild switch --flake github:srid/nixos-config#<name>
───────────┬─────────────
 name      │ description
═══════════┼═════════════
 immediacy │ N/A
───────────┴─────────────

🍏 Darwin Configurations

Run: darwin-rebuild switch --flake github:srid/nixos-config#<name>
────────────┬─────────────
 name       │ description
════════════┼═════════════
 appreciate │ N/A
────────────┴─────────────

@srid
Copy link
Collaborator

srid commented Jul 19, 2024

Very useful change. I should make nixci use this as well somehow, rather than wait for srid/devour-flake#8

@shivaraj-bh
Copy link
Member Author

Very useful change. I should make nixci use this as well somehow, rather than wait for srid/devour-flake#8

Weren't we planning on importing nixci to omnix, just like nix-health?

@srid
Copy link
Collaborator

srid commented Jul 19, 2024

Very useful change. I should make nixci use this as well somehow, rather than wait for srid/devour-flake#8

Weren't we planning on importing nixci to omnix, just like nix-health?

Yes, further PRs to nixci will be in this repo.

@shivaraj-bh
Copy link
Member Author

You can now nix run the app, it comes wrapped with nix-flake-schemas:

nix run github:juspay/omnix/flake-schemas show github:srid/nixos-config

shivaraj-bh added a commit that referenced this pull request Jul 22, 2024
@shivaraj-bh
Copy link
Member Author

image

The GUI also supports NixOS, darwin configurations and NixOS modules. I have to still parse the type of derivation correctly, that’s why you see “?” now — added it to TODO.

shivaraj-bh added a commit that referenced this pull request Jul 29, 2024
@shivaraj-bh shivaraj-bh force-pushed the flake-schemas branch 2 times, most recently from 3d53586 to 2bcc118 Compare July 29, 2024 12:40
@srid
Copy link
Collaborator

srid commented Jul 29, 2024

The mainProgram thing is broken on main. Let me fix it; it's regression from juspay/rust-flake@363f20b

EDIT: done, b3cfad3

@shivaraj-bh
Copy link
Member Author

nix (with flake-schemas) static binary builds and works as expected on Linux. While making a release, we can keep both nix and om static binary in the same directory, along with a script that points NIX_FLAKE_SCHEMAS_BIN env to the nix in the same directory and runs om. This directory can then be zipped and released.

Doesn’t look very pleasant, but that seems like the only way.

cc: @srid

@shivaraj-bh
Copy link
Member Author

shivaraj-bh commented Jul 30, 2024

Also, for static binary to work, we have to change the compile time ENVs to runtime. Which means DEVOUR_FLAKE source must also be zipped along with the static binary.

@srid
Copy link
Collaborator

srid commented Jul 30, 2024

As long as nix run continues to work, let's delegate static binary concerns to another PR.

crates/nix_rs/src/flake/mod.rs Outdated Show resolved Hide resolved
@shivaraj-bh shivaraj-bh marked this pull request as ready for review August 1, 2024 16:45
@shivaraj-bh
Copy link
Member Author

Here’s how the CLI and GUI outputs looks so far:

CLI

📦 Packages (nix build github:srid/nixos-config#<name>)
╭──────────┬───────────────────────────────────────────────────────╮
│ name     │ description                                           │
├──────────┼───────────────────────────────────────────────────────┤
│ activate │ Activate NixOS/nix-darwin/home-manager configurations │
│ default  │ Activate NixOS/nix-darwin/home-manager configurations │
│ update   │ N/A                                                   │
╰──────────┴───────────────────────────────────────────────────────╯

🐚 Devshells (nix develop github:srid/nixos-config#<name>)
╭─────────┬─────────────╮
│ name    │ description │
├─────────┼─────────────┤
│ default │ N/A         │
╰─────────┴─────────────╯

🔍 Checks (nix flake check)
╭─────────┬─────────────╮
│ name    │ description │
├─────────┼─────────────┤
│ treefmt │ N/A         │
╰─────────┴─────────────╯

🐧 NixOS Configurations (nixos-rebuild switch --flake github:srid/nixos-config#<name>)
╭───────────┬─────────────╮
│ name      │ description │
├───────────┼─────────────┤
│ immediacy │ N/A         │
╰───────────┴─────────────╯

🍏 Darwin Configurations (darwin-rebuild switch --flake github:srid/nixos-config#<name>)
╭────────────┬─────────────╮
│ name       │ description │
├────────────┼─────────────┤
│ appreciate │ N/A         │
╰────────────┴─────────────╯

🔧 NixOS Modules ()
╭──────────────┬─────────────╮
│ name         │ description │
├──────────────┼─────────────┤
│ common       │ N/A         │
│ default      │ N/A         │
│ home-manager │ N/A         │
│ my-home      │ N/A         │
│ nixosFlake   │ N/A         │
╰──────────────┴─────────────╯

GUI

image

@shivaraj-bh
Copy link
Member Author

Apart from the traditional outputs, you also see Darwin Configurations and NixOS Modules

@shivaraj-bh
Copy link
Member Author

  • Updated the description to reflect the changes done in this PR

Copy link
Collaborator

@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.

@shivaraj-bh LGTM, great. Did a final review.

crates/nix_rs/src/command.rs Outdated Show resolved Hide resolved
crates/nix_rs/src/command.rs Outdated Show resolved Hide resolved
crates/nix_rs/src/flake/mod.rs Outdated Show resolved Hide resolved
crates/nix_rs/src/flake/outputs.rs Outdated Show resolved Hide resolved
crates/nix_rs/src/flake/outputs.rs Show resolved Hide resolved
crates/omnix-gui/src/app/flake.rs Show resolved Hide resolved
crates/omnix-gui/src/app/flake.rs Outdated Show resolved Hide resolved
crates/omnix-cli/src/command/show.rs Outdated Show resolved Hide resolved
crates/nix_rs/src/flake/outputs.rs Show resolved Hide resolved
This was referenced Aug 1, 2024
shivaraj-bh and others added 2 commits August 2, 2024 16:48
Co-authored-by: Sridhar Ratnakumar <3998+srid@users.noreply.github.com>
Co-authored-by: Sridhar Ratnakumar <3998+srid@users.noreply.github.com>
flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
@shivaraj-bh
Copy link
Member Author

I have addressed all the comments. How does this look?

Copy link
Collaborator

@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.

Great!

@srid srid merged commit f409d82 into main Aug 2, 2024
5 checks passed
@srid srid deleted the flake-schemas branch August 2, 2024 20:10
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.

om show should display system configurations
2 participants