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

Packaging request: tailwindcss cli #149333

Closed
lobre opened this issue Dec 7, 2021 · 13 comments · Fixed by #149839
Closed

Packaging request: tailwindcss cli #149333

lobre opened this issue Dec 7, 2021 · 13 comments · Fixed by #149839
Labels
0.kind: packaging request Request for a new package to be added

Comments

@lobre
Copy link
Contributor

lobre commented Dec 7, 2021

Project description

Tailwindcss is a utility-first CSS framework. The team has recently built a cli to facilitate the compilation process.

Metadata

Here is also the link to the npm package containing the executable of the cli: https://www.npmjs.com/package/tailwindcss

It does not seem complicated to build in Nix but I have just never done that before so it feels a little overwhelming to me. Would appreciate a hand.

@lobre lobre added the 0.kind: packaging request Request for a new package to be added label Dec 7, 2021
@lobre lobre changed the title Tailwindcss cli Packaging request: tailwindcss cli Dec 7, 2021
@jyooru
Copy link
Member

jyooru commented Dec 9, 2021

Welcome to nixpkgs! There's a nixpkgs manual that contains useful information for packaging for nixpkgs. There are also specific sections for adding packages and specific languages. Here's what I did to package tailwindcss.

@lobre
Copy link
Contributor Author

lobre commented Dec 9, 2021

Thanks, @jyooru for the warm welcome and the guidance. I did not know those docs were that accurate.
And thank you also for taking the time to create this PR, that is much appreciated.

@lobre
Copy link
Contributor Author

lobre commented Dec 13, 2021

Do you know by any chance why tailwindcss still does not appear on https://search.nixos.org/packages (unstable channel), while I can properly install it with nix-env -iA nixpkgs.nodePackages.tailwindcss?

The nixpkgs-unstable channel is correctly built of what I can see: https://status.nixos.org/

Is there anything special blocking me from finding it? Maybe there is a delay before it shows up on search.nixos.org.

@jyooru
Copy link
Member

jyooru commented Dec 13, 2021

I've just tried installing it on my system and it's not working either.

search.nixos.org is updated hourly: https://github.com/NixOS/nixos-search/actions/workflows/cron-nixpkgs.yml
It seems to have broken 12 hours ago, but this was merged 2 days ago, and even running a local nix search doesn't show nodePackages.tailwindcss...

After a little investigation, it looks like there's a bigger problem here.

I've tried a few PRs that add a new node package and none seem to be available on nixos-unstable but are available in the nixpkgs repository (eg nix-build -A nodePackages.tailwindcss.

For example, #129668, added 9th of July:

❯ nix-shell -p nodePackages.terser
error: attribute 'terser' missing

Where as running it through the master branch (through flakes):

❯ nix shell .#pkgs.nodePackages.terser
❯ terser --help
Usage: terser [options] [files...]
...

@Mic92, is this a bug worth making an issue for?

@Mic92
Copy link
Member

Mic92 commented Dec 13, 2021

Is the package already included in the channel commit? You not just need to check the time of the channel build but also what commit of nixpkgs finished, because it may be an old commit that just finished now to build.

@Mic92
Copy link
Member

Mic92 commented Dec 13, 2021

This works for me:

$ nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixpkgs-unstable.tar.gz --builders '' -p nodePackages.tailwindcss

@lobre
Copy link
Contributor Author

lobre commented Dec 14, 2021

I confirm. From what I see, the package is included in the nixpkgs-unstable branch.

commit af0da8e2eaf7ccafba00fc778fe87ad3d7faf492
Author: Joel <[email protected]>
Date:   Fri Dec 10 11:37:25 2021 +1000

    tailwindcss: init at 3.0.1
$ git branch --all --contains af0da8e2eaf7ccafba00fc778fe87ad3d7faf492

remotes/origin/haskell-updates
remotes/origin/master
remotes/origin/nixos-unstable
remotes/origin/nixos-unstable-small
remotes/origin/nixpkgs-unstable        <-- HERE
remotes/origin/staging
remotes/origin/staging-next

And the last successful build of nixpkgs-unstable (as reported on https://status.nixos.org/) is c473cc8714710179df205b153f4e9fa007107ff9.

And so af0da8e2eaf7ccafba00fc778fe87ad3d7faf492 belongs to this build.

$ git log --oneline c473cc8714710179df205b153f4e9fa007107ff9 | grep af0da8e2eaf
af0da8e2eaf tailwindcss: init at 3.0.1

However, I still don’t see it in https://search.nixos.org

@Mic92
Copy link
Member

Mic92 commented Dec 14, 2021

I don't think search.nixos.org indexes all packages in nodePackages because we don't build all packages in nodePackages.
To make it show up in nixos-search, we need an alias in all-packages.nix. Something like:

tailwindcss = nodePackages.tailwindcss;

@lobre
Copy link
Contributor Author

lobre commented Dec 14, 2021

Are you sure about this? If I take for example leetcode-cli, it does not exist in all-packages.nix while it appears in search.nixos.org.

And there are many other examples of packages that I can find in search.nixos.org belonging to pkgs/development/node-packages/node-packages.json and not to all-packages.nix.

@jyooru
Copy link
Member

jyooru commented Dec 14, 2021

# pkgs/top-level/all-packages.nix
  nodePackages = dontRecurseIntoAttrs nodejs.pkgs;

I believe dontRecurseIntoAttrs means something along the lines of only evaluate the values you need. The packages that do show up have been evaluated because they have been aliased elsewhere or because they may be a dependency of another package that has been evaluated.

@jyooru
Copy link
Member

jyooru commented Dec 14, 2021

Also, I just got the package working in a devShell (with flakes):

# flake.nix

{
  description = "Website development environment";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    flake-utils.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let pkgs = import nixpkgs { inherit system; }; in
      {
        devShell = pkgs.mkShell {
          packages = (with pkgs; [ nodejs ])
            ++ (with pkgs.nodePackages; [ prettier tailwindcss ]);
        };
      }
    );
}

2021-12-14-224839_651x287_scrot

@Mic92
Copy link
Member

Mic92 commented Dec 14, 2021

Are you sure about this? If I take for example leetcode-cli, it does not exist in all-packages.nix while it appears in search.nixos.org.

And there are many other examples of packages that I can find in search.nixos.org belonging to pkgs/development/node-packages/node-packages.json and not to all-packages.nix.

looks like the import in nixos-search is broken: https://github.com/NixOS/nixos-search/runs/4521001235?check_suite_focus=true

Tracked here: NixOS/nixos-search#389

@lobre
Copy link
Contributor Author

lobre commented Dec 14, 2021

Let’s first see what happens once the import is fixed then.

Thanks for creating the issue @Mic92.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: packaging request Request for a new package to be added
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants