From c22ed6af62b5206e01724fc0e30440ba2c88746a Mon Sep 17 00:00:00 2001 From: Steph Date: Tue, 29 Oct 2024 08:12:05 +0100 Subject: [PATCH] Mac config --- flake.lock | 57 +++++++++++++- flake.nix | 22 ++++-- home.nix | 138 +++++++++------------------------ configuration.nix => nixos.nix | 30 +------ platforms/darwin/home.nix | 8 ++ platforms/linux/home.nix | 90 +++++++++++++++++++++ programs/bash.nix | 11 +-- programs/firefox.nix | 115 ++++++++++++++++----------- programs/fish.nix | 74 ++++++++++++++++++ programs/helix.nix | 31 ++++++++ programs/kakoune.nix | 4 +- programs/pastebin.nix | 4 +- 12 files changed, 389 insertions(+), 195 deletions(-) rename configuration.nix => nixos.nix (84%) create mode 100644 platforms/darwin/home.nix create mode 100644 platforms/linux/home.nix create mode 100644 programs/fish.nix create mode 100644 programs/helix.nix diff --git a/flake.lock b/flake.lock index 7b16a60..1f09185 100644 --- a/flake.lock +++ b/flake.lock @@ -26,11 +26,11 @@ "firefox-gnome-theme": { "flake": false, "locked": { - "lastModified": 1723137499, - "narHash": "sha256-MOE9NeU2i6Ws1GhGmppMnjOHkNLl2MQMJmGhaMzdoJM=", + "lastModified": 1728654484, + "narHash": "sha256-J53bks/1loTdXiSQz1OlOAc8jx9g399oF1YiXAX2JKQ=", "owner": "rafaelmardojai", "repo": "firefox-gnome-theme", - "rev": "fb5b578a4f49ae8705e5fea0419242ed1b8dba70", + "rev": "e53b84d428e7f5ba0f04d6a91e6cc6c05c75b632", "type": "github" }, "original": { @@ -39,6 +39,22 @@ "type": "github" } }, + "firefox-macos-theme": { + "flake": false, + "locked": { + "lastModified": 1729993006, + "narHash": "sha256-8YGR0HuMcxGQBDlhP+kUriYDOpP7geHvGc+sEu167Dk=", + "owner": "AdamXweb", + "repo": "WhiteSurFirefoxThemeMacOS", + "rev": "4665c5b6e03127597c7cf99d91b676c9d1fca95d", + "type": "github" + }, + "original": { + "owner": "AdamXweb", + "repo": "WhiteSurFirefoxThemeMacOS", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1629284811, @@ -75,7 +91,38 @@ "type": "github" } }, + "nix-darwin": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1730070491, + "narHash": "sha256-+RYCbdU6l4E4pr40++lrdhdE3gNC/BR54AL7xWG/YRU=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "5c0c6aaa797d6ccbb6cdab14de0248135735709d", + "type": "github" + }, + "original": { + "id": "nix-darwin", + "type": "indirect" + } + }, "nixpkgs": { + "locked": { + "lastModified": 1718149104, + "narHash": "sha256-Ds1QpobBX2yoUDx9ZruqVGJ/uQPgcXoYuobBguyKEh8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e913ae340076bbb73d9f4d3d065c2bca7caafb16", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1727540905, "narHash": "sha256-40J9tW7Y794J7Uw4GwcAKlMxlX2xISBl6IBigo83ih8=", @@ -110,8 +157,10 @@ "inputs": { "firefox-addons": "firefox-addons", "firefox-gnome-theme": "firefox-gnome-theme", + "firefox-macos-theme": "firefox-macos-theme", "home": "home", - "nixpkgs": "nixpkgs", + "nix-darwin": "nix-darwin", + "nixpkgs": "nixpkgs_2", "nur": "nur" } } diff --git a/flake.nix b/flake.nix index a6012f5..eae8541 100644 --- a/flake.nix +++ b/flake.nix @@ -8,25 +8,26 @@ home.inputs.nixpkgs.follows = "nixpkgs"; firefox-gnome-theme = { url = "github:rafaelmardojai/firefox-gnome-theme"; flake = false; }; + firefox-macos-theme = {url = "github:AdamXweb/WhiteSurFirefoxThemeMacOS"; flake = false; }; firefox-addons = { url = "gitlab:rycee/nur-expressions?dir=pkgs/firefox-addons"; inputs.nixpkgs.follows = "nixpkgs"; }; nur.url = "github:nix-community/NUR"; }; - outputs = { self, nixpkgs, home, firefox-gnome-theme, firefox-addons, nur }@inputs: { + outputs = { self, nixpkgs, home, firefox-gnome-theme, firefox-addons, nur, nix-darwin, firefox-macos-theme }@inputs: { nixosConfigurations.iota = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ home.nixosModules.home-manager { imports = [ - ./configuration.nix + ./nixos.nix ./hardware-configuration/iota.nix {_module.args = {inherit inputs;};} ]; - home-manager.users.steph = import ./home.nix; + home-manager.users.steph = { imports = [ ./home.nix ./platforms/linux/home.nix ]; }; home-manager.useGlobalPkgs = true; - home-manager.extraSpecialArgs = { inherit inputs ; }; + home-manager.extraSpecialArgs = { inherit inputs ; os = "linux"; }; } ]; }; @@ -36,16 +37,21 @@ home.nixosModules.home-manager { imports = [ - ./configuration.nix + ./nixos.nix ./hardware-configuration/tau.nix {_module.args = {inherit inputs;};} ]; - home-manager.users.steph = import ./home.nix; + home-manager.users.steph = { imports = [ ./home.nix ./platforms/linux/home.nix ]; }; home-manager.useGlobalPkgs = true; - home-manager.extraSpecialArgs = { inherit inputs ; }; + home-manager.extraSpecialArgs = { inherit inputs ; os = "linux"; }; } ]; }; - + homeConfigurations.stephans = home.lib.homeManagerConfiguration rec { + pkgs = nixpkgs.legacyPackages."aarch64-darwin"; + extraSpecialArgs = { inherit inputs ; os = "darwin"; }; + modules = [ ./home.nix ./platforms/darwin/home.nix ]; + }; + }; } diff --git a/home.nix b/home.nix index e3d3be6..f200d20 100644 --- a/home.nix +++ b/home.nix @@ -1,125 +1,57 @@ -{config, lib, pkgs, inputs, ...}: { +{config, lib, pkgs, inputs, os, ...}: { + imports = [ + ./programs/tmux.nix + ./programs/bash.nix + ./programs/kakoune.nix + ./programs/pastebin.nix + ./programs/helix.nix + ./programs/firefox.nix + ]; - imports = [ - ./programs/firefox.nix - ./programs/tmux.nix - ./programs/bash.nix - ]; - + options = {}; + + config = { home.stateVersion = "22.05"; + programs.home-manager.enable = true; - home.packages = with pkgs; [ + nixpkgs = { + config.allowUnfree = true; + overlays = [ inputs.nur.overlay ]; + }; + + home.packages = with pkgs; [ bat bottom - dino - direnv - element-desktop - endeavour + btop + entr eza fd file - foliate fortune - fragments git - gparted htop - inkscape - lf - libreoffice - minetest - mpv - mumble neovim - nextcloud-client - nix-direnv nodejs-18_x - obs-studio - openvpn - pinta - prismlauncher + pandoc ripgrep - sequeler - skim sqlite sqlite.dev - stack - steam-run - syncplay - tdesktop - thunderbird - tmux - tuba - ungoogled-chromium + texliveFull unzip vim vscodium wget - widevine-cdm - wl-clipboard zip - zotero - thunderbird - signal-desktop - entr - pandoc - texliveFull + coreutils + + # fonts + (nerdfonts.override { fonts = [ "FiraCode" "DroidSansMono" ]; }) + noto-fonts + noto-fonts-cjk + noto-fonts-emoji + inter + google-fonts + vistafonts ]; - - programs.home-manager.enable = true; - - dconf.settings = { - "org/gnome/desktop/wm/keybindings" = { - move-to-workspace-left = ["Left"]; - move-to-workspace-right = ["Right"]; - switch-to-workspace-left = ["Left"]; - switch-to-workspace-right = ["Right"]; - - switch-applications = ["Tab"]; - switch-applications-backward = ["Tab"]; - switch-windows = ["Tab"]; - switch-windows-backward = ["Tab"]; - }; - "org/gnome/settings-daemon/plugins/media-keys" = { - custom-keybindings = ["/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/"]; - }; - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" = { - binding = "t"; - command = "kgx"; - name = "gnome-console"; - }; - "org/gnome/desktop/interface" = { - clock-show-weekday = true; - }; - "org/gnome/desktop/peripherals/touchpad" = { - tap-to-click = true; - two-finger-scrolling-enabled = true; - }; - "org/gnome/shell" = rec { - enabled-extensions = [ - "trayIconsReloaded@selfmade.pl" - "AlphabeticalAppGrid@stuarthayhurst" - "clipboard-history@alexsaveau.dev" - "noannoyance@daase.net" - ]; - # disabled-extensions = builtins.filter (x: ! builtins.elem x enabled-extensions) disabled-extensions; - favorite-apps = [ - "firefox.desktop" - "chromium-browser.desktop" - "org.gnome.Console.desktop" - "org.gnome.Nautilus.desktop" - "thunderbird.desktop" - "signal-desktop.desktop" - "element-desktop.desktop" - "org.telegram.desktop.desktop" - "im.dino.Dino.desktop" - ]; - }; - "org/gnome/desktop/background" = { - "picture-uri" = "${config.home.homeDirectory}/.background-image"; - }; - }; - - home.file.".background-image".source = "${./.}/Morskie Oko.jpg"; - -} + }; +} \ No newline at end of file diff --git a/configuration.nix b/nixos.nix similarity index 84% rename from configuration.nix rename to nixos.nix index c19fdac..7cbea58 100644 --- a/configuration.nix +++ b/nixos.nix @@ -3,8 +3,7 @@ { imports = [ - ./programs/kakoune.nix - ./programs/pastebin.nix + ]; nix = { @@ -14,9 +13,7 @@ ''; }; - nixpkgs.overlays = [ - inputs.nur.overlay - ]; + networking.networkmanager.enable = true; @@ -79,37 +76,16 @@ description = "Steph"; extraGroups = [ "networkmanager" "wheel" "dialout" "podman" "docker" ]; packages = with pkgs; [ - + # Use home-manager doofus ]; }; - networking.firewall.allowedTCPPorts = [ 8080 ]; - networking.extraHosts = '' - 86.95.92.180 apprise.prod.gaiaplant.app - 192.145.59.184 marshallingyard.steph.tools - ''; - services.avahi.enable = false; virtualisation.podman.enable = true; virtualisation.docker.enable = true; - nixpkgs.config.allowUnfree = true; - - fonts.packages = with pkgs; [ - (nerdfonts.override { fonts = [ "FiraCode" "DroidSansMono" ]; }) - noto-fonts - noto-fonts-cjk - noto-fonts-emoji - inter - google-fonts - vistafonts - ]; - environment.systemPackages = with pkgs; [ - podman - docker-compose - fprintd libfprint-2-tod1-vfs0090 udev diff --git a/platforms/darwin/home.nix b/platforms/darwin/home.nix new file mode 100644 index 0000000..53e9227 --- /dev/null +++ b/platforms/darwin/home.nix @@ -0,0 +1,8 @@ +{config, lib, pkgs, inputs, os, ...}: { + home.username = "stephans"; + home.homeDirectory = "/Users/stephans"; + + home.packages = with pkgs; [ + + ]; +} \ No newline at end of file diff --git a/platforms/linux/home.nix b/platforms/linux/home.nix new file mode 100644 index 0000000..0eb9cfd --- /dev/null +++ b/platforms/linux/home.nix @@ -0,0 +1,90 @@ +{config, lib, pkgs, inputs, os, ...}: { + imports = [ + + ]; + + home.packages = with pkgs; [ + element-desktop + + # gnome apps + endeavour + foliate + fragments + gparted + inkscape + lf + libreoffice + minetest + mpv + mumble + nextcloud-client + obs-studio + openvpn + pinta + prismlauncher + sequeler + syncplay + tdesktop + thunderbird + tuba + ungoogled-chromium + widevine-cdm + wl-clipboard + zotero + signal-desktop + ]; + + dconf.settings = { + "org/gnome/desktop/wm/keybindings" = { + move-to-workspace-left = ["Left"]; + move-to-workspace-right = ["Right"]; + switch-to-workspace-left = ["Left"]; + switch-to-workspace-right = ["Right"]; + + switch-applications = ["Tab"]; + switch-applications-backward = ["Tab"]; + switch-windows = ["Tab"]; + switch-windows-backward = ["Tab"]; + }; + "org/gnome/settings-daemon/plugins/media-keys" = { + custom-keybindings = ["/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/"]; + }; + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" = { + binding = "t"; + command = "kgx"; + name = "gnome-console"; + }; + "org/gnome/desktop/interface" = { + clock-show-weekday = true; + }; + "org/gnome/desktop/peripherals/touchpad" = { + tap-to-click = true; + two-finger-scrolling-enabled = true; + }; + "org/gnome/shell" = rec { + enabled-extensions = [ + "trayIconsReloaded@selfmade.pl" + "AlphabeticalAppGrid@stuarthayhurst" + "clipboard-history@alexsaveau.dev" + "noannoyance@daase.net" + ]; + # disabled-extensions = builtins.filter (x: ! builtins.elem x enabled-extensions) disabled-extensions; + favorite-apps = [ + "firefox.desktop" + "chromium-browser.desktop" + "org.gnome.Console.desktop" + "org.gnome.Nautilus.desktop" + "thunderbird.desktop" + "signal-desktop.desktop" + "element-desktop.desktop" + "org.telegram.desktop.desktop" + "im.dino.Dino.desktop" + ]; + }; + "org/gnome/desktop/background" = { + "picture-uri" = "${config.home.homeDirectory}/.background-image"; + }; + }; + + home.file.".background-image".source = "${./.}/Morskie Oko.jpg"; +} \ No newline at end of file diff --git a/programs/bash.nix b/programs/bash.nix index 58c3695..1b45613 100644 --- a/programs/bash.nix +++ b/programs/bash.nix @@ -1,4 +1,4 @@ -{config, lib, pkgs, inputs, ...} : { +{config, lib, pkgs, inputs, os, ...} : { programs.bash.enable = true; programs.bash.bashrcExtra = '' if [ -n "$PS1" ]; then @@ -25,8 +25,6 @@ $NEW_PROMPT_COMMAND" export PS1="[\t \[\e[32m\]\u\[\e[m\]\[\e[32m\]@\[\e[m\]\[\e[32m\]\h\[\e[m\]]"'$SHELL_PREFIX'" \[\e[36m\]"'$TRIMMED_PWD'"\[\e[m\] \$ " fi - - eval "$(direnv hook bash)" ''; programs.bash.shellAliases = { chmod = "chmod --preserve-root"; @@ -36,10 +34,13 @@ $NEW_PROMPT_COMMAND" free = "free -h"; toupper = "tr [:lower:] [:upper:]"; tolower = "tr [:upper:] [:lower:]"; - rebuild = '' - nixos-rebuild switch --flake "$HOME/.local/os#" --use-remote-sudo + rebuild = if (os == "linux") then '' + nixos-rebuild switch --flake "path:$HOME/.local/os#" --use-remote-sudo + '' else '' + home-manager switch ''; ":r" = "!!"; + ":wq" = "exit"; }; programs.bash.sessionVariables = { NIX_SHELL_PRESERVE_PROMPT = 1; diff --git a/programs/firefox.nix b/programs/firefox.nix index bde9c9c..311c4bd 100644 --- a/programs/firefox.nix +++ b/programs/firefox.nix @@ -1,46 +1,73 @@ -{config, lib, pkgs, inputs, ...} : { - home.file.".mozilla/firefox/default/chrome/firefox-gnome-theme".source = inputs.firefox-gnome-theme; - programs.firefox.enable = true; - programs.firefox.profiles.default = { - userChrome = '' - @import "firefox-gnome-theme/userChrome.css"; - ''; - userContent = '' - @import "firefox-gnome-theme/userContent.css"; - ''; - settings = { - "toolkit.legacyUserProfileCustomizations.stylesheets" = true; # Enable customChrome.cs - "browser.uidensity" = 0; # Set UI density to normal - "svg.context-properties.content.enabled" = true; # Enable SVG context-propertes - "browser.theme.dark-private-windows" = false; # Disable private window dark theme - "extensions.autoDisableScopes" = 0; # Auto enable new extentions - "browser.toolbars.bookmarks.visibility" = "never"; - "gnomeTheme.hideSingleTab" = true; - "signon.rememberSignons" = false; - "dom.private-attribution.submission.enabled" = false; - }; - extensions = with pkgs.nur.repos.rycee.firefox-addons; [ - ublock-origin - bitwarden - consent-o-matic - wayback-machine - h264ify - sponsorblock - fediact - multi-account-containers - tampermonkey - ]; - search = { - default = "DuckDuckGo"; - force = true; - }; - containers = { - "Lekker van Peet" = { - color = "toolbar"; - icon = "circle"; - id = 2; +{config, lib, pkgs, inputs, os, ...} : lib.mkMerge [ + + (lib.mkIf (os == "linux") { + home.file.".mozilla/firefox/default/chrome/theme".source = + inputs.firefox-gnome-theme; + }) + + (lib.mkIf (os == "darwin") { + home.file."/Users/stephans/Library/Application Support/Firefox/Profiles/default/chrome/theme".source = + inputs.firefox-macos-theme; + }) + + { + programs.firefox = lib.mkMerge [ + (lib.mkIf (os == "darwin") { + package = null; + }) + { + enable = true; + profiles.default = { + isDefault = true; + userChrome = if (os == "linux") then '' + @import "theme/userChrome.css"; + '' else '' + @import "theme/chrome/userChrome.css"; + ''; + userContent = if (os == "linux") then '' + @import "theme/userContent.css"; + '' else '' + @import "theme/chrome/userContent.css"; + ''; + settings = { + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; # Enable customChrome.cs + "browser.uidensity" = 0; # Set UI density to normal + "svg.context-properties.content.enabled" = true; # Enable SVG context-propertes + "browser.theme.dark-private-windows" = false; # Disable private window dark theme + "extensions.autoDisableScopes" = 0; # Auto enable new extentions + "browser.toolbars.bookmarks.visibility" = "never"; + "gnomeTheme.hideSingleTab" = true; + "signon.rememberSignons" = false; + "dom.private-attribution.submission.enabled" = false; }; + extensions = with pkgs.nur.repos.rycee.firefox-addons; [ + ublock-origin + bitwarden + consent-o-matic + sponsorblock + multi-account-containers + ] ++ (if (os == "darwin") then [ + onepassword-password-manager + ] else [ + wayback-machine + h264ify + fediact + tampermonkey + ]); + search = { + default = "DuckDuckGo"; + force = true; + }; + containers = { + "Lekker van Peet" = { + color = "toolbar"; + icon = "circle"; + id = 2; + }; + }; + containersForce = true; }; - containersForce = true; - }; -} \ No newline at end of file + } + ]; + } +] \ No newline at end of file diff --git a/programs/fish.nix b/programs/fish.nix new file mode 100644 index 0000000..57bba9c --- /dev/null +++ b/programs/fish.nix @@ -0,0 +1,74 @@ +{ config , pkgs , ... } : { + programs.fish = { + enable = true ; + functions = { + fish_prompt = '' + # get status to set colour later + set -f s $status + + # nix shell component + set pkgs (echo $PATH | tr ' ' "\n" | grep '^/nix/store' \ + | sed 's#^[^-]*-##;s#-[^-]*$##' | xargs) + if test -n "$pkgs" + set_color yellow + echo -n "nix: $pkgs " + end + + # ssh component + if test -n "$SSH_CLIENT$SSH_TTY$SSH_CONNECTION" + set_color blue + echo -n (whoami)@(hostname)' ' + end + + # pwd + test $s -eq 0 && set_color magenta || set_color red + echo -n (prompt_pwd) + + # git component + set_color green + set branch (git branch 2> /dev/null | grep '^*' \ + | cut -d'*' -f 2) + set_color green + echo -n $branch + + # prompt component + set_color brwhite + echo -n ' $ ' + set_color normal + '' ; + fish_greeting = '' + source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish + '' ; + mkcd = "mkdir -p $argv && cd $argv" ; + xv = "touch $argv && chmod +x $argv && hx $argv" ; + clwy = '' + curl -s -X POST -H "Content-Type: text/plain" -d "$argv" \ + 'https://jerl.zone/contact' > /dev/null + '' ; + } ; + shellAbbrs = { + gs = "git status" ; + gc = "git commit" ; + gca = "git commit --amend" ; + ga = "git add" ; + gaa = "git add -A" ; + gse = "git send-email HEAD^ --to=\"\"" ; + gd = "git diff" ; + gP = "git push" ; + gp = "git pull" ; + gl = "git log '@{push}..'" ; + gla = "git log" ; + } ; + shellAliases = { + l = "ls -CB" ; + la = "ls -CAB" ; + ll = "ls -CBlh" ; + lla = "ls -CABlh" ; + cl = "clear" ; + "c." = "cd .." ; + ":q" = "exit" ; + v = "hx" ; + sv = "sudo hx" ; + } ; + } ; +} \ No newline at end of file diff --git a/programs/helix.nix b/programs/helix.nix new file mode 100644 index 0000000..20ea994 --- /dev/null +++ b/programs/helix.nix @@ -0,0 +1,31 @@ +{config, lib, pkgs, inputs, ...} : { + programs.helix = { + enable = true ; + defaultEditor = true ; + settings = { + theme = "horizon-dark" ; + editor = { + scrolloff = 4 ; + auto-format = true ; + auto-pairs = false ; + color-modes = true ; + lsp.snippets = true ; + cursor-shape.insert = "bar" ; + shell = [ "fish" "-c" ] ; + idle-timeout = 250 ; + whitespace = { + render.tab = "all" ; + characters.tab = "│" ; + } ; + soft-wrap = { + enable = true ; + wrap-at-text-width = true ; + } ; + } ; + keys = { + normal = { + } ; + } ; + } ; + }; +} \ No newline at end of file diff --git a/programs/kakoune.nix b/programs/kakoune.nix index 14e09fc..ba9be1e 100644 --- a/programs/kakoune.nix +++ b/programs/kakoune.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, config, specialArgs, options, modulesPath }: +{ pkgs, lib, config, specialArgs, options, modulesPath, ... }: with pkgs; with pkgs.kakouneUtils; @@ -221,5 +221,5 @@ let }; in { - environment.systemPackages = [ myKakoune kak-wrap ]; + home.packages = [ myKakoune kak-wrap ]; } diff --git a/programs/pastebin.nix b/programs/pastebin.nix index 2c8ea27..7b67d86 100644 --- a/programs/pastebin.nix +++ b/programs/pastebin.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, config, specialArgs, options, modulesPath }: +{ pkgs, lib, config, specialArgs, options, modulesPath, ... }: with pkgs; @@ -230,5 +230,5 @@ let in { - environment.systemPackages = [ pastebin ]; + home.packages = [ pastebin ]; }