repositories

NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor

clonegit clone https://git.daemon-sec.xyz/NixDaemon.git
nixmod.mdMarkdown165 lines7.9 KiBsource raw download

nixmod — add and configure tools in NixDaemon#

Terminal card: nixmod-cheat — sections start discover new settings edit check templates remove fix checkout. Run from ~/NixDaemon, or pass --repo ~/NixDaemon. Nixmod reads the Home Manager and nixpkgs versions pinned in flake.lock; it never activates the system.

start — the usual workflow#

nixmod search TOOL                     # find Home Manager / NixOS modules and packages
nixmod doc TOOL                        # options, defaults, examples, pinned source links
nixmod new TOOL --dry-run              # preview without changing files
nixmod new TOOL                        # generate, git-add, wire the import, evaluate this host
nvim modules/home/TOOL.nix             # adjust settings
nixmod check TOOL                      # syntax first, then the selected host's configuration
nh os build                           # actual build, without activation

Replace TOOL with the program name. nixmod TOOL is shorthand for nixmod new TOOL. The installed command gets checkout changes on the next system activation; see checkout to use the updated source immediately.

discover — Home Manager, NixOS, or just a package#

nixmod search gallery
nixmod doc gallery-dl
nixmod doc programs.gallery-dl --home
nixmod doc services.syncthing --nixos
nixmod list                            # modules created by nixmod, plus available templates

new — create and wire a module#

nixmod new firefox                    # Home Manager preferred
nixmod new --home firefox             # Home Manager only
nixmod new --nixos steam              # NixOS only
nixmod new sync --option services.syncthing --home
nixmod new gallery-dl --dry-run        # preview, even if the module already exists
nixmod new TOOL --edit                 # open in $EDITOR; check again after editing
nixmod new TOOL --no-wire              # create the file; add its import yourself

Home modules go in modules/home/TOOL.nix; NixOS modules go in modules/features/TOOL.nix. The selected host's import list is updated automatically. Existing modules are preserved; --force explicitly overwrites one and discards its previous contents.

The host defaults to your hostname when it matches a flake configuration. With multiple hosts and no match, select one with nixmod's --host. The owner's laptop is nixos, with user daemonsec; do not substitute the generic nixdaemon configuration.

settings — values without editing braces#

# For a NEW module; add --dry-run to preview an existing one:
nixmod new gallery-dl --set 'settings.extractor.base-directory=~/Downloads/gallery-dl/'
nixmod new kitty --set font.size=12 --set settings.enable_audio_bell=false
nixmod new gallery-dl --set 'settings.extractor.retries=3'
nixmod new gallery-dl --set 'settings.extractor.example=["one","two"]' --dry-run

Repeat --set PATH=VALUE for several settings. Paths are relative to the selected module; full paths such as programs.gallery-dl.settings.extractor.base-directory also work. Values are JSON booleans, numbers, lists, objects, null, or plain strings. To preserve true as text, use --set 'settings.example="true"'. Quote arguments containing spaces or shell characters. For a key containing a dot: --set 'settings."a.b"=value'.

Unknown Home Manager / NixOS paths and overlapping assignments are rejected. Free-form application settings still need the tool's documentation for supported keys and values. The example keys above demonstrate syntax; they are not gallery-dl configuration advice. --set creates modules; edit an existing module in its file.

edit — keep the settings wrapper#

Empty settings wrappers are active; upstream examples stay commented. Uncomment individual assignments inside the wrapper, or add your own:

programs.gallery-dl = {
  enable = true;
  settings = {
    extractor.base-directory = "~/Downloads/gallery-dl/";
  };
};

extractor belongs under settings, not directly under programs.gallery-dl. Keep each { paired with };. Upstream examples are optional; nixmod does not invent credentials or enable every example.

check — catch mistakes before rebuilding#

nixmod check gallery-dl                # parse that module, then evaluate this host
nixmod check                          # evaluate this host
nixmod new TOOL --check                # also evaluate both configured hosts
nixmod new TOOL --no-check             # syntax only; skip automatic host evaluation
nh os build                           # build the configuration after evaluation passes

New program modules evaluate the selected host by default. Other templates are scaffolds and only evaluate hosts when --check is requested. A failed check returns a failure status and keeps the file for editing. Evaluation may fetch flake inputs; it does not build packages or activate NixOS. Host checks validate only that host's imported modules. --no-wire reports a syntax-only check until you add the import.

templates — something other than a recognized program#

nixmod templates
nixmod new -t packages recon           # a bundle of packages
nixmod new -t script backup            # your own command, with dependencies
nixmod new -t service tunnel           # a user systemd service; timer example included
nixmod new -t config foot              # home files and xdg.configFile
nixmod new -t feature --nixos lab       # daemon.lab.enable, initially off
nixmod new -t package mytool           # a derivation; fill in source and hash
nix build .#mytool                     # package templates need a package build

Use --nixos for a system service. The config template is Home Manager only. Script, service, feature and package templates need your own implementation before use.

remove — review before deleting#

nixmod rm TOOL --dry-run               # preview the file and imports that would be removed
nixmod rm TOOL                         # ask before deleting
nixmod rm TOOL -y                      # explicitly confirm deletion
nixmod rm TOOL --check                 # remove, then evaluate both hosts

Removal also unwires imports. It normally refuses modules without the Started by nixmod marker and stops when another file still refers to them. --force bypasses those checks; review the dry run before using it. Host definitions are never removable through nixmod.

fix — common errors#

checkout — use the source version now#

cd ~/NixDaemon
python3 -B modules/home/_nixmod/nixmod.py doc gallery-dl
python3 -B modules/home/_nixmod/nixmod.py check gallery-dl
python3 -B modules/home/_nixmod/nixmod.py new gallery-dl --dry-run \
  --set 'settings.extractor.base-directory=~/Downloads/gallery-dl/'

Full guide: docs/nixmod.md. Source: modules/home/_nixmod/nixmod.py and options.nix.