Giter Club home page Giter Club logo

arkenfox-nixos's Introduction

Arkenfox user.js module for NixOS + home-manager

Motivation

Firefox's user.js can be used to store preferences and settings for Firefox, but it is painful to manually edit. There is a popular user.js optimised for ease of edition and hardening : Arkenfox's.

If one want to directly use it, there already is an option in home-manager to use a user.js : programs.firefox.profiles.<name>.extraConfig and programs.firefox.profiles.<name>.settings.

The problem with directly using Arkenfox's user.js is that handling updates to file after having gone through it to edit your preferences is a bit of a pain. In order to improve the situation, we implemented a script that parses Arkenfox's user.js and generate a home-manager module that allows setting the preferences using the merge algorithm of the NixOS module system. Furthermore, it keeps the edits outside the generated module. Any drift between the settings and the user.js will be caught by the module type-system.

Outputs

This flake exports a few things :

  • the script used for the extraction as packages.<system>.arkenfox-extractor.
  • the home-manager module as hmModules.arkenfox.
  • a rendered documentation of each supported user.js version as packages.<system>.arkenfox-v<version>-doc-static. Here version can be either a numeric one like 103_0 or master.

Home-manager module

To enable the module, you need to set both programs.firefox.arkenfox.enable to true and programs.firefox.arkenfox.version to the version you want to use. Ideally the version used is the same as Firefox's, but may differ if arkenfox hasn't yet been updated, or you want to keep your previous settings with the new Firefox version. In the case the versions do not match, a warning will be displayed when generating the configuration.

Then the settings can be set profile-by-profile using programs.firefox.profiles.<name>.arkenfox. The user.js file is subdivided into sections, subsections and individual settings that all have a default value, and may be commented or not. All this is present in the module. A setting can be set with <section-number>.<subsection-number>.<setting-name>.value and enabled with <section-number>.<subsection-number>.<setting-name>.enable. Sections and subsections can also be enabled and disabled. A setting value is only set if both its sections and subsection are enabled. Furthermore, a top level enable flag is present.

Since Arkenfox's settings are very opinionated and shouldn't be used unless they've been reviewed and agreed with, both the top level enable flag and all sections enable flags are false by default. On the other hand, the subsections enable flags are true by default.

For example, if you want to enable the TOPLEVEL, STARTUP and GEOLOCATION sections, but still have Firefox check if it is the default browser, and you want to enable the search region setting that is commented in the default user.js but keep its value, you would do:

{
  programs.firefox = {
    enable = true;
    arkenfox = {
      enable = true;
      version = "103.0";
    };
    
    profiles.Default.arkenfox = {
      enable = true;
      "0000".enable = true;
      "0001" = {
        enable = true;
        "0101"."browser.shell.checkDefaultBrowser".value = true;
      };
      "0002" = {
        enable = true;
        "0204"."browser.search.region".enable = true;
      };
    };
  };
}

Documentation

Finding the section and subsection numbers and the option names can be a bit complicated. The authoritative source of truth is of course the user.js file on Arkenfox's GitHub, which you should read, at least the section you enable. For better usability, the metadata extracted is also used to generate a HTML file that may be more agreeable looking through.

Targets programs.<system>.arkenfox-v<version>-doc-static will build this html file. An example of a rendered documentation (WARNING: often outdated) can be found there. Each setting is presented as a table with a checkbox indicating if it is enabled by default, its name, and its default value.

You can build the documentation without copying the flake using (for example):

nix build "github:dwarfmaster/arkenfox-nixos#arkenfox-v103_0-doc-static"

arkenfox-nixos's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

arkenfox-nixos's Issues

Add Darwin Build support

Hello,

I am trying to integrate your project into my personal config flake, and it works as expected on x86 linux. However when I attempt to build on my x86_64-darwin machine, I get the error:

error: a 'x86_64-linux' with features {} is required to build '/nix/store/fdyjg3gkpw67vbbw5337bzm3a13kw520-arkenfox-extractor.drv', but I am a 'x86_64-darwin' with features {benchmark, big-parallel, nixos-test} (use '--show-trace' to show detailed location information)

Darwin support in the future would be greatly appreciated!

Is it working or not?

Hey!
Is this an working snippet?

programs.firefox = {
 enable.true;
 arkenfox = {
        enable = true;
        version = "122.0";
      };
 profiles = {
       "${config.home.username}" = {
         id = 0;
         name = "${config.home.username}";

         settings = {
           ...
           "0105".enable = true; 
           ...
          };
      };
   };
 };

The user.js file is as follows:

user_pref("0105", "{\"enable\":true}");

?!?!?

Evaluation error: `error: attribute 'meta' already defined`

Latest commit introduced an error for me:

[azahi@eonwe:~/src/nixfiles]$ nixos-rebuild build --flake .
building the system configuration...
error: attribute 'meta' already defined at /nix/store/6374accpf21d1l5w5f2dbg51vbb5q4x9-user.js:2468:7

       at /nix/store/6374accpf21d1l5w5f2dbg51vbb5q4x9-user.js:2451:7:

         2450|       ];
         2451|       meta = {
             |       ^
         2452|         title = "disable Form Autofill";
(use '--show-trace' to show detailed location information)

Full trace is here, if required. My config is here, just in case.

How do I use the module?

I'm probably making a silly error but I'm not sure how to use the module? I add it to my flake and I still get a

error: The option home-manager.users.maedayscout.programs.firefox.arkenfox does not exist. Definition values:
       - In /nix/store/n97rpbbqjprlyqwcwa09gl88isgbvmz2-source/flake.nix:
           {
             enable = true;
             version = "103.0";
           }

Here's my flake

{
 inputs = {
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    arkenfox.url = "git+https://github.com/dwarfmaster/arkenfox-nixos?ref=main";
    arkenfox.inputs.nixpkgs.follows = "nixpkgs";
  };
  outputs = { self, nixpkgs, home-manager, arkenfox, ... }: {
    nixosConfigurations."0x4d6165-x360-nixos" = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [ ./configuration.nix
        home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.maedayscout = {nixpkgs, ...}: {
            services.gammastep = {
                enable = true;
                provider = "geoclue2";
            };

            services.mpd = {
                enable = true;
                musicDirectory = "/home/maedayscout/Music/";
                extraConfig = ''
                # must specify one or more outputs in order to play audio!
                # (e.g. ALSA, PulseAudio, PipeWire), see next sections
            audio_output {
                type "alsa"
                name "My ALSA"
                mixer_type		"hardware"
                mixer_device	"default"
                mixer_control	"PCM"
                }
                '';
                # Optional:
            };
            services.mpd-discord-rpc.enable = true;
            services.mpdris2 = {
                enable = true;
                notifications = true;
                multimediaKeys = true;
            };

            programs.direnv.enable = true;
            programs.direnv.nix-direnv.enable = true;
            programs.direnv.enableZshIntegration = true;

            programs.starship = {
                enable = true;
                enableZshIntegration = true;
            };
            programs.zoxide = {
                enable = true;
                enableZshIntegration = true;
            };
            programs.git = {
                enable = true;
                userName = "Mae Miller";
                userEmail = "[email protected]";
                signing.key = "317F7B2642173F9C";
                signing.signByDefault = true;
                package = nixpkgs.gitFull;
            };
            services.swayidle = {
                enable = true;
                timeouts = [
                {
                    timeout = 1800;
                    command = "${nixpkgs.swaylock}/bin/swaylock";
                }
                {
                    timeout = 1800;
                    command = "${nixpkgs.sway}/bin/swaymsg 'output * dpms off'";
                    resumeCommand = "${nixpkgs.sway}/bin/swaymsg 'output * dpms on'";
                }
                {
                    timeout = 2005;
                    command = "systemctl suspend";
                }
                ];
                events = [
                {
                    event = "before-sleep";
                    command = "${nixpkgs.swaylock}/bin/swaylock";
                }
                ];
            };
            home.packages = [
                (nixpkgs.rofi-wayland.override {"plugins" = [nixpkgs.rofi-calc nixpkgs.rofi-emoji];})
                nixpkgs.dconf
            ];
            programs.zsh = {
                enable = true;
                shellAliases = {
                cp = "cp -i";
                mv = "mv -i";
                };
                initExtra = "
                    set -o noclobber

                    export TERM=xterm-256color
                    fpath+=~/.zfunc
                    # Lines configured by zsh-newuser-install
                    HISTFILE=~/.histfile
                    HISTSIZE=1000
                    SAVEHIST=1000
                    setopt autocd extendedglob notify
                    unsetopt beep
                    export EDITOR=vim
                    bindkey -e

                    export MOZ_ENABLE_WAYLAND=1
                    export QT_STYLE_OVERRIDE='kvantum'
                    export GTK_THEME=Catppuccin-Macchiato-Standard-Mauve-Dark
                    export _JAVA_AWT_WM_NONREPARENTING=1

                    autoload -Uz compinit
                    compinit

                    ### Added by Zinit's installer
                    export HISTORY_SUBSTRING_SEARCH_FUZZY='y'


                    source ${nixpkgs.zinit}/share/zinit/zinit.zsh	
                    zinit load zsh-users/zsh-syntax-highlighting
                    zinit load zsh-users/zsh-autosuggestions
                    zinit load zsh-users/zsh-history-substring-search
                    zinit load johannchangpro/zsh-interactive-cd

                    bindkey \"$terminfo[kcuu1]\" history-substring-search-up
                    bindkey \"$terminfo[kcud1]\" history-substring-search-down
                    bindkey  \"^[[H\"   beginning-of-line
                    bindkey  \"^[[F\"   end-of-line
                    bindkey  \"^[[3~\"  delete-char
                    export GOPATH=~/go

                    if [[ -o interactive ]] then
                    PF_INFO='ascii title os host kernel uptime memory wm'  ~/.misc/pfetch/pfetch 
                    fi

                    fpath+=~/.zfunc
                ";
            };
            programs.fish = {
                enable = true;
                shellInit = "
                set -Ux EDITOR 'vim'

                set -Ux MOZ_ENABLE_WAYLAND 1
                set -Ux QT_STYLE_OVERRIDE 'kvantum'
                set -Ux GTK_THEME 'Catppuccin-Macchiato-Standard-Mauve-Dark'
                set -Ux _JAVA_AWT_WM_NONREPARENTING '1'

                set -Ux PYTHON_KEYRING_BACKEND 'keyring.backends.null.Keyring'

                alias cp 'cp -i'
                alias mv 'mv -i'

                if status is-interactive
                    # Commands to run in interactive sessions can go here
                    ~/.local/bin/afetch
                end

                starship init fish | source
                zoxide init fish | source
                direnv hook fish | source
                ";
            };
            gtk = {
                enable = true;
                theme = {
                name = "Catppuccin-Macchiato-Compact-Pink-dark";
                package = nixpkgs.catppuccin-gtk.override {
                    accents = ["mauve"];
                    variant = "macchiato";
                };
                };
                iconTheme = {
                name = "Papirus-Dark";
                package = nixpkgs.papirus-icon-theme;
                };
                cursorTheme = {
                name = "Catppuccin-Macchiato-Mauve-Cursors";
                package = nixpkgs.catppuccin-cursors.macchiatoMauve;
                };
                gtk3.extraConfig = {
                Settings = ''
                    gtk-application-prefer-dark-theme=1
                '';
                };

            gtk4.extraConfig = {
                Settings = ''
                    gtk-application-prefer-dark-theme=1
                '';
                };
            };
            programs.firefox = {
            enable = true;
            package = nixpkgs.firefox-devedition-bin;
            arkenfox = {
                enable = true;
                version = "103.0";
            };
            profiles.Default.arkenfox = {
                enable = true;
                "0000".enable = true;
                "0001" = {
                enable = true;
                "0101"."browser.shell.checkDefaultBrowser".value = true;
                };
                "0002" = {
                enable = true;
                "0204"."browser.search.region".enable = true;
                };
            };
            };

            home.stateVersion = "23.05";
            };
          }
        ];
    };
  };
}

Betterfox user.js repo for NixOS

I would like to create a repo for the betterfox user.js.
It's a more casual collection than arkenfox's one and enhances the browser experience.

So, I forked this project and noticed that the syntax from the betterfox user.js is a bit different than the arkenfox user.js.
I'm not sure if that's the main problem but I don't know why the github action does create empty files. Maybe there is a typo in my config?

Any ideas on how to fix or debug this problem?
Thanks in advance ๐Ÿ˜ƒ.

Need help, NixOS-config doesn't build

Hi, I'm new to nix and NixOS and would like to use this firefox option to add the user.js automatically.
Unfortunately, I think I missed something from your documentation because there is an error while building the config.

I added this part to my config and don't know what else I should do to fix the problem:

# firefox.nix 
{ pkgs, inputs,  ... }:
{
  programs.firefox = {
    enable = true;
    arkenfox = {
      enable = true;
      version = "119.0";
    };

    profiles.testing = {
    
      arkenfox = {
        enable = true;
      };
    };
  };
}

And this is the error:

error: The option `home-manager.users.tom.programs.firefox.arkenfox' does not exist. Definition values:
       - In `/home/tom/.dotfiles/nixos-config/firefox.nix':
           {
             enable = true;
             version = "119.0";
           }

How do I enable this option for home-manager?

prefsCleaner?

I couldn't find any mention of the prefsCleaner.

How/When do you trigger the script?
It could be called via home.activation but maybe not a great idea because the Firefox profile shouldn't be in use when running prefsCleaner...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.