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

Add firefox only on non-darwin systems' flake.nix #1019

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

DanGould
Copy link
Contributor

@DanGould DanGould commented Feb 7, 2024

pkgs.firefox's metadata list darwin in badPlatforms.
See: https://github.com/NixOS/nixpkgs/blob/d89f18a17e51532ed5f4d45297b0ddf11e46b9c8/pkgs/applications/networking/browsers/firefox/packages.nix#L21

This applies to firefox-119 and may change

Without this change, using the flake produces the following. I don't think the readme should say darwin has first-class nix support, but this is a nice change to have.

direnv: loading ~/f/dev/mutiny-node/.envrc                                                                                                         
direnv: using flake
error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'nix-shell'
         whose name attribute is located at /nix/store/35dcag44a0ymww0vy0s4jjgxwpv9g62d-source/pkgs/stdenv/generic/make-derivation.nix:300:7

       … while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'

         at /nix/store/35dcag44a0ymww0vy0s4jjgxwpv9g62d-source/pkgs/stdenv/generic/make-derivation.nix:344:7:

          343|       depsBuildBuild              = lib.elemAt (lib.elemAt dependencies 0) 0;
          344|       nativeBuildInputs           = lib.elemAt (lib.elemAt dependencies 0) 1;
             |       ^
          345|       depsBuildTarget             = lib.elemAt (lib.elemAt dependencies 0) 2;

       error: Package ‘firefox-119.0’ in /nix/store/35dcag44a0ymww0vy0s4jjgxwpv9g62d-source/pkgs/applications/networking/browsers/firefox/wrapper.nix:421 is not available on the requested hostPlatform:
         hostPlatform.config = "aarch64-apple-darwin"
         package.meta.platforms = [
           "i686-cygwin"
           "x86_64-cygwin"
           "x86_64-darwin"
           "i686-darwin"
           "aarch64-darwin"
           "armv7a-darwin"
           "i686-freebsd13"
           "x86_64-freebsd13"
           "x86_64-solaris"
           "aarch64-linux"
           "armv5tel-linux"
           "armv6l-linux"
           "armv7a-linux"
           "armv7l-linux"
           "i686-linux"
           "loongarch64-linux"
           "m68k-linux"
           "microblaze-linux"
           "microblazeel-linux"
           "mips-linux"
           "mips64-linux"
           "mips64el-linux"
           "mipsel-linux"
           "powerpc64-linux"
           "powerpc64le-linux"
           "riscv32-linux"
           "riscv64-linux"
           "s390-linux"
           "s390x-linux"
           "x86_64-linux"
           "aarch64-netbsd"
           "armv6l-netbsd"
           "armv7a-netbsd"
           "armv7l-netbsd"
           "i686-netbsd"
           "m68k-netbsd"
           "mipsel-netbsd"
           "powerpc-netbsd"
           "riscv32-netbsd"
           "riscv64-netbsd"
           "x86_64-netbsd"
           "i686-openbsd"
           "x86_64-openbsd"
           "x86_64-redox"
         ]
         package.meta.badPlatforms = [
           "x86_64-darwin"
           "i686-darwin"
           "aarch64-darwin"
           "armv7a-darwin"
         ]
       , refusing to evaluate.

       a) To temporarily allow packages that are unsupported for this system, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1

        Note: For `nix shell`, `nix build`, `nix develop` or any other Nix 2.4+
        (Flake) command, `--impure` must be passed in order to read this
        environment variable.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnsupportedSystem = true; }
       in configuration.nix to override this.

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnsupportedSystem = true; }
       to ~/.config/nixpkgs/config.nix.

Copy link
Contributor

@TonyGiorgio TonyGiorgio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the tests still work without Firefox needing to be there? I see geckodriver is still in there. Maybe I put in both without needing to do Firefox at all?

@DanGould
Copy link
Contributor Author

DanGould commented Feb 7, 2024

The tests don't work without firefox. I have firefox installed outside of nix (and open at the time of testing) which seems to be the only option for darwin systems short of emulating a linux system

@DanGould
Copy link
Contributor Author

DanGould commented Feb 7, 2024

I found an overlay for firefox on darwin, but I'm not sure how comprehensive you'd like this fix to be or whether you want to trust that outside overlay

@DanGould
Copy link
Contributor Author

DanGould commented Feb 7, 2024

Gah, while this builds with nix's geckodriver, it won't run in the tests. It's only running for me with local env geckodriver and firefox. I adjusted the PR to reflect this reality.

flake.nix Outdated
Comment on lines 19 to 25
isDarwin = system == "x86_64-darwin" || system == "aarch64-darwin";
# Add firefox deps only on non-darwin.
# darwin is listed in badPlatforms in pkgs.firefox's meta.
optionalPackages = if isDarwin then [] else [
pkgs.firefox
pkgs.geckodriver
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've typically seen things done like this before, would it work here?

          buildInputs = [
            pkgs.bitcoind
            clightning-dev
            pkgs.openssl
            pkgs.zlib
            pkgs.postgresql
            pkgs.gcc
            pkgs.pkg-config
            pkgs.poetry
            pythonEnv
            pkgs.gcc.cc.lib
          ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
            pkgs.libiconv
          ];
        };

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works. pushed the change

Copy link
Contributor

@TonyGiorgio TonyGiorgio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@TonyGiorgio TonyGiorgio merged commit 9e1f35a into MutinyWallet:master Feb 15, 2024
9 checks passed
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.

None yet

2 participants