DeterminateSystems / flake-schemas

Schemas for common flake output types
MIT License
77 stars 5 forks source link

provide a command to check schema definitions #14

Open sellout opened 9 months ago

sellout commented 9 months ago

I tried nix run github:DeterminateSystems/nix/flake-schemas -- flake show, but that fails in the check phase. I got it integrated in my flake with a bit of jiggering:

inputs.nix-schema.url = "github:DeterminateSystems/nix/flake-schemas";
pkgs = import nixpkgs {
  inherit system;
  overlays = [
    (final: prev: {
      nix-schema =
        nix-schema.packages.${system}.nix.overrideAttrs (old: {
          doCheck = false;
          postInstall = old.postInstall + ''
            mv $out/bin/nix $out/bin/nix-schema
          '';
          doInstallCheck = false;
        });
    })
  ];
$ nix-schema flake show
nix-schema flake show
git+file:///…/project-manager
⋮
├───projectConfigurations
│   ├───aarch64-darwin: Project Manager configuration for this flake’s project [project-manager-generation-for-project-manager]
│   ├───aarch64-linux omitted (use '--all-systems' to show)
│   ├───x86_64-darwin omitted (use '--all-systems' to show)
│   └───x86_64-linux omitted (use '--all-systems' to show)
├───projectModules
│   ├───direnv: Project Manager module
│   ├───editorconfig: Project Manager module
│   ├───files: Project Manager module
│   ├───flakehub: Project Manager module
│   ├───flakestry: Project Manager module
│   ├───garnix: Project Manager module
│   ├───git: Project Manager module
│   ├───github: Project Manager module
│   ├───just: Project Manager module
│   ├───mercurial: Project Manager module
│   ├───news: Project Manager module
│   ├───project-environment: Project Manager module
│   ├───project-manager: Project Manager module
│   ├───renovate: Project Manager module
│   ├───shellcheck: Project Manager module
│   ├───submodule-support: Project Manager module
│   ├───treefmt: Project Manager module
│   ├───vale: Project Manager module
│   ├───version: Project Manager module
│   └───xdg: Project Manager module
└───schemas
    ⋮
    ├───projectConfigurations: flake schema
    ├───projectModules: flake schema
    └───schemas: flake schema

But that seems like more work than a user should have to do. Maybe it's as simple as fixing the PR and mentioning nix run … in the README, but something where users can trust their schemas are reasonable before pushing to FlakeHub would be great.

sellout commented 9 months ago

This is just using the branch for NixOS/nix#8892. Merging that would make this issue redundant (once a new nix is released).

drupol commented 4 months ago

Yeah that's elegant, for sure. However, having various versions of Nix is, IMHO, not the most practical ways of using it.

sellout commented 4 months ago

Yeah that's elegant, for sure. However, having various versions of Nix is, IMHO, not the most practical ways of using it.

Absolutely – this is just a workaround until 🤞🏼 NixOS/nix#8892 is merged. If there’s a better workaround, I’m open to it. I wanted to avoid using that branch as my default nix to avoid any compatibility issues.