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 flakes to run firefox-nightly without manually including overlays. #307

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,36 @@ Firefox trademark, held by Mozilla), so you will need to set
``nixpkgs.config.allowUnfree`` in order to use them. More info `here
<https://nixos.wiki/wiki/FAQ#How_can_I_install_a_proprietary_or_unfree_package.3F>`_.

Flake usage
~~~~~~~~~~~

Latest versions of Firefox can be started using flakes, as follows:

``nix run --impure -no-write-lock-file github:mozilla/nixpkgs-mozilla?dir=flakes/nixos-22.11#firefox-nightly``

- The ``--impure`` command line argument is used to allow pulling the latest
pre-built version of Firefox from `archive.mozilla.org`, and checking for the
correct binary signature.

- The ``--no-write-lock-file`` command line argument is to work-around the fact
that this repository does not include lock files. This repository deliberately
does not include lock files! This is made on purpose to use the latest version
of Nixpkgs with all the security fixes applied, instead of using a frozen
version of Nixpkgs anchored in the past which might have known
vulnerabilities.

- The ``github:mozilla/nixpkgs-mozilla`` is this repository, each flake contains a
commented line in case you might want to use local path instead.

- The ``?dir=flakes/nixos-22.11`` is used to refer to the non-default flake
which includes a specific version of Nixpkgs. This one can be changed based on
the content of the `flakes` directory, such as ``?dir=flakes/nixos-unstable``.

- The ``#firefox-nightly`` is the package name, which is also the default in
this case, and can be omitted when looking at firefox-nightly. This can also
be replaced to use different versions such as `firefox-beta`,
`firefox-release` and `firefox-esr`.

Rust overlay
------------

Expand Down Expand Up @@ -72,6 +102,7 @@ Example of using in ```shell.nix```:

Flake usage
-----------

This repository contains a minimal flake interface for the various
overlays in this repository. To use it in your own flake, add it as
an input to your ``flake.nix``:
Expand All @@ -89,6 +120,7 @@ an input to your ``flake.nix``:
};
};
}

The available overlays are ``nixpkgs-mozilla.overlay`` for the
default overlay containing everything, and
``nixpkgs-mozilla.{lib, rust, rr, firefox, git-cinnabar}-overlay``
Expand Down
5 changes: 4 additions & 1 deletion firefox-overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ let

requiredArgs = {
"${nameArg}" = "firefox";
pname = "firefox-bin";
# Note: the default for binary wouldbe to include the -bin suffix,
# however the pname aliases the default program to be used with `nix
# run` command.
pname = "firefox";
desktopName = version.name;
};

Expand Down
21 changes: 21 additions & 0 deletions flakes/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
# nixpkgs-mozilla.url = "/local/path/to/nixpkgs-mozilla";
nixpkgs-mozilla.url = "github:mozilla/nixpkgs-mozilla/master";
};

outputs = {nixpkgs, nixpkgs-mozilla, ...}:
let
latest = (import nixpkgs {
overlays = [ nixpkgs-mozilla.overlays.firefox ];
system = "x86_64-linux";
}).latest;
in {
packages."x86_64-linux".default = latest.firefox-nightly-bin;
packages."x86_64-linux".firefox-nightly = latest.firefox-nightly-bin;
packages."x86_64-linux".firefox-beta = latest.firefox-beta-bin;
packages."x86_64-linux".firefox-release = latest.firefox-release-bin;
packages."x86_64-linux".firefox-esr = latest.firefox-esr-bin;
};
}
12 changes: 12 additions & 0 deletions flakes/nixos-22.11/flake.nix
Copy link
Contributor

Choose a reason for hiding this comment

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

Why? users can just --override-input nixpkgs nixpkgs/nixos-22.11

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is another option, yes, but this would still require ?dir=flakes, as there is no nixpkgs input to the root flake.nix.

Copy link
Contributor

Choose a reason for hiding this comment

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

i think channel specific flakes are unnecessary bloat and it can't be guaranteed that they will always exist many years in the future, while override-input is future proof

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Testing a bit, it seems that the following are already working:

$ nix shell --impure github:nbp/nixpkgs-mozilla?dir=flakes
$ nix shell --impure --override-input nixpkgs nixpkgs/nixos-22.11 github:nbp/nixpkgs-mozilla?dir=flakes

Thanks for the feedback, I will remove the 2 flake.nix which are simply replacing nixpkgs input and add this one as example in the README.

Unfortunately, the nix run command does not work yet, unless we override again the input, as the pname change is not yet part of mozilla/nixpkgs-mozilla, but it can temporarily be achieved with:

$ nix shell --impure --override-input nixpkgs-mozilla github:nbp/nixpkgs-mozilla github:nbp/nixpkgs-mozilla?dir=flakes

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-22.11";
# nixpkgs-mozilla.url = "/local/path/to/nixpkgs-mozilla/flakes";
nixpkgs-mozilla.url = "github:mozilla/nixpkgs-mozilla/master?dir=flakes";
nixpkgs-mozilla.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = {nixpkgs-mozilla, ...}: {
inherit (nixpkgs-mozilla) packages;
};
}
12 changes: 12 additions & 0 deletions flakes/nixos-unstable/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
# nixpkgs-mozilla.url = "/local/path/to/nixpkgs-mozilla/flakes";
nixpkgs-mozilla.url = "github:mozilla/nixpkgs-mozilla/master?dir=flakes";
nixpkgs-mozilla.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = {nixpkgs-mozilla, ...}: {
inherit (nixpkgs-mozilla) packages;
};
}