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

Manage firefox and improve firewall rules #13

Merged
merged 1 commit into from
Nov 27, 2024
Merged
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
1 change: 1 addition & 0 deletions base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[
<home-manager/nixos>
./modules/antivirus.nix
./modules/firefox.nix
./modules/gnome.nix
./modules/jetbrains.nix
./modules/opensnitch.nix
Expand Down
8 changes: 4 additions & 4 deletions home.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{ lib, pkgs, ... }:



{
home.username = "stusmall";
home.homeDirectory = "/home/stusmall";
Expand All @@ -14,7 +11,6 @@
alacritty
chromium
dig
firefox
gnupg
htop
jq
Expand Down Expand Up @@ -91,6 +87,7 @@
};
};


programs.helix = {
enable = true;
};
Expand Down Expand Up @@ -146,6 +143,9 @@
"org/gnome/shell/extensions/dash-to-dock" = {
apply-custom-theme = true;
};
"org/gnome/system/location" = {
enabled = false;
};
};
}

77 changes: 77 additions & 0 deletions modules/firefox.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{ pkgs, lib, ... }:
let
managed-firefox = (pkgs.firefox.override {
extraPolicies = {
AutofillCreditCardEnabled = false;
DisableFirefoxAccounts = true;
DisableFirefoxScreenshots = true;
DisableFirefoxStudies = true;
DisablePocket = true;
DisableTelemetry = true;
DontCheckDefaultBrowser = true;
EnableTrackingProtection = {
Value = true;
Locked = true;
Cryptomining = true;
Fingerprinting = true;
EmailTracking = true;
};
ExtensionSettings = {
"*".installation_mode = "blocked"; # blocks all addons except the ones specified below
# 1Password:
"{d634138d-c276-4fc8-924b-40a0ea21d284}" = {
install_url = "https://addons.mozilla.org/firefox/downloads/latest/1password-x-password-manager/latest.xpi";
installation_mode = "force_installed";
};
# Facebook container
"@contain-facebook" = {
install_url = "https://addons.mozilla.org/firefox/downloads/latest/facebook-container/latest.xpi";
installation_mode = "force_installed";
};
# Impluse Blocker
"{3a7ab27c-6a20-4d24-9fda-5e38f8992556}" = {
install_url = "https://addons.mozilla.org/firefox/downloads/latest/impulse-blocker/latest.xpi";
installation_mode = "force_installed";
};
# ublock origin
"[email protected]" = {
install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi";
installation_mode = "force_installed";
};
};

FirefoxSuggest = {
WebSuggestions = false;
SponsoredSuggestions = false;
ImproveSuggest = false;
Locked = true;
};
PasswordManagerEnabled = false;
PictureInPicture = {
Enabled = true;
Locked = true;
};
};
});
in
{
environment.systemPackages = [
managed-firefox
];


services.opensnitch.rules = {
rule-000-firefox = {
name = "Allow Firefox";
enabled = true;
action = "allow";
duration = "always";
operator = {
type = "simple";
sensitive = false;
operand = "process.path";
data = "${lib.getBin managed-firefox}/lib/firefox/firefox";
};
};
};
}
4 changes: 2 additions & 2 deletions modules/jetbrains.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
type = "simple";
sensitive = false;
operand = "process.path";
data = "${lib.getBin pkgs.jetbrains.jdk})/lib/openjdk/bin/java";
data = "${lib.getBin pkgs.jetbrains.jdk}/lib/openjdk/bin/java";
}
{
type = "regexp";
operand = "dest.host";
sensitive = false;
data = "^(([a-z0-9|-]+\.)*jetbrains\.com|github\.com|([a-z0-9|-]+\.)*schemastore.org)$";
data = "^(([a-z0-9|-]+\.)*jetbrains\.com|github\.com|registry.npmjs.org|([a-z0-9|-]+\.)*schemastore.org)$";
}
];
};
Expand Down
12 changes: 0 additions & 12 deletions modules/opensnitch.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@
enable = true;
settings.DefaultAction = "deny";
rules = {
rule-000-firefox = {
name = "Allow Firefox";
enabled = true;
action = "allow";
duration = "always";
operator = {
type = "simple";
sensitive = false;
operand = "process.path";
data = "${lib.getBin pkgs.firefox}/lib/firefox/firefox";
};
};
rule-000-localhost = {
name = "Allow all localhost";
enabled = true;
Expand Down
5 changes: 4 additions & 1 deletion modules/steam.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
environment.systemPackages = with pkgs; [
steam
];
programs.steam = {
remotePlay.openFirewall = true;
};

services.opensnitch.rules = {
rule-500-steam = {
Expand All @@ -24,7 +27,7 @@
type = "regexp";
operand = "dest.host";
sensitive = false;
data = "^(api.steampowered.com|([a-z0-9|-]+\.)*steamcontent.com|([a-z0-9|-]+\.)*steamstatic.com|([a-z0-9|-]+\.)*steamserver.net|steamcommunity.com|steamstore-a.akamaihd.net|([a-z0-9|-]+\.)*.steampowered.com)$";
data = "^(api.steampowered.com|([a-z0-9|-]+\.)*steamcontent.com|([a-z0-9|-]+\.)*steamstatic.com|([a-z0-9|-]+\.)*steamserver.net|steamcommunity.com|steamstore-a.akamaihd.net|steamuserimages-a.akamaihd.net|steamcommunity-a.akamaihd.net|([a-z0-9|-]+\.)*.steampowered.com|([a-z0-9|-]+\.)*.youtube.com)$";
}
];
};
Expand Down