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

[flakes] generate flake.nix file for php-related packages #639

Merged
merged 3 commits into from
Feb 21, 2023

Conversation

savil
Copy link
Collaborator

@savil savil commented Feb 15, 2023

Summary

For flake.nix:

  • we now also include the php "Definitions" and change the buildInputs list so that it uses the php packages from Definitions instead of from nixpkgs (if Definitions exist)

TODO for future PR:

  • look into whether buildInputs should be packages in flake.nix

How was it tested?

in examples/testdata/php/php-extensions, started devbox shell with DEVBOX_FEATURE_FLAKES=0 and DEVBOX_FEATURE_FLAKES=1. Inspected the generated flake.nix files.

❯ cat .devbox/gen/flake/flake.nix
{
  description = "A devbox shell";

  inputs = {
    nixpkgs.url = "https://github.com/nixos/nixpkgs/archive/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62.tar.gz";

    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let pkgs = nixpkgs.legacyPackages.${system};
          php81 = pkgs.php81.withExtensions ({ enabled, all }: enabled ++ (with all; [ ds ]));
          php81Packages.composer = php81.packages.composer;

      in {
        devShell = pkgs.mkShell {
          shellHook =
            ''
              # We're technically no longer in a Nix shell after this hook because we
              # exec a devbox shell.
              export IN_NIX_SHELL=0
              export DEVBOX_SHELL_ENABLED=1

              # Undo the effects of "nix-shell --pure" on SSL certs.
              # See https://github.com/NixOS/nixpkgs/blob/dae204faa0243b4d0c0234a5f5f83a2549ecb5b7/pkgs/stdenv/generic/setup.sh#L677-L685
              if [ "$NIX_SSL_CERT_FILE" = "/no-cert-file.crt" ]; then
                 unset NIX_SSL_CERT_FILE
              fi
              if [ "$SSL_CERT_FILE" = "/no-cert-file.crt" ]; then
                 unset SSL_CERT_FILE
              fi

              # Append the parent shell's PATH so that we retain access to
              # non-Nix programs, while still preferring the Nix ones.
              export "PATH=$PATH:$PARENT_PATH"


            '';

          buildInputs = with pkgs; [
            php81

            php81Packages.composer

            php81Extensions.ds
            ];
        };
      }
    );
}

Copy link
Collaborator Author

savil commented Feb 15, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@savil savil force-pushed the savil/enable-php-extensions-2 branch from b0872da to 324d480 Compare February 16, 2023 23:03
@savil savil force-pushed the savil/enable-php-extensions branch from cd1d62c to 3df1cb5 Compare February 16, 2023 23:08
@savil savil force-pushed the savil/enable-php-extensions-2 branch from 324d480 to 519dd92 Compare February 16, 2023 23:08
@savil savil changed the title [flakes] php extension changes [flakes] generate flake.nix file for php-related packages Feb 16, 2023
@savil savil force-pushed the savil/enable-php-extensions-2 branch 4 times, most recently from c7940f0 to 7e22dff Compare February 16, 2023 23:35
@savil savil requested review from gcurtis and ipince February 16, 2023 23:39
@savil savil marked this pull request as ready for review February 16, 2023 23:39
@savil savil force-pushed the savil/enable-php-extensions branch from 3df1cb5 to 1d4a3b0 Compare February 17, 2023 00:58
@savil savil force-pushed the savil/enable-php-extensions-2 branch from 7e22dff to a92a7aa Compare February 17, 2023 00:58
Base automatically changed from savil/enable-php-extensions to main February 17, 2023 01:03
@savil savil force-pushed the savil/enable-php-extensions-2 branch from a92a7aa to 903ea67 Compare February 17, 2023 01:03
@mikeland73
Copy link
Contributor

@savil I think this PR might not be necessary if we solve a flakes bug detailed here: #655

#648 might similarly not be needed.

the tldr is that we should not add the profile path when starting shell (or if we do we need a way to control the binaries there to ensure they represent the flake.nix ones and not the individually installed ones).

@gcurtis
Copy link
Collaborator

gcurtis commented Feb 21, 2023

@savil I'm going to remove myself as a reviewer since I think you and Mike are going to figure out the best way to tackle this. Feel free to re-add me if you still need a review.

@gcurtis gcurtis removed their request for review February 21, 2023 19:45
@savil
Copy link
Collaborator Author

savil commented Feb 21, 2023

We are going to simplify this to just the flake.nix changes.

Separately, @mikeland86 will remove nix-profile from PATH and we can then directly do print-dev-env on this flake.nix file.

@savil savil force-pushed the savil/enable-php-extensions-2 branch from ec2f9f8 to 0c15f9c Compare February 21, 2023 21:34
@savil savil requested review from mikeland73 and gcurtis February 21, 2023 21:46
@savil savil merged commit 94aa7d4 into main Feb 21, 2023
@savil savil deleted the savil/enable-php-extensions-2 branch February 21, 2023 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants