From 7125c1430536c2b617d6ab828c2b95f6c50c6e7b Mon Sep 17 00:00:00 2001 From: Martin Myrseth Date: Tue, 9 Jun 2026 22:17:21 +0200 Subject: [PATCH 01/11] flake: Add static + secret checks and CI Wire treefmt-nix (nixfmt) and cachix/git-hooks.nix into the flake so `nix fmt`, `nix flake check`, and pre-push hooks all share one config: - nixfmt via treefmt-nix (`nix fmt`, treefmt.nix) - statix (Nix anti-patterns) and deadnix (dead code) hooks - gitleaks secret scanner as a custom hook reading .gitleaks.toml - pre-commit-check installed as a pre-push hook on `nix develop` - aarch64-darwin added to per-system outputs so checks run on macOS; Linux-only outputs (deploy/xmonad shells, packages, apps) gated - GH Actions workflows: nix flake check on PRs, weekly flake.lock PR --- .github/workflows/check.yml | 17 +++ .github/workflows/update-flake-lock.yml | 18 +++ .gitleaks.toml | 12 ++ flake.lock | 83 ++++++++++++- flake.nix | 148 ++++++++++++++++-------- treefmt.nix | 12 ++ 6 files changed, 240 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/check.yml create mode 100644 .github/workflows/update-flake-lock.yml create mode 100644 .gitleaks.toml create mode 100644 treefmt.nix diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..28c6426 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,17 @@ +name: check + +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - name: nix flake check + run: nix flake check --accept-flake-config --print-build-logs diff --git a/.github/workflows/update-flake-lock.yml b/.github/workflows/update-flake-lock.yml new file mode 100644 index 0000000..577f755 --- /dev/null +++ b/.github/workflows/update-flake-lock.yml @@ -0,0 +1,18 @@ +name: update-flake-lock + +on: + workflow_dispatch: + schedule: + - cron: '0 4 * * 1' # Mondays 04:00 UTC + +jobs: + lockfile: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/update-flake-lock@main + with: + pr-title: "flake.lock: weekly update" + pr-labels: dependencies + commit-msg: "flake.lock: weekly update" diff --git a/.gitleaks.toml b/.gitleaks.toml new file mode 100644 index 0000000..2bc0243 --- /dev/null +++ b/.gitleaks.toml @@ -0,0 +1,12 @@ +# gitleaks config — extends the default rules with project-specific allowlists +[extend] +useDefault = true + +[allowlist] +description = "Allowlist agenix-encrypted files and public SSH key lists" +paths = [ + '''secrets\.nix''', + '''secrets/.*\.age''', + '''machines/.*\.age''', + '''flake\.lock''', +] diff --git a/flake.lock b/flake.lock index 2a9c4a9..0031442 100644 --- a/flake.lock +++ b/flake.lock @@ -168,6 +168,22 @@ } }, "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "NixOS", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_3": { "flake": false, "locked": { "lastModified": 1767039857, @@ -216,6 +232,49 @@ "type": "github" } }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1778507602, + "narHash": "sha256-kTwur1wV+01SdqskVMSo6JMEpg71ps3HpbFY2GsflKs=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "61ab0e80d9c7ab14c256b5b453d8b3fb0189ba0a", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -357,7 +416,7 @@ }, "nixos-wsl": { "inputs": { - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat_3", "nixpkgs": [ "nixpkgs" ] @@ -500,6 +559,7 @@ "disko": "disko", "doomemacs": "doomemacs", "flake-utils": "flake-utils", + "git-hooks": "git-hooks", "home-manager": "home-manager_2", "home-manager-stable": "home-manager-stable", "i3ws": "i3ws", @@ -510,6 +570,7 @@ "nixpkgs": "nixpkgs_4", "nixpkgs-stable": "nixpkgs-stable", "piddif": "piddif", + "treefmt-nix": "treefmt-nix", "wallpapers": "wallpapers" } }, @@ -573,6 +634,26 @@ "type": "github" } }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1780220602, + "narHash": "sha256-eynAfOmbmxJnkp7YewvCEbShNnnYJ9gLLqkzsYtBPeM=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "db947814a175b7ca6ded66e21383d938df01c227", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, "utils": { "inputs": { "systems": "systems_2" diff --git a/flake.nix b/flake.nix index cb78679..c7d29b2 100644 --- a/flake.nix +++ b/flake.nix @@ -38,6 +38,14 @@ url = "github:ryantm/agenix"; inputs.nixpkgs.follows = "nixpkgs"; }; + git-hooks = { + url = "github:cachix/git-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; doomemacs = { url = "github:doomemacs/doomemacs"; flake = false; @@ -114,11 +122,6 @@ } ); - # Deploy checks - checks = builtins.mapAttrs ( - system: deployLib: deployLib.deployChecks self.deploy - ) inputs.deploy-rs.lib; - # Non-NixOS machines (Fedora, WSL, ++) homeConfigurations = lib.myme.nixos2hm { inherit (self) nixosConfigurations; }; @@ -127,52 +130,99 @@ name: config: config.config.system.build.sdImage ) self.nixosConfigurations; } - // flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ] ( - system: - let - pkgs = import nixpkgs { inherit system overlays; }; - in - { - # Apps for `nix run .#` - apps = { - agenix = { - type = "app"; - program = "${pkgs.agenix}/bin/agenix"; - }; - deploy = { - type = "app"; - program = "${pkgs.deploy-rs.deploy-rs}/bin/deploy"; - }; - }; + // + flake-utils.lib.eachSystem + [ + "aarch64-linux" + "x86_64-linux" + "aarch64-darwin" + ] + ( + system: + let + pkgs = import nixpkgs { inherit system overlays; }; + isLinux = lib.hasSuffix "-linux" system; + treefmtEval = inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix; + pre-commit-check = inputs.git-hooks.lib.${system}.run { + src = ./.; + default_stages = [ "pre-push" ]; + hooks = { + treefmt = { + enable = true; + package = treefmtEval.config.build.wrapper; + }; + statix.enable = true; + deadnix.enable = true; + gitleaks = { + enable = true; + name = "gitleaks"; + description = "Detect hardcoded secrets"; + entry = "${pkgs.gitleaks}/bin/gitleaks detect --no-banner --redact --source=."; + language = "system"; + pass_filenames = false; + }; + }; + }; + in + { + # `nix fmt` + formatter = treefmtEval.config.build.wrapper; + + # `nix flake check` + checks = { + pre-commit = pre-commit-check; + } + // lib.optionalAttrs (inputs.deploy-rs.lib ? ${system}) ( + inputs.deploy-rs.lib.${system}.deployChecks self.deploy + ); - # All packages under pkgs.myme.pkgs from the overlay - packages = pkgs.myme.pkgs; + # Apps for `nix run .#` (Linux only) + apps = lib.optionalAttrs isLinux { + agenix = { + type = "app"; + program = "${pkgs.agenix}/bin/agenix"; + }; + deploy = { + type = "app"; + program = "${pkgs.deploy-rs.deploy-rs}/bin/deploy"; + }; + }; - devShells = { - # Default dev shell (used by direnv) - default = pkgs.mkShell { - buildInputs = with pkgs; [ - agenix - disko - pkgs.myme.pkgs.nixos-bootstrap - ]; - }; + # All packages under pkgs.myme.pkgs from the overlay (Linux only) + packages = lib.optionalAttrs isLinux pkgs.myme.pkgs; - # Deployment to other nodes - deploy = pkgs.mkShell { buildInputs = with pkgs; [ deploy-rs.deploy-rs ]; }; + devShells = { + # Default dev shell (used by direnv) — installs the pre-push hook + default = pkgs.mkShell { + inherit (pre-commit-check) shellHook; + buildInputs = + pre-commit-check.enabledPackages + ++ lib.optionals isLinux ( + with pkgs; + [ + agenix + disko + myme.pkgs.nixos-bootstrap + ] + ); + }; + } + // lib.optionalAttrs isLinux { + # Deployment to other nodes + deploy = pkgs.mkShell { buildInputs = with pkgs; [ deploy-rs.deploy-rs ]; }; - # For hacking on XMonad - xmonad = pkgs.mkShell { - buildInputs = with pkgs; [ - (ghc.withPackages ( - ps: with ps; [ - xmonad - xmonad-contrib - ] - )) - ]; - }; - }; - } - ); + # For hacking on XMonad + xmonad = pkgs.mkShell { + buildInputs = with pkgs; [ + (ghc.withPackages ( + ps: with ps; [ + xmonad + xmonad-contrib + ] + )) + ]; + }; + }; + } + ); } diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..c5c0b47 --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,12 @@ +{ + projectRootFile = "flake.nix"; + programs.nixfmt.enable = true; + settings.global.excludes = [ + "flake.lock" + "*.age" + "secrets/*" + "*.png" + "*.jpg" + "*.svg" + ]; +} From d387e49748b6e9526f2c3eb44d6e9c941a8d7724 Mon Sep 17 00:00:00 2001 From: Martin Myrseth Date: Tue, 9 Jun 2026 22:17:26 +0200 Subject: [PATCH 02/11] treewide: Apply nixfmt formatting --- home-manager/btop.nix | 7 +- home-manager/dev.nix | 55 +- home-manager/emacs/darwin.nix | 65 ++- home-manager/emacs/default.nix | 88 ++- home-manager/fonts.nix | 10 +- home-manager/irc.nix | 19 +- home-manager/nixon/default.nix | 121 ++-- home-manager/spotify.nix | 23 +- home-manager/tmux.nix | 3 +- home-manager/wm/alacritty/default.nix | 34 +- home-manager/wm/alacritty/nord-theme.nix | 9 +- home-manager/wm/alacritty/one-light-theme.nix | 32 +- home-manager/wm/alacritty/one-theme.nix | 28 +- home-manager/wm/conky/default.nix | 14 +- home-manager/wm/default.nix | 14 +- home-manager/wm/dunst.nix | 239 ++++---- home-manager/wm/i3/default.nix | 272 ++++++--- home-manager/wm/i3/i3ws.nix | 16 +- home-manager/wm/polybar/default.nix | 543 +++++++++--------- home-manager/wm/polybar/dracula-colors.nix | 2 +- home-manager/wm/polybar/nord-colors.nix | 20 +- home-manager/wm/theme.nix | 16 +- home-manager/wm/waybar/default.nix | 7 +- home-manager/wm/xmonad/default.nix | 10 +- lib/allNixFiles.nix | 9 +- lib/allProfilesIf.nix | 17 +- lib/default.nix | 12 +- lib/deployConf.nix | 3 +- lib/makeNixOS.nix | 30 +- lib/nixos2hm.nix | 29 +- machines/Tuple/default.nix | 119 ++-- machines/deque.nix | 218 +++---- machines/generic.nix | 32 +- machines/map/default.nix | 114 ++-- machines/nuckie/default.nix | 223 +++---- machines/nuckie/nginx.nix | 7 +- machines/qemu-vm.nix | 73 +-- machines/rassie.nix | 132 +++-- modules/default.nix | 64 ++- modules/machine.nix | 27 +- modules/sleep.nix | 3 +- modules/users.nix | 26 +- pkgs/git-sync/default.nix | 10 +- pkgs/lockscreen/default.nix | 7 +- pkgs/nixos-bootstrap/default.nix | 6 +- pkgs/sonnette/default.nix | 8 +- users/myme.nix | 5 +- users/root.nix | 3 +- users/user.nix | 7 +- 49 files changed, 1668 insertions(+), 1163 deletions(-) diff --git a/home-manager/btop.nix b/home-manager/btop.nix index 2a3f589..623a0d9 100644 --- a/home-manager/btop.nix +++ b/home-manager/btop.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: { programs.btop = { enable = lib.mkDefault config.myme.defaultPrograms; diff --git a/home-manager/dev.nix b/home-manager/dev.nix index 8304fba..7733d85 100644 --- a/home-manager/dev.nix +++ b/home-manager/dev.nix @@ -1,12 +1,18 @@ # TODO: Pair programming setup using Docker/Podman + Tmate # Use a docker/pod with tmate and usual dev tools to share a tmux session with a peer. -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.myme.dev; -in { +in +{ imports = [ ./vscode.nix ]; @@ -179,9 +185,11 @@ in { # Python (lib.mkIf cfg.python.enable [ - (lib.mkIf cfg.python.interpreter (pkgs.python3.withPackages (ps: [ - ps.ipython - ]))) + (lib.mkIf cfg.python.interpreter ( + pkgs.python3.withPackages (ps: [ + ps.ipython + ]) + )) pkgs.black # pkgs.python-language-server pkgs.pyright @@ -212,14 +220,35 @@ in { ''; }) (lib.mkIf (cfg.llm.enable && cfg.llm.claude.enable) { - ".claude/settings.json".text = builtins.toJSON ({ - includeCoAuthoredBy = false; - } // lib.optionalAttrs cfg.llm.claude.notify { - hooks = { - Stop = [{ hooks = [{ type = "command"; command = "${pkgs.myme.pkgs.sonnette}/bin/sonnette notify 'Claude Code'"; }]; }]; - Notification = [{ hooks = [{ type = "command"; command = "${pkgs.myme.pkgs.sonnette}/bin/sonnette notify 'Claude Code'"; }]; }]; - }; - }); + ".claude/settings.json".text = builtins.toJSON ( + { + includeCoAuthoredBy = false; + } + // lib.optionalAttrs cfg.llm.claude.notify { + hooks = { + Stop = [ + { + hooks = [ + { + type = "command"; + command = "${pkgs.myme.pkgs.sonnette}/bin/sonnette notify 'Claude Code'"; + } + ]; + } + ]; + Notification = [ + { + hooks = [ + { + type = "command"; + command = "${pkgs.myme.pkgs.sonnette}/bin/sonnette notify 'Claude Code'"; + } + ]; + } + ]; + }; + } + ); }) ]; diff --git a/home-manager/emacs/darwin.nix b/home-manager/emacs/darwin.nix index 9387dff..6acb644 100644 --- a/home-manager/emacs/darwin.nix +++ b/home-manager/emacs/darwin.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.myme.emacs; @@ -8,8 +13,14 @@ let # Build a minimal Spotlight-discoverable .app bundle. # `exec` is the body of a /bin/sh script that becomes CFBundleExecutable. - mkDarwinApp = { name, bundleId, exec, extraPlist ? "" }: - pkgs.runCommandLocal "${name}.app" {} '' + mkDarwinApp = + { + name, + bundleId, + exec, + extraPlist ? "", + }: + pkgs.runCommandLocal "${name}.app" { } '' app="$out/Applications/${name}.app" mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" @@ -65,7 +76,8 @@ let end open location ''; -in { +in +{ config = lib.mkIf (cfg.enable && pkgs.stdenv.isDarwin) { # GUI launches on macOS (Spotlight, Dock, Finder) inherit launchd's # environment, not the login shell's. Without these: @@ -82,7 +94,8 @@ in { RunAtLoad = true; KeepAlive = false; ProgramArguments = [ - "/bin/sh" "-c" + "/bin/sh" + "-c" '' launchctl setenv DOOMLOCALDIR "$HOME/.cache/doomemacs/" ; \ launchctl setenv DOOMPROFILELOADFILE "$HOME/.cache/doomemacs/load.el" @@ -113,7 +126,8 @@ in { # proper LaunchServices identity so AppleScript `tell # application "Emacs" to activate` works. ProgramArguments = lib.mkForce [ - "/bin/sh" "-c" + "/bin/sh" + "-c" "/bin/wait4path /nix/store && exec ${emacsPkg}/Applications/Emacs.app/Contents/MacOS/Emacs --fg-daemon" ]; }; @@ -124,25 +138,24 @@ in { # Darwin equivalent of the Linux org-capture xdg.desktopEntry in # default.nix: an .app bundle that handles org-protocol:// URLs and # is launchable from Spotlight. - home.activation.orgCaptureApp = - lib.hm.dag.entryAfter ["writeBoundary"] '' - app="$HOME/Applications/Home Manager Apps/Org Capture.app" - run mkdir -p "$HOME/Applications/Home Manager Apps" - run rm -rf "$app" - run /usr/bin/osacompile -o "$app" ${orgCaptureScript} - # Replace osacompile's default droplet icon with the Emacs icon. - run cp "${emacsIcon}" "$app/Contents/Resources/applet.icns" - run /usr/libexec/PlistBuddy \ - -c 'Add :CFBundleURLTypes array' \ - -c 'Add :CFBundleURLTypes:0 dict' \ - -c 'Add :CFBundleURLTypes:0:CFBundleURLName string Org Protocol' \ - -c 'Add :CFBundleURLTypes:0:CFBundleURLSchemes array' \ - -c 'Add :CFBundleURLTypes:0:CFBundleURLSchemes:0 string org-protocol' \ - -c 'Add :CFBundleIdentifier string org.nixos.org-capture' \ - "$app/Contents/Info.plist" - # Bump the bundle mtime so Launch Services re-indexes it (copyApps - # preserves the nix-store epoch mtime otherwise). - run /usr/bin/touch "$app" - ''; + home.activation.orgCaptureApp = lib.hm.dag.entryAfter [ "writeBoundary" ] '' + app="$HOME/Applications/Home Manager Apps/Org Capture.app" + run mkdir -p "$HOME/Applications/Home Manager Apps" + run rm -rf "$app" + run /usr/bin/osacompile -o "$app" ${orgCaptureScript} + # Replace osacompile's default droplet icon with the Emacs icon. + run cp "${emacsIcon}" "$app/Contents/Resources/applet.icns" + run /usr/libexec/PlistBuddy \ + -c 'Add :CFBundleURLTypes array' \ + -c 'Add :CFBundleURLTypes:0 dict' \ + -c 'Add :CFBundleURLTypes:0:CFBundleURLName string Org Protocol' \ + -c 'Add :CFBundleURLTypes:0:CFBundleURLSchemes array' \ + -c 'Add :CFBundleURLTypes:0:CFBundleURLSchemes:0 string org-protocol' \ + -c 'Add :CFBundleIdentifier string org.nixos.org-capture' \ + "$app/Contents/Info.plist" + # Bump the bundle mtime so Launch Services re-indexes it (copyApps + # preserves the nix-store epoch mtime otherwise). + run /usr/bin/touch "$app" + ''; }; } diff --git a/home-manager/emacs/default.nix b/home-manager/emacs/default.nix index 37c2fb9..326f538 100644 --- a/home-manager/emacs/default.nix +++ b/home-manager/emacs/default.nix @@ -1,10 +1,18 @@ -{ config, lib, pkgs, osConfig, ... }: +{ + config, + lib, + pkgs, + osConfig, + ... +}: let cfg = config.myme.emacs; - doom = (pkgs.writeShellScriptBin "doom" '' - ~/.emacs.d/bin/doom "$@" - ''); + doom = ( + pkgs.writeShellScriptBin "doom" '' + ~/.emacs.d/bin/doom "$@" + '' + ); # On Darwin we manage the daemon ourselves (no systemd socket activation), # so fall back to `-a ""` to spawn a daemon if one isn't running. # Note: regular `"..."` string — `''..''` strips the leading space. @@ -12,26 +20,37 @@ let # Use an absolute path so the wrappers work outside a shell-derived PATH # (AppleScript `do shell script`, launchd plists, etc.). emacsclientBin = "${config.programs.emacs.finalPackage}/bin/emacsclient"; - ec = (pkgs.writeShellScriptBin "ec" '' - ${emacsclientBin} -c${emacsclientFallback} "$@" - ''); - et = (pkgs.writeShellScriptBin "et" '' - ${emacsclientBin} -t${emacsclientFallback} "$@" - ''); + ec = ( + pkgs.writeShellScriptBin "ec" '' + ${emacsclientBin} -c${emacsclientFallback} "$@" + '' + ); + et = ( + pkgs.writeShellScriptBin "et" '' + ${emacsclientBin} -t${emacsclientFallback} "$@" + '' + ); # FIXME: Hack to avoid hang on gpg save: https://dev.gnupg.org/T6481 - epg = if lib.versionOlder pkgs.gnupg.version "2.4.4" then (pkgs.writeShellScriptBin "epg" '' - PATH="${pkgs.gnupg24}/bin:$PATH" emacs "$@" - '') else null; + epg = + if lib.versionOlder pkgs.gnupg.version "2.4.4" then + (pkgs.writeShellScriptBin "epg" '' + PATH="${pkgs.gnupg24}/bin:$PATH" emacs "$@" + '') + else + null; flavor = osConfig.myme.machine.flavor; deVariant = osConfig.myme.machine.de.variant; - isWayland = flavor == "wsl" || builtins.elem deVariant [ "gnome" "hyprland" ]; - EDITOR = if osConfig.myme.machine.role == "server" then - "${et}/bin/et" - else - "${ec}/bin/ec"; + isWayland = + flavor == "wsl" + || builtins.elem deVariant [ + "gnome" + "hyprland" + ]; + EDITOR = if osConfig.myme.machine.role == "server" then "${et}/bin/et" else "${ec}/bin/ec"; xclip-to-org = pkgs.writeShellScriptBin "xclip-to-org" (builtins.readFile ./xclip-to-org.sh); -in { +in +{ imports = [ ./darwin.nix ]; options.myme.emacs = { @@ -123,14 +142,24 @@ in { }; # Additional packages - home.packages = with pkgs; [ - (aspellWithDicts (dicts: with dicts; [ en en-computers it nb ])) - doom - ec - et - nodePackages.mermaid-cli - xclip-to-org - ] ++ (if epg != null then [epg] else []); + home.packages = + with pkgs; + [ + (aspellWithDicts ( + dicts: with dicts; [ + en + en-computers + it + nb + ] + )) + doom + ec + et + nodePackages.mermaid-cli + xclip-to-org + ] + ++ (if epg != null then [ epg ] else [ ]); xdg.desktopEntries = lib.mkIf pkgs.stdenv.isLinux { org-capture = { @@ -139,7 +168,10 @@ in { exec = "${EDITOR} %u"; icon = "emacs"; terminal = false; - categories = [ "Development" "TextEditor" ]; + categories = [ + "Development" + "TextEditor" + ]; mimeType = [ "x-scheme-handler/org-protocol" ]; }; }; diff --git a/home-manager/fonts.nix b/home-manager/fonts.nix index c3a4f3d..a1679d8 100644 --- a/home-manager/fonts.nix +++ b/home-manager/fonts.nix @@ -1,9 +1,15 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.myme.fonts; -in { +in +{ options.myme.fonts = { enable = lib.mkEnableOption "WM Fonts"; }; diff --git a/home-manager/irc.nix b/home-manager/irc.nix index e0f9b90..de05c99 100644 --- a/home-manager/irc.nix +++ b/home-manager/irc.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.myme.irc; @@ -10,14 +15,18 @@ let TMUX_TMPDIR= ${tmuxCmd} attach-session -t weechat ''; -in { +in +{ options = { myme.irc.enable = lib.mkEnableOption "Enable IRC (weechat)"; myme.irc.service = lib.mkEnableOption "Run WeeChat as a user service"; }; config = { - home.packages = lib.mkIf cfg.enable [ irc weechat ]; + home.packages = lib.mkIf cfg.enable [ + irc + weechat + ]; systemd.user.services.weechat = lib.mkIf (cfg.enable && cfg.service) { Unit = { @@ -34,7 +43,9 @@ in { Restart = "on-failure"; }; - Install = { WantedBy = [ "default.target" ]; }; + Install = { + WantedBy = [ "default.target" ]; + }; }; }; } diff --git a/home-manager/nixon/default.nix b/home-manager/nixon/default.nix index 9dea13a..c554efb 100644 --- a/home-manager/nixon/default.nix +++ b/home-manager/nixon/default.nix @@ -1,10 +1,17 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: with lib; -let cfg = config.programs.nixon; +let + cfg = config.programs.nixon; -in { +in +{ options.programs.nixon = { enable = mkEnableOption "nixon"; @@ -62,8 +69,7 @@ in { home.packages = [ cfg.package ]; # Add default commands - programs.nixon.configExtra = - lib.mkIf cfg.defaultCommands (lib.readFile ./nixon.md); + programs.nixon.configExtra = lib.mkIf cfg.defaultCommands (lib.readFile ./nixon.md); xdg.configFile."nixon.md".text = '' # Nixon @@ -72,7 +78,12 @@ in { ```json ${builtins.toJSON { - inherit (cfg) exact_match ignore_case use_direnv use_nix; + inherit (cfg) + exact_match + ignore_case + use_direnv + use_nix + ; project_dirs = cfg.source_dirs; project_types = [ { @@ -97,7 +108,11 @@ in { } { name = "nix"; - test = [ "flake.nix" "default.nix" "shell.nix" ]; + test = [ + "flake.nix" + "default.nix" + "shell.nix" + ]; desc = "Nix project"; } { @@ -126,49 +141,53 @@ in { ${cfg.configExtra} ''; - programs.bash.initExtra = (mkIf config.programs.bash.enable '' - # Nixon - alias n=nixon - alias px="nixon project" - - source ${pkgs.complete-alias}/bin/complete_alias - complete -F _complete_alias n - complete -F _complete_alias px - - # Nixon (p: project cd) - p () { - local project; - project=$(nixon project -s "$@" | tail -1) - if [ -z "$project" ]; then - return - fi - cd "$project" - } - - source ${cfg.package}/share/nixon/nixon-widget.bash - ''); - - programs.zsh.initContent = (mkIf config.programs.zsh.enable '' - # Nixon - alias n=nixon - - # Nixon (p: project cd) - (( ''${+aliases[p]} )) && unalias p - p () { - local project; - project=$(nixon project -s "$@" | tail -1) - if [ -z "$project" ]; then - return - fi - cd "$project" - } - - # Nixon (px: project execute) - px () { - nixon project "$@" - } - - source ${cfg.package}/share/zsh/site-functions/_nixon_widget - ''); + programs.bash.initExtra = ( + mkIf config.programs.bash.enable '' + # Nixon + alias n=nixon + alias px="nixon project" + + source ${pkgs.complete-alias}/bin/complete_alias + complete -F _complete_alias n + complete -F _complete_alias px + + # Nixon (p: project cd) + p () { + local project; + project=$(nixon project -s "$@" | tail -1) + if [ -z "$project" ]; then + return + fi + cd "$project" + } + + source ${cfg.package}/share/nixon/nixon-widget.bash + '' + ); + + programs.zsh.initContent = ( + mkIf config.programs.zsh.enable '' + # Nixon + alias n=nixon + + # Nixon (p: project cd) + (( ''${+aliases[p]} )) && unalias p + p () { + local project; + project=$(nixon project -s "$@" | tail -1) + if [ -z "$project" ]; then + return + fi + cd "$project" + } + + # Nixon (px: project execute) + px () { + nixon project "$@" + } + + source ${cfg.package}/share/zsh/site-functions/_nixon_widget + '' + ); }; } diff --git a/home-manager/spotify.nix b/home-manager/spotify.nix index aa04ea0..8b18bf4 100644 --- a/home-manager/spotify.nix +++ b/home-manager/spotify.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let spotify-ctrl = pkgs.writeShellScriptBin "spotify-ctrl" '' @@ -8,16 +13,20 @@ let org.mpris.MediaPlayer2.Player."$1" ''; -in { +in +{ options = { myme.apps.spotify.enable = lib.mkEnableOption "Enable Spotify"; }; config = lib.mkIf config.myme.apps.spotify.enable { - home.packages = with pkgs; [ - spotify - ] ++ [ - spotify-ctrl - ]; + home.packages = + with pkgs; + [ + spotify + ] + ++ [ + spotify-ctrl + ]; }; } diff --git a/home-manager/tmux.nix b/home-manager/tmux.nix index 59b256f..2032552 100644 --- a/home-manager/tmux.nix +++ b/home-manager/tmux.nix @@ -1,4 +1,5 @@ -{ pkgs, ... }: { +{ pkgs, ... }: +{ config = { home.packages = with pkgs; [ tmux-xpanes diff --git a/home-manager/wm/alacritty/default.nix b/home-manager/wm/alacritty/default.nix index 37063c5..0ca19cb 100644 --- a/home-manager/wm/alacritty/default.nix +++ b/home-manager/wm/alacritty/default.nix @@ -1,4 +1,10 @@ -{ config, lib, pkgs, flake-inputs, ... }: +{ + config, + lib, + pkgs, + flake-inputs, + ... +}: with lib; @@ -7,16 +13,19 @@ let terminal = pkgs.writeShellScriptBin "x-terminal-emulator" ''${pkgs.alacritty}/bin/alacritty "$@"''; readTheme = input: theme: builtins.fromTOML (builtins.readFile "${input}/${theme}.toml"); catppuccin = flake-inputs.alacritty-catppuccin; - theme = { - catppuccin-frappe = readTheme catppuccin "catppuccin-frappe"; - catppuccin-latte = readTheme catppuccin "catppuccin-latte"; - catppuccin-macchiato = readTheme catppuccin "catppuccin-macchiato"; - catppuccin-mocha = readTheme catppuccin "catppuccin-mocha"; - dracula = readTheme flake-inputs.alacritty-dracula "dracula"; - nord.colors = import ./nord-theme.nix; - }.${cfg.theme}; + theme = + { + catppuccin-frappe = readTheme catppuccin "catppuccin-frappe"; + catppuccin-latte = readTheme catppuccin "catppuccin-latte"; + catppuccin-macchiato = readTheme catppuccin "catppuccin-macchiato"; + catppuccin-mocha = readTheme catppuccin "catppuccin-mocha"; + dracula = readTheme flake-inputs.alacritty-dracula "dracula"; + nord.colors = import ./nord-theme.nix; + } + .${cfg.theme}; -in { +in +{ options.myme.alacritty = { enable = mkEnableOption "Enable Alacritty"; background_opacity = mkOption { @@ -54,7 +63,10 @@ in { }; window = { opacity = cfg.background_opacity; - padding = { x = 10; y = 5; }; + padding = { + x = 10; + y = 5; + }; }; }; }; diff --git a/home-manager/wm/alacritty/nord-theme.nix b/home-manager/wm/alacritty/nord-theme.nix index ad60804..1c061f3 100644 --- a/home-manager/wm/alacritty/nord-theme.nix +++ b/home-manager/wm/alacritty/nord-theme.nix @@ -27,11 +27,10 @@ background = "#4c566a"; }; search = { - matches = - { - foreground = "CellBackground"; - background = "#88c0d0"; - }; + matches = { + foreground = "CellBackground"; + background = "#88c0d0"; + }; }; colors = { footer_bar = { diff --git a/home-manager/wm/alacritty/one-light-theme.nix b/home-manager/wm/alacritty/one-light-theme.nix index 5e1392d..d0da236 100644 --- a/home-manager/wm/alacritty/one-light-theme.nix +++ b/home-manager/wm/alacritty/one-light-theme.nix @@ -13,25 +13,25 @@ # Normal colors normal = { - black = "0x5c6370"; - red = "0xe45649"; - green = "0x4db5bd"; - yellow = "0xda8548"; - blue = "0x4078f2"; - magenta = "0xb751b6"; - cyan = "0x0184bc"; - white = "0xf0f0f0"; + black = "0x5c6370"; + red = "0xe45649"; + green = "0x4db5bd"; + yellow = "0xda8548"; + blue = "0x4078f2"; + magenta = "0xb751b6"; + cyan = "0x0184bc"; + white = "0xf0f0f0"; }; # Bright colors bright = { - black = "0xf0f0f0"; - red = "0xe45649"; - green = "0x50a14f"; - yellow = "0x986801"; - blue = "0xa0bcf8"; - magenta = "0xa626a4"; - cyan = "0x005478"; - white = "0xf0f0f0"; + black = "0xf0f0f0"; + red = "0xe45649"; + green = "0x50a14f"; + yellow = "0x986801"; + blue = "0xa0bcf8"; + magenta = "0xa626a4"; + cyan = "0x005478"; + white = "0xf0f0f0"; }; } diff --git a/home-manager/wm/alacritty/one-theme.nix b/home-manager/wm/alacritty/one-theme.nix index c391fd7..9162548 100644 --- a/home-manager/wm/alacritty/one-theme.nix +++ b/home-manager/wm/alacritty/one-theme.nix @@ -13,25 +13,25 @@ # Normal colors normal = { - black = "0x131613"; - red = "0xe06c75"; - green = "0x98c379"; - yellow = "0xd19a66"; - blue = "0x61afef"; + black = "0x131613"; + red = "0xe06c75"; + green = "0x98c379"; + yellow = "0xd19a66"; + blue = "0x61afef"; magenta = "0xc678dd"; - cyan = "0x56b6c2"; - white = "0xabb2bf"; + cyan = "0x56b6c2"; + white = "0xabb2bf"; }; # Bright colors bright = { - black = "0x5c6370"; - red = "0xe06c75"; - green = "0x98c379"; - yellow = "0xd19a66"; - blue = "0x61afef"; + black = "0x5c6370"; + red = "0xe06c75"; + green = "0x98c379"; + yellow = "0xd19a66"; + blue = "0x61afef"; magenta = "0xc678dd"; - cyan = "0x56b6c2"; - white = "0xffffff"; + cyan = "0x56b6c2"; + white = "0xffffff"; }; } diff --git a/home-manager/wm/conky/default.nix b/home-manager/wm/conky/default.nix index 85b274b..9437eb5 100644 --- a/home-manager/wm/conky/default.nix +++ b/home-manager/wm/conky/default.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.myme.wm.conky; @@ -22,7 +27,8 @@ let ''; }; -in { +in +{ options.myme.wm.conky = { enable = lib.mkEnableOption "Enable conky resource monitor"; font = { @@ -63,7 +69,9 @@ in { Restart = "on-failure"; }; - Install = { WantedBy = [ "graphical-session.target" ]; }; + Install = { + WantedBy = [ "graphical-session.target" ]; + }; }; }; } diff --git a/home-manager/wm/default.nix b/home-manager/wm/default.nix index e1a42ad..8516581 100644 --- a/home-manager/wm/default.nix +++ b/home-manager/wm/default.nix @@ -196,9 +196,19 @@ in enable = true; settings = import ./dunst.nix ( if machine.highDPI then - { font = "Dejavu Sans 15"; width = 500; origin = "top-right"; offset = "30x20"; } + { + font = "Dejavu Sans 15"; + width = 500; + origin = "top-right"; + offset = "30x20"; + } else - { font = "Dejavu Sans 10"; width = 300; origin = "top-right"; offset = "30x20"; } + { + font = "Dejavu Sans 10"; + width = 300; + origin = "top-right"; + offset = "30x20"; + } ); }; }) diff --git a/home-manager/wm/dunst.nix b/home-manager/wm/dunst.nix index 4a3ea7e..683b852 100644 --- a/home-manager/wm/dunst.nix +++ b/home-manager/wm/dunst.nix @@ -1,4 +1,9 @@ -{ font, width, origin, offset }: +{ + font, + width, + origin, + offset, +}: { global = { ### Display ### @@ -271,120 +276,120 @@ #icon = /path/to/icon }; -# Every section that isn't one of the above is interpreted as a rules to -# override settings for certain messages. -# -# Messages can be matched by -# appname (discouraged, see desktop_entry) -# body -# category -# desktop_entry -# icon -# match_transient -# msg_urgency -# stack_tag -# summary -# -# and you can override the -# background -# foreground -# format -# frame_color -# fullscreen -# new_icon -# set_stack_tag -# set_transient -# timeout -# urgency -# -# Shell-like globbing will get expanded. -# -# Instead of the appname filter, it's recommended to use the desktop_entry filter. -# GLib based applications export their desktop-entry name. In comparison to the appname, -# the desktop-entry won't get localized. -# -# SCRIPTING -# You can specify a script that gets run when the rule matches by -# setting the "script" option. -# The script will be called as follows: -# script appname summary body icon urgency -# where urgency can be "LOW", "NORMAL" or "CRITICAL". -# -# NOTE: if you don't want a notification to be displayed, set the format -# to "". -# NOTE: It might be helpful to run dunst -print in a terminal in order -# to find fitting options for rules. - -# Disable the transient hint so that idle_threshold cannot be bypassed from the -# client -#[transient_disable] -# match_transient = yes -# set_transient = no -# -# Make the handling of transient notifications more strict by making them not -# be placed in history. -#[transient_history_ignore] -# match_transient = yes -# history_ignore = yes - -# fullscreen values -# show: show the notifications, regardless if there is a fullscreen window opened -# delay: displays the new notification, if there is no fullscreen window active -# If the notification is already drawn, it won't get undrawn. -# pushback: same as delay, but when switching into fullscreen, the notification will get -# withdrawn from screen again and will get delayed like a new notification -#[fullscreen_delay_everything] -# fullscreen = delay -#[fullscreen_show_critical] -# msg_urgency = critical -# fullscreen = show - -#[espeak] -# summary = "*" -# script = dunst_espeak.sh - -#[script-test] -# summary = "*script*" -# script = dunst_test.sh - -#[ignore] -# # This notification will not be displayed -# summary = "foobar" -# format = "" - -#[history-ignore] -# # This notification will not be saved in history -# summary = "foobar" -# history_ignore = yes - -#[skip-display] -# # This notification will not be displayed, but will be included in the history -# summary = "foobar" -# skip_display = yes - -#[signed_on] -# appname = Pidgin -# summary = "*signed on*" -# urgency = low -# -#[signed_off] -# appname = Pidgin -# summary = *signed off* -# urgency = low -# -#[says] -# appname = Pidgin -# summary = *says* -# urgency = critical -# -#[twitter] -# appname = Pidgin -# summary = *twitter.com* -# urgency = normal -# -#[stack-volumes] -# appname = "some_volume_notifiers" -# set_stack_tag = "volume" -# -# vim: ft=cfg + # Every section that isn't one of the above is interpreted as a rules to + # override settings for certain messages. + # + # Messages can be matched by + # appname (discouraged, see desktop_entry) + # body + # category + # desktop_entry + # icon + # match_transient + # msg_urgency + # stack_tag + # summary + # + # and you can override the + # background + # foreground + # format + # frame_color + # fullscreen + # new_icon + # set_stack_tag + # set_transient + # timeout + # urgency + # + # Shell-like globbing will get expanded. + # + # Instead of the appname filter, it's recommended to use the desktop_entry filter. + # GLib based applications export their desktop-entry name. In comparison to the appname, + # the desktop-entry won't get localized. + # + # SCRIPTING + # You can specify a script that gets run when the rule matches by + # setting the "script" option. + # The script will be called as follows: + # script appname summary body icon urgency + # where urgency can be "LOW", "NORMAL" or "CRITICAL". + # + # NOTE: if you don't want a notification to be displayed, set the format + # to "". + # NOTE: It might be helpful to run dunst -print in a terminal in order + # to find fitting options for rules. + + # Disable the transient hint so that idle_threshold cannot be bypassed from the + # client + #[transient_disable] + # match_transient = yes + # set_transient = no + # + # Make the handling of transient notifications more strict by making them not + # be placed in history. + #[transient_history_ignore] + # match_transient = yes + # history_ignore = yes + + # fullscreen values + # show: show the notifications, regardless if there is a fullscreen window opened + # delay: displays the new notification, if there is no fullscreen window active + # If the notification is already drawn, it won't get undrawn. + # pushback: same as delay, but when switching into fullscreen, the notification will get + # withdrawn from screen again and will get delayed like a new notification + #[fullscreen_delay_everything] + # fullscreen = delay + #[fullscreen_show_critical] + # msg_urgency = critical + # fullscreen = show + + #[espeak] + # summary = "*" + # script = dunst_espeak.sh + + #[script-test] + # summary = "*script*" + # script = dunst_test.sh + + #[ignore] + # # This notification will not be displayed + # summary = "foobar" + # format = "" + + #[history-ignore] + # # This notification will not be saved in history + # summary = "foobar" + # history_ignore = yes + + #[skip-display] + # # This notification will not be displayed, but will be included in the history + # summary = "foobar" + # skip_display = yes + + #[signed_on] + # appname = Pidgin + # summary = "*signed on*" + # urgency = low + # + #[signed_off] + # appname = Pidgin + # summary = *signed off* + # urgency = low + # + #[says] + # appname = Pidgin + # summary = *says* + # urgency = critical + # + #[twitter] + # appname = Pidgin + # summary = *twitter.com* + # urgency = normal + # + #[stack-volumes] + # appname = "some_volume_notifiers" + # set_stack_tag = "volume" + # + # vim: ft=cfg } diff --git a/home-manager/wm/i3/default.nix b/home-manager/wm/i3/default.nix index 9343d10..fe58f25 100644 --- a/home-manager/wm/i3/default.nix +++ b/home-manager/wm/i3/default.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.myme.wm.i3; @@ -14,7 +19,8 @@ let amixer = "${pkgs.alsa-utils}/bin/amixer"; nixonCfg = config.programs.nixon; -in { +in +{ imports = [ ./i3ws.nix ]; @@ -48,17 +54,50 @@ in { package = pkgs.i3-gaps; config = { modifier = "Mod4"; - bars = []; + bars = [ ]; colors = { background = "#ffffff"; - focused = { border = "#4c7899"; background = "#285577"; text = "#ffffff"; indicator = "#2e9ef4"; childBorder = "#285577"; }; - focusedInactive = { border = "#333333"; background = "#5f676a"; text = "#ffffff"; indicator = "#484e50"; childBorder = "#5f676a"; }; - unfocused = { border = "#333333"; background = "#222222"; text = "#888888"; indicator = "#292d2e"; childBorder = "#222222"; }; - urgent = { border = "#2f343a"; background = "#900000"; text = "#ffffff"; indicator = "#900000"; childBorder = "#900000"; }; - placeholder = { border = "#000000"; background = "#0c0c0c"; text = "#ffffff"; indicator = "#000000"; childBorder = "#0c0c0c"; }; + focused = { + border = "#4c7899"; + background = "#285577"; + text = "#ffffff"; + indicator = "#2e9ef4"; + childBorder = "#285577"; + }; + focusedInactive = { + border = "#333333"; + background = "#5f676a"; + text = "#ffffff"; + indicator = "#484e50"; + childBorder = "#5f676a"; + }; + unfocused = { + border = "#333333"; + background = "#222222"; + text = "#888888"; + indicator = "#292d2e"; + childBorder = "#222222"; + }; + urgent = { + border = "#2f343a"; + background = "#900000"; + text = "#ffffff"; + indicator = "#900000"; + childBorder = "#900000"; + }; + placeholder = { + border = "#000000"; + background = "#0c0c0c"; + text = "#ffffff"; + indicator = "#000000"; + childBorder = "#0c0c0c"; + }; }; fonts = { - names = ["Dejavu Sans Mono" "FontAwesome 11"]; + names = [ + "Dejavu Sans Mono" + "FontAwesome 11" + ]; }; gaps = { inner = 10; @@ -148,28 +187,36 @@ in { # Restart/reload "${modifier}+r" = "reload"; "${modifier}+Shift+r" = "restart"; - } // ( - if ! nixonCfg.enable then {} else { - # Nixon - "${modifier}+x" = "exec --no-startup-id ${nixonCfg.package}/bin/nixon run"; - "${modifier}+Shift+x" = "exec --no-startup-id ${nixonCfg.package}/bin/nixon project"; - } - ) // ( + } + // ( + if !nixonCfg.enable then + { } + else + { + # Nixon + "${modifier}+x" = "exec --no-startup-id ${nixonCfg.package}/bin/nixon run"; + "${modifier}+Shift+x" = "exec --no-startup-id ${nixonCfg.package}/bin/nixon project"; + } + ) + // ( # Sans Plasma - if cfg.plasma then {} else { - # Locking - "Control+Mod1+l" = ''mode "${lockMode}"''; - - # Audio controls - "XF86AudioRaiseVolume" = "exec --no-startup-id ${amixer} set Master 1%+"; - "XF86AudioLowerVolume" = "exec --no-startup-id ${amixer} set Master 1%-"; - "XF86AudioMute" = "exec --no-startup-id ${amixer} set Master toggle"; - "XF86AudioMicMute" = "exec --no-startup-id ${amixer} set Capture toggle"; - - # Brightness - # "XF86MonBrightnessUp" = "exec ${backlight} -A 10"; - # "XF86MonBrightnessDown" = "exec ${backlight} -U 10"; - } + if cfg.plasma then + { } + else + { + # Locking + "Control+Mod1+l" = ''mode "${lockMode}"''; + + # Audio controls + "XF86AudioRaiseVolume" = "exec --no-startup-id ${amixer} set Master 1%+"; + "XF86AudioLowerVolume" = "exec --no-startup-id ${amixer} set Master 1%-"; + "XF86AudioMute" = "exec --no-startup-id ${amixer} set Master toggle"; + "XF86AudioMicMute" = "exec --no-startup-id ${amixer} set Capture toggle"; + + # Brightness + # "XF86MonBrightnessUp" = "exec ${backlight} -A 10"; + # "XF86MonBrightnessDown" = "exec ${backlight} -U 10"; + } ) ); modes = lib.mkMerge [ @@ -203,43 +250,140 @@ in { }) ]; startup = [ - { command = "~/.fehbg"; notification = false; } - ] ++ (if (cfg.plasma) then [ - { command = "${pkgs.wmctrl} -c Plasma"; notification = false; } - { command = "systemctl --user restart davmail.service"; notification = false; } - { command = "systemctl --user restart i3ws.service"; always = true; notification = false; } - { command = "systemctl --user restart picom.service"; notification = false; } - { command = "systemctl --user restart polybar.service"; always = true; notification = false; } - { command = "systemctl --user restart syncthing.service"; notification = false; } - { command = "systemctl --user restart qsyncthingtray.service"; always = true; notification = false; } - ] else [ - # Enable natural scrolling - # { command = ''xinput set-prop "GDX1301:00 27C6:01F0 Touchpad" "libinput Natural Scrolling Enabled" 1''; notification = false; } - { command = ''setxkbmap us alt-intl-unicode''; notification = false; } - # { command = "systemctl --user restart davmail.service"; notification = false; } - # { command = "systemctl --user restart syncthing.service"; notification = false; } - # { command = "systemctl --user restart picom.service"; notification = false; } - { command = "systemctl --user restart polybar.service"; always = true; notification = false; } - { command = "systemctl --user restart i3ws.service"; always = true; notification = false; } - { command = "sleep 2; systemctl --user restart qsyncthingtray.service"; always = true; notification = false; } - ]); + { + command = "~/.fehbg"; + notification = false; + } + ] + ++ ( + if (cfg.plasma) then + [ + { + command = "${pkgs.wmctrl} -c Plasma"; + notification = false; + } + { + command = "systemctl --user restart davmail.service"; + notification = false; + } + { + command = "systemctl --user restart i3ws.service"; + always = true; + notification = false; + } + { + command = "systemctl --user restart picom.service"; + notification = false; + } + { + command = "systemctl --user restart polybar.service"; + always = true; + notification = false; + } + { + command = "systemctl --user restart syncthing.service"; + notification = false; + } + { + command = "systemctl --user restart qsyncthingtray.service"; + always = true; + notification = false; + } + ] + else + [ + # Enable natural scrolling + # { command = ''xinput set-prop "GDX1301:00 27C6:01F0 Touchpad" "libinput Natural Scrolling Enabled" 1''; notification = false; } + { + command = "setxkbmap us alt-intl-unicode"; + notification = false; + } + # { command = "systemctl --user restart davmail.service"; notification = false; } + # { command = "systemctl --user restart syncthing.service"; notification = false; } + # { command = "systemctl --user restart picom.service"; notification = false; } + { + command = "systemctl --user restart polybar.service"; + always = true; + notification = false; + } + { + command = "systemctl --user restart i3ws.service"; + always = true; + notification = false; + } + { + command = "sleep 2; systemctl --user restart qsyncthingtray.service"; + always = true; + notification = false; + } + ] + ); window = { # Disable title bar titlebar = false; - commands = if (!cfg.plasma) then [] else [ - # Kill Plasma desktop - { criteria = { title = "Desktop — Plasma"; }; command = "kill; floating enable; border none"; } - - # Plasma popus shouldn't be tiled - { criteria = { class = "plasmashell"; }; command = "floating enable"; } - { criteria = { class = "Plasma"; }; command = "floating enable; border none"; } - { criteria = { title = "plasma-desktop"; }; command = "floating enable; border none"; } - { criteria = { title = "win7"; }; command = "floating enable; border none"; } - { criteria = { class = "krunner"; }; command = "floating enable; border none"; } - { criteria = { class = "Kmix"; }; command = "floating enable; border none"; } - { criteria = { class = "Klipper"; }; command = "floating enable; border none"; } - { criteria = { class = "Plasmoidviewer"; }; command = "floating enable; border none"; } - ]; + commands = + if (!cfg.plasma) then + [ ] + else + [ + # Kill Plasma desktop + { + criteria = { + title = "Desktop — Plasma"; + }; + command = "kill; floating enable; border none"; + } + + # Plasma popus shouldn't be tiled + { + criteria = { + class = "plasmashell"; + }; + command = "floating enable"; + } + { + criteria = { + class = "Plasma"; + }; + command = "floating enable; border none"; + } + { + criteria = { + title = "plasma-desktop"; + }; + command = "floating enable; border none"; + } + { + criteria = { + title = "win7"; + }; + command = "floating enable; border none"; + } + { + criteria = { + class = "krunner"; + }; + command = "floating enable; border none"; + } + { + criteria = { + class = "Kmix"; + }; + command = "floating enable; border none"; + } + { + criteria = { + class = "Klipper"; + }; + command = "floating enable; border none"; + } + { + criteria = { + class = "Plasmoidviewer"; + }; + command = "floating enable; border none"; + } + ]; }; }; }; diff --git a/home-manager/wm/i3/i3ws.nix b/home-manager/wm/i3/i3ws.nix index c0430b1..76ea1d2 100644 --- a/home-manager/wm/i3/i3ws.nix +++ b/home-manager/wm/i3/i3ws.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: with lib; @@ -11,7 +16,8 @@ let renumberFlag = "--no-renumber"; cmd = "${cfg.package}/bin/i3ws ${iconFlag} ${separator} ${renumberFlag}"; -in { +in +{ options.myme.i3ws = { enable = mkEnableOption "Enable i3ws integration"; @@ -24,13 +30,13 @@ in { icons = mkOption { type = types.bool; default = false; - description ="Enable i3ws integration"; + description = "Enable i3ws integration"; }; separator = mkOption { type = types.str; default = ":"; - description ="Separator between workspace number and icons"; + description = "Separator between workspace number and icons"; }; }; @@ -44,7 +50,7 @@ in { Service = { Environment = "PATH=${i3pkg}/bin"; - ExecStart = ''${cmd} monitor''; + ExecStart = "${cmd} monitor"; Restart = "on-failure"; }; diff --git a/home-manager/wm/polybar/default.nix b/home-manager/wm/polybar/default.nix index 713fc73..59bb9c2 100644 --- a/home-manager/wm/polybar/default.nix +++ b/home-manager/wm/polybar/default.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: with lib; @@ -12,7 +17,8 @@ let }; theme = themes.dracula; -in { +in +{ options = { myme.wm.polybar = { enable = mkEnableOption "Polybar - Window manager status bar."; @@ -34,275 +40,272 @@ in { }; }; - config = let - font_size = builtins.toString cfg.font_size; - font_size_material = - builtins.toString (cfg.font_size + (cfg.font_size / 7)); - in mkIf cfg.enable { - systemd.user.services.polybar = { - Service.Environment = - mkForce "PATH=${polybar}/bin:/run/wrappers/bin:${pkgs.xdotool}/bin"; - }; - services.polybar = { - enable = cfg.enable; - config = { - defaults = { - width = "100%"; - height = cfg.height; - fixed-center = true; - bottom = true; - - module-margin-left = 1; - module-margin-right = 2; - - background = theme.colors.background; - foreground = theme.colors.foreground; - - line-size = 3; - line-color = theme.colors.urgent; - - font-0 = "Dejavu Sans Mono for Powerline:pixelsize=${font_size};1"; - font-1 = "FontAwesome:size=${font_size};1"; - font-2 = "Material Icons:size=${font_size_material};2"; - - cursor-click = "pointer"; - cursor-scroll = "ns-resize"; - }; - - "bar/main" = { - "inherit" = "defaults"; - monitor = "\${env:MONITOR:${cfg.monitor}}"; - - fixed-center = false; - - modules-left = - if wm.variant == "xmonad" then "xmonad" else "xworkspaces"; - modules-center = "xwindow"; - modules-right = [ - "alsa" - "wlan" - "eth" - "battery" - "backlight" - "cpu" - "memory" - "filesystem" - "date" - ]; - - tray-position = "right"; - }; - - "bar/aux" = { - "inherit" = "defaults"; - monitor = "\${env:MONITOR:DP-2}"; - modules-left = - if wm.variant == "xmonad" then "xmonad" else "xworkspaces"; - modules-center = [ "xwindow" ]; - modules-right = [ "date" ]; - }; - - "module/xmonad" = { - type = "custom/script"; - exec = - "${pkgs.coreutils}/bin/tail -F \${XDG_RUNTIME_DIR:-/tmp}/xmonad.log"; - tail = true; - }; - - "module/xworkspaces" = { - type = "internal/xworkspaces"; - - label-active = "%name%"; - label-active-background = theme.colors.background-alt; - label-active-underline = theme.colors.primary; - label-active-padding = 1; - - label-occupied = "%name%"; - label-occupied-padding = 1; - - label-empty = "%name%"; - label-empty-padding = 1; - - label-urgent = "%name%"; - label-urgent-background = theme.colors.alert; - label-urgent-padding = 1; - }; - - "module/xwindow" = { - type = "internal/xwindow"; - label = "%title:0:30:...%"; - }; - - "module/alsa" = { - type = "internal/alsa"; - - format-volume-prefix = " "; - format-volume = " "; - label-volume-foreground = theme.colors.foreground; - - format-muted-prefix = " "; - format-muted-foreground = theme.colors.foreground-alt; - label-muted = "sound muted"; - - bar-volume-width = 10; - bar-volume-foreground-0 = theme.colors.success; - bar-volume-foreground-1 = theme.colors.success; - bar-volume-foreground-2 = theme.colors.success; - bar-volume-foreground-3 = theme.colors.success; - bar-volume-foreground-4 = theme.colors.success; - bar-volume-foreground-5 = theme.colors.notify; - bar-volume-foreground-6 = theme.colors.urgent; - bar-volume-gradient = false; - bar-volume-indicator = "|"; - bar-volume-indicator-font = 2; - bar-volume-fill = "─"; - bar-volume-fill-font = 2; - bar-volume-empty = "─"; - bar-volume-empty-font = 2; - bar-volume-empty-foreground = theme.colors.foreground-alt; - }; - - "module/cpu" = { - type = "internal/cpu"; - interval = 2; - format-prefix = " "; - format-prefix-foreground = theme.colors.foreground-alt; - format-underline = theme.colors.urgent; - label = "%percentage:2%%"; - }; - - "module/memory" = { - type = "internal/memory"; - interval = 2; - format-prefix = " "; - format-prefix-foreground = theme.colors.foreground-alt; - format-underline = theme.colors.warning; - label = "%percentage_used%%"; - }; - - "module/filesystem" = { - type = "internal/fs"; - interval = 10; - mount-0 = "/"; - label-mounted = " %mountpoint% %percentage_used%%"; - label-mounted-underline = theme.colors.notify; - label-unmounted = " %mountpoint% not mounted"; - label-unmounted-foreground = theme.colors.foreground-alt; - label-unmounted-underline = theme.colors.alert; - }; - - "module/eth" = { - type = "internal/network"; - interface = "ens33"; - interval = 3; - - format-connected-underline = theme.colors.function; - format-connected-prefix = " "; - format-connected-prefix-foreground = theme.colors.foreground-alt; - label-connected = "%local_ip%"; - - format-disconnected = ""; - }; - - "module/wlan" = { - type = "internal/network"; - interface = "wlp1s0"; - interval = 3; - - format-connected = " "; - format-connected-underline = theme.colors.function; - label-connected = "%essid%"; - - format-disconnected = ""; - - ramp-signal-0 = ""; - ramp-signal-1 = ""; - ramp-signal-2 = ""; - ramp-signal-3 = ""; - ramp-signal-4 = ""; - ramp-signal-foreground = theme.colors.foreground-alt; - }; - - "module/battery" = { - type = "internal/battery"; - battery = "BAT0"; - adapter = "ADP1"; - full-at = 98; - - format-charging = " "; - format-charging-underline = theme.colors.notify; - - format-discharging = " "; - format-discharging-underline = "\${self.format-charging-underline}"; - - format-full-prefix = " "; - format-full-prefix-foreground = theme.colors.foreground-alt; - format-full-underline = "\${self.format-charging-underline}"; - - ramp-capacity-0 = ""; - ramp-capacity-1 = ""; - ramp-capacity-2 = ""; - ramp-capacity-3 = ""; - ramp-capacity-4 = ""; - ramp-capacity-foreground = theme.colors.foreground-alt; - - animation-charging-0 = ""; - animation-charging-1 = ""; - animation-charging-2 = ""; - animation-charging-3 = ""; - animation-charging-4 = ""; - animation-charging-foreground = theme.colors.foreground-alt; - animation-charging-framerate = 750; - - }; - - "module/backlight" = { - type = "internal/backlight"; - card = "intel_backlight"; - - # Available tags: - #