From 448bf425c3442fccc8742ed4677f25bfdb8fca41 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 26 Jul 2024 18:27:47 -0400 Subject: [PATCH] thelio76: firefox and refactor --- flake.lock | 39 ++++++++++++ flake.nix | 100 ++++++++++++++++--------------- nixos76/alex/home.nix | 41 ++++--------- nixos76/system/configuration.nix | 1 + quick-switch.sh | 28 +++++++-- 5 files changed, 127 insertions(+), 82 deletions(-) diff --git a/flake.lock b/flake.lock index c83eb9c..b9584d7 100644 --- a/flake.lock +++ b/flake.lock @@ -22,6 +22,44 @@ "url": "https://git.atauno.com/atau/atau-nixpkgs" } }, + "firefox-addons": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "dir": "pkgs/firefox-addons", + "lastModified": 1721859466, + "narHash": "sha256-SDLXa2YZiQpsgxPJanbsBETI9LWEHaw+ZgCn0Jb2/HI=", + "owner": "rycee", + "repo": "nur-expressions", + "rev": "e37c395b486aa4fde1dbffd57de6ed5c22eb6495", + "type": "gitlab" + }, + "original": { + "dir": "pkgs/firefox-addons", + "owner": "rycee", + "repo": "nur-expressions", + "type": "gitlab" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1629284811, + "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c5d161cc0af116a2e17f54316f0bf43f0819785c", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -61,6 +99,7 @@ "root": { "inputs": { "atau-nixpkgs": "atau-nixpkgs", + "firefox-addons": "firefox-addons", "home-manager": "home-manager", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index 5c0f427..58c505f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,75 +1,79 @@ { description = "Alex's super mega awesome nixos config"; + # A flake's inputs specify the dependencies that get pulled in. Each input is pinned to a specific version (the git commit) of that dependency. inputs = { nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable; - # unstable.url = "nixpkgs/nixos-unstable"; - atau-nixpkgs.url = "git+https://git.atauno.com/atau/atau-nixpkgs?ref=main&rev=1e72f4b1e9b7a2991e3ccdebbe75d312f016da3b"; - atau-nixpkgs.inputs.nixpkgs.follows = "nixpkgs"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; # This flake also takes in nixpkgs as its own input, so we can override it here to ensure the same pkgs are used! + }; - home-manager.url = "github:nix-community/home-manager"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; + firefox-addons = { + url = "gitlab:rycee/nur-expressions?dir=pkgs/firefox-addons"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + atau-nixpkgs = { + url = "git+https://git.atauno.com/atau/atau-nixpkgs?ref=main&rev=1e72f4b1e9b7a2991e3ccdebbe75d312f016da3b"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, home-manager, ... }@attrs: - # let - # # system = "x86_64-linux"; - # # pkgs = import nixpkgs { - # # # inherit system; - # # config.allowUnfree = true; - # # overlays = [ atau-nixpkgs.overlays.default ]; - # # }; - # in + outputs = { self, nixpkgs, home-manager, firefox-addons, ... }@attrs: { - nixosConfigurations.nixos76 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./nixos76/system/configuration.nix - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.backupFileExtension = "backup"; - home-manager.users.alex = import ./nixos76/alex/home.nix; - # Optionally, use home-manager.extraSpecialArgs to pass - # arguments to home.nix - } - ]; - }; - nixosConfigurations.thelio76 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./thelio76/configuration.nix - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.backupFileExtension = "backup"; - home-manager.users.alex = import ./nixos76/alex/home.nix; - } - ]; - }; - nixosConfigurations.ursa-minor = nixpkgs.lib.nixosSystem - { + nixosConfigurations = { + ## ---- personal computers (linux) ---- + nixos76 = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./nixos76/system/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.backupFileExtension = "backup"; + home-manager.users.alex = import ./nixos76/alex/home.nix; + # Optionally, use home-manager.extraSpecialArgs to pass + # arguments to home.nix + } + ]; + }; + thelio76 = nixpkgs.lib.nixosSystem rec { + system = "x86_64-linux"; + modules = [ + ./thelio76/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.backupFileExtension = "backup"; + home-manager.users.alex = import ./nixos76/alex/home.nix; + home-manager.extraSpecialArgs = { ff = firefox-addons.packages.${system}; }; + } + ]; + }; + + ## ---- servers ---- + ursa-minor = nixpkgs.lib.nixosSystem { system = "aarch64-linux"; modules = [ ./ursa-minor/configuration.nix ]; }; - nixosConfigurations.ursa-major = nixpkgs.lib.nixosSystem - { + ursa-major = nixpkgs.lib.nixosSystem { system = "aarch64-linux"; modules = [ ./ursa-major/configuration.nix ]; }; - nixosConfigurations.atauno = nixpkgs.lib.nixosSystem - { + atauno = nixpkgs.lib.nixosSystem { system = "aarch64-linux"; modules = [ ./atauno/configuration.nix ]; }; + }; }; } diff --git a/nixos76/alex/home.nix b/nixos76/alex/home.nix index 98a5c2d..b760dd5 100644 --- a/nixos76/alex/home.nix +++ b/nixos76/alex/home.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, pkgs, ff, ... }: { # Home Manager needs a bit of information about you and the @@ -67,38 +67,19 @@ }; firefox = { enable = true; - # policies = { - # ExtensionSettings = with builtins; - # let - # extension = shortId: uuid: { - # name = uuid; - # value = { - # install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/${shortId}/latest.xpi"; - # installation_mode = "normal_installed"; - # }; - # }; - # in - # listToAttrs [ - # # (extension "tree-style-tab" "treestyletab@piro.sakura.ne.jp") - # (extension "ublock-origin" "uBlock0@raymondhill.net") - # # (extension "bitwarden-password-manager" "{446900e4-71c2-419f-a6a7-df9c091e268b}") - # # (extension "tabliss" "extension@tabliss.io") - # (extension "umatrix" "uMatrix@raymondhill.net") - # # (extension "libredirect" "7esoorv3@alefvanoon.anonaddy.me") - # # (extension "clearurls" "{74145f27-f039-47ce-a470-a662b129930a}") - # ]; - # }; - profiles = { - default = { - containers = { - google = { - color = "green"; - id = 1; - }; - }; + profiles.default = { + settings = { + "extensions.autoDisableScopes" = 0; }; + extensions = with ff; [ + darkreader + multi-account-containers + ublock-origin + umatrix + ]; }; }; + git = { enable = true; userEmail = "alexmat2on@protonmail.com"; diff --git a/nixos76/system/configuration.nix b/nixos76/system/configuration.nix index 7956c20..16b4f23 100644 --- a/nixos76/system/configuration.nix +++ b/nixos76/system/configuration.nix @@ -30,6 +30,7 @@ # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + # What was this for? maybe wireguard? networking.firewall = { allowedUDPPorts = [ 51820 22000 ]; # Clients and peers can use the same port, see listenport allowedTCPPorts = [ 22000 48412 62109 ]; diff --git a/quick-switch.sh b/quick-switch.sh index 09fe37c..4414cc5 100755 --- a/quick-switch.sh +++ b/quick-switch.sh @@ -1,14 +1,34 @@ #!/usr/bin/env bash set -euo pipefail -if [ -z "$(git status --porcelain)" ] -then +function yes_or_no { + while true; do + read -p "$* [y/n]: " yn + case $yn in + [Yy]*) return 0 ;; + [Nn]*) echo "Aborted" ; return 1 ;; + esac + done +} + +function apply() { git push --force-with-lease rev=$(git rev-parse HEAD) sudo nixos-rebuild switch \ --flake "git+https://git.atauno.com/atau/nixos-config.git?ref=main&rev=$rev" +} + +function commit_and_apply() { + read -p "Enter a commit message: " msg + git add . + git commit -m "$(hostname): $msg" + apply +} + +if [ -z "$(git status --porcelain)" ] +then + apply else - echo "Git working directory is unclean, please commit changes" - exit 1 + yes_or_no "Git working directory is unclean, would you like to commit changes?" && commit_and_apply fi