repositories

NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor

clonegit clone https://git.daemon-sec.xyz/NixDaemon.git
dotfiles.nixNix208 lines9.7 KiBraw download
# modules/home/dotfiles.nix — every hand-written dotfile, from dotfiles/ in
# this repo, placed by home-manager.
#
# dotfiles/home mirrors $HOME. It was carried on 2026-10-14 from
# ~/git/daemon-sec-dotfiles (the Omarchy-era snapshot, now only an archive), and
# holds the live configs this machine uses; dotfiles/assets holds the fonts.
# home-manager links each path as an out-of-store symlink (mkOutOfStoreSymlink)
# into ~/NixDaemon, so there is one source of truth: edit dotfiles/ and the live
# config changes; `nh os switch` is only needed when a path is added or removed
# here. Apps still write their state next to the config (Vesktop's session, jj's
# per-repo config); .gitignore keeps all of it out of the repo.
#
# Private parts are sops secrets (see .sops.yaml), not files under dotfiles/:
#   secrets/jj-identity.toml           jj [user] name and email → ~/.config/jj/conf.d/identity.toml
#   secrets/uncover-provider-config.yaml   uncover's API keys → ~/.config/uncover/provider-config.yaml
#   secrets/agent-state.tar            Claude Code / Codex settings, hooks, rules and
#                                      memories; `agent-state` restores or snapshots it
# Edit with `TMPDIR=/dev/shm sops secrets/<file>`, then `nh os switch`.
#
# Not linked, and why (each is one line to add if wanted):
#   .config/hypr, kitty, alacritty       Nix-managed (modules/home/hyprland.nix, terminal.nix)
#   .config/nvim                         the AstroNvim tree; Neovim is nvf now (modules/home/neovim.nix)
#   .config/starship.toml, .config/fastfetch   the Omarchy-era prompt and fetch; both are
#                                        Nix-managed now (modules/home/prompt.nix)
#   .config/mpd, rmpc, mpv, yazi         Nix-managed (modules/home/media.nix, yazi.nix), carried from the checkout
#   .config/omarchy*, Omacom, hyprmoncfg Omarchy's own trees; the wallpapers live in
#                                        ~/Pictures/Wallpapers (caelestia.nix)
#   .config/systemd/user                 Omarchy-era units; caelestia-shell.service there would
#                                        fight the home-manager caelestia service
#   .config/autostart                    Omarchy autostarts for apps not installed here
#   .config/mimeapps.list                defaults point at chromium / HEY, neither installed:
#                                        xdg-open would fail on every link
#   .config/git                          turns on commit signing with a key not on this machine
#   .config/fontconfig, dconf, gtk-4.0   home-manager writes these (fonts.fontconfig, gtk.nix)
#   .config/gtk-3.0/bookmarks            paths under the old /home/daemon-sec
#   .config/user-dirs.dirs               the XDG defaults already match
#   .config/floorp                       a browser profile is state, and the profile is Nix-built
#                                        now (modules/home/floorp.nix); the checkout's ShyFox tree
#                                        is vendored into modules/home/floorp/_shyfox
#   .config/tmux                         holds only a disabled backup; ~/.tmux.conf is the config
#   .bashrc, .bash_profile, .bash_logout source Omarchy's bash rc unguarded (errors on NixOS)
#   .zshrc, .zprofile                    the dead decoys; ZDOTDIR=~/.dotfiles bypasses them
#   .XCompose                            includes /usr/share/omarchy/default/xcompose
#   .claude, .codex                      live agent state, written by the agents; the
#                                        settings and memories are in secrets/agent-state.tar
#   .agents, */skills                    downloaded skills; the plugins reinstall them
#   bin, .local/bin                      ~/.local/bin is the live toolbox repo (README)
#   tooling/, manifests/, system/        Arch install scripts and inventories; the fan and
#                                        touchpad fixes are modules in modules/hosts/laptop, the
#                                        keyboard fix is kept in modules/hosts/laptop/keyboard-reference
#   .local/share/applications            Omarchy web-app launchers (omarchy-launch-webapp)
#   .local/share/icons/hicolor           apps install into it; the themes are linked one by one
{ ... }:
{
  flake.homeModules.dotfiles =
  { config, lib, pkgs, ... }:
  let
    flake = "${config.home.homeDirectory}/NixDaemon";
    repo = "${flake}/dotfiles";
    home = "${repo}/home";
    link = path: config.lib.file.mkOutOfStoreSymlink "${home}/${path}";

    # Same path under $HOME as in dotfiles/home.
    same = paths: lib.genAttrs paths (p: { source = link p; });
    # Entries of .config, by name.
    config' = names: lib.genAttrs names (n: { source = link ".config/${n}"; });

    cursorThemes = [
      "modernxp-retro-black" # the active cursor (gtk.nix, core.lua)
      "modernxp-retro-black-hyprcursor"
      "modernxp-rose-pine"
      "modernxp-rose-pine-hyprcursor"
      "retrosmart-rose-pine"
      "retrosmart-rose-pine-hyprcursor"
      "rose-pine-hyprcursor"
      "BreezeX-RosePine-Linux"
    ];
  in
  {
    home.file =
      same [
        ".dotfiles" # the zsh ZDOTDIR tree (modules/home/shell.nix sets ZDOTDIR)
        ".tmux.conf"
        ".ripgreprc" # RIPGREP_CONFIG_PATH, exported by .dotfiles/config/ripgrep.zsh
        "Music/AGENTS.md"
      ]
      // same (map (t: ".local/share/icons/${t}") cursorThemes)
      // {
        # The patched DMMono TTFs live in dotfiles/assets, outside home/.
        ".local/share/fonts/nerd-fonts-dm-mono".source =
          config.lib.file.mkOutOfStoreSymlink "${repo}/assets/fonts/nerd-fonts-dm-mono";
      };

    xdg.configFile = config' [
      # shell and prompt
      "atuin"
      "bat" # the "Rose Pine" theme BAT_THEME names (shell.nix rebuilds bat's cache)
      "carapace"
      "cheats" # the markdown cheat cards (cheats.zsh, ~/.local/bin/cheat-*)
      "crossfetch" # the login splash animation (animations.zsh); the fetch card itself is prompt.nix
      "eza"
      "mise"
      # tools
      "btop"
      "lazygit"
      "jj"
      "emacs"
      "opencode"
      "feroxbuster"
      "uncover"
      "herdr"
      "tensaku"
      "ai-usagebar"
      "bg-pasticcio"
      "libvirt"
      "zsh-abbr" # user-abbreviations: the gs/gco/lg… set from the Mac (core.zsh loads zsh-abbr)
      # media
      "cava"
      "imv"
      "zathura"
      "xournalpp"
      "spicetify"
      "vesktop"
      "pipewire" # 10-sample-rates.conf
      "wireplumber" # bluetooth-a2dp-autoconnect.conf
      # terminals and desktop bits
      "foot"
      "ghostty"
      "fcitx5"
      "xdg-terminals.list" # kitty first, for xdg-terminal-exec
      "chromium-flags.conf" # read only if a chromium is ever installed
      "menus" # the chrome-apps application menu entries
      "uwsm" # env.d/50-rose-pine-cursor (same values core.lua sets)
    ];

    # jj merges conf.d/*.toml after config.toml, so the public config keeps the
    # signing setup and the identity comes from here.
    sops.secrets."jj-identity.toml" = {
      sopsFile = ../../secrets/jj-identity.toml;
      format = "binary";
      path = "${config.xdg.configHome}/jj/conf.d/identity.toml";
    };
    # Where uncover reads its search-engine API keys (all empty when carried).
    sops.secrets."uncover-provider-config.yaml" = {
      sopsFile = ../../secrets/uncover-provider-config.yaml;
      format = "binary";
      path = "${config.xdg.configHome}/uncover/provider-config.yaml";
    };

    # Claude Code and Codex rewrite their own settings, so these are not linked
    # (a sops-nix file is read-only). They are kept as one encrypted tarball:
    #   agent-state list       what the snapshot holds
    #   agent-state restore    unpack into $HOME, never overwriting a file
    #   agent-state snapshot   fold the live settings and memories into it
    home.packages = [
      (pkgs.writeShellApplication {
        name = "agent-state";
        runtimeInputs = with pkgs; [ sops gnutar rsync coreutils ];
        text = ''
          flake="''${NIXDAEMON:-${flake}}"
          file=secrets/agent-state.tar
          cd "$flake" # sops finds .sops.yaml from the working directory
          tmp=$(mktemp -d /dev/shm/agent-state.XXXXXX)
          trap 'rm -rf "$tmp"' EXIT
          decrypt() { sops -d --input-type binary --output-type binary "$file" > "$tmp/state.tar"; }

          case "''${1:-}" in
            list)
              decrypt
              tar -tf "$tmp/state.tar" | grep -v '/$'
              ;;
            restore)
              decrypt
              tar -C "$HOME" --skip-old-files -xvf "$tmp/state.tar"
              ;;
            snapshot)
              decrypt
              mkdir "$tmp/tree"
              tar -C "$tmp/tree" -xf "$tmp/state.tar"
              cd "$HOME"
              shopt -s nullglob
              live=()
              for p in .claude/settings.json .claude/settings.local.json .claude/CLAUDE.md \
                       .claude/hooks .claude/themes .claude/plugins/installed_plugins.json \
                       .claude/plugins/known_marketplaces.json .claude/projects/*/memory \
                       .codex/AGENTS.md .codex/config.toml .codex/hooks.json .codex/rules \
                       .codex/herdr-agent-state.sh; do
                [ -e "$p" ] && live+=("$p")
              done
              rsync -a --relative "''${live[@]}" "$tmp/tree/"
              tar -C "$tmp/tree" --sort=name --owner=0 --group=0 --mtime=@0 -cf "$tmp/new.tar" .
              cd "$flake"
              sops -e --input-type binary --output-type binary --filename-override "$file" \
                "$tmp/new.tar" > "$tmp/new.enc"
              mv "$tmp/new.enc" "$file"
              echo "agent-state: ''${#live[@]} live paths folded into $flake/$file"
              ;;
            *)
              echo "usage: agent-state list|restore|snapshot" >&2
              exit 2
              ;;
          esac
        '';
      })
    ];
  }
  ;
}