Stop Scripting Your Setup: Why You Should Try Nix Home Manager

Stop Scripting Your Setup: Why You Should Try Nix Home Manager

We have all been there. You get a fresh laptop, or maybe you finally decide to wipe your current machine to start over. The first hour feels great, but then the reality sets in: you have to configure everything again.

Even if you are organized, it is a pain. You might have a repository of dotfiles and a few shell scripts you wrote three years ago to bootstrap your environment. You run them, and they mostly work. But then you start noticing the cracks. It doesn’t feel exactly like your other machine.

Maybe you start working and realize you are missing a specific config file for a tool you rarely touch but desperately need. Or perhaps you spent hours months ago researching an obscure flag to make a CLI utility behave a certain way, and now that setting is gone. Your muscle memory betrays you because your keyboard shortcuts aren’t quite right.

Then there is the issue of secrets. You can’t exactly check your SSH keys or API tokens into a public GitHub repository. So you end up manually copying files from a USB drive breaking any hope of full automation.

The problem gets worse if you juggle multiple machines, like a corporate MacBook for work and a Linux desktop at home. Keeping them in sync is a full-time job. Even if you manage to copy the config files, the underlying software might be different. You might have ripgrep version 13 on one machine and version 11 on the other, and you don’t realize the syntax has changed until your scripts fail.

There is a better way

This is usually where people talk about Nix and NixOS. If you haven’t heard of Nix, it’s a package manager and language that focuses on reproducibility. NixOS is a Linux distribution built entirely around this concept.

But here is the thing: you don’t need to switch your operating system to NixOS to solve these problems.

If you are on a company-issued MacBook, you obviously can’t install a new OS. If you are on Ubuntu and don’t want to reinstall everything, that’s fine too. You can install the Nix package manager on any Linux distro or macOS.

Once you have Nix, you can use Home Manager.

Home Manager allows you to manage your user environment using the Nix language. Instead of running imperative commands (like apt install, brew install, or manually edit text files), you describe the state you want your machine to be in.

You write a single configuration file that says “I want these programs installed,” “I want Git configured with this email and these aliases,” and “I want my shell to look like this.”

Why it solves the headache

When you use Home Manager, your environment becomes portable code. You can apply that configuration to a new machine, and it will pull down exactly what you specified.

Syncing is automatic. Because the configuration is text, you can version control it. When you make a change to your vim configuration on your personal machine, you push it to your repo. When you get to work, you pull the repo, run the Home Manager switch command, and your work machine is instantly updated to match.

No more version mismatches. Nix allows you to pin packages to specific commits. If you need a specific version of Node.js or Python to make your workflow function, you declare it. Home Manager ensures that exact version is installed, regardless of what the underlying operating system thinks is “current.”

Safe experimentation One of the best features is the ability to roll back. Let’s say you decide to try out a totally different shell configuration or a new terminal emulator. You change your config and switch. If you hate it, you don’t have to spend hours undoing your mess. You just switch into the previous status and your system is exactly how it was five minutes ago.

Il problema dei metadata DICOM

Un header DICOM tipico contiene centinaia di campi.

Esempio:

(0008,0060) Modality: CT
(0018,0050) Slice Thickness: 1.0
(0028,0010) Rows: 512
(0028,0011) Columns: 512
(0018,0015) Body Part Examined: HEAD
(0020,0037) Image Orientation Patient
 

Per un umano, interpretare questi valori richiede:

  • esperienza nel dominio

  • conoscenza dello standard DICOM

  • tempo per analizzare i dati

Per sviluppatori che lavorano con:

  • integrazione PACS

  • piattaforme medical imaging

  • pipeline AI

  • sistemi di data ingestion

può essere molto utile avere un livello di interpretazione più leggibile e immediato sopra i metadata grezzi.


Un approccio leggero

L’idea alla base di dicom-insight è semplice:

  1. leggere i file DICOM con pydicom

  2. estrarre i metadata rilevanti

  3. applicare alcune euristiche

  4. generare un report strutturato

Il report include ad esempio:

  • modalità dell’esame

  • distretto anatomico

  • dimensione della matrice

  • spessore delle slice

  • numero di immagini

  • possibile utilizzo di contrasto

In questo modo si ottiene una descrizione immediatamente leggibile dello studio.

 

Installazione

Il progetto utilizza uv, un moderno gestore di ambienti e dipendenze Python sviluppato da Astral.

Clonare il repository e Installare l’ambiente e le dipendenze:

				
					git clone https://github.com/dvisionlab/dicom-insight
cd dicom-insight
uv sync
				
			

Questo comando:

  • crea automaticamente un virtual environment

  • installa tutte le dipendenze

  • genera il lockfile per l’ambiente.

Utilizzo da Python

Esempio di analisi di un file DICOM:

				
					from dicom_insight import analyze_file

report = analyze_file("ct_head.dcm")

print(report.summary)
print(report.explanation)
				
			

Output esempio:

CT HEAD study
Matrix 512×512
Slice thickness: 1.0 mm
Likely non-contrast acquisition

Il report può anche essere esportato in formato JSON: 

				
					print(report.to_json())
				
			

Output:

				
					{
  "modality": "CT",
  "body_part": "HEAD",
  "rows": 512,
  "columns": 512,
  "slice_thickness": 1.0,
  "contrast_suspected": false
}
				
			

Questo rende la libreria facilmente integrabile in:

  • pipeline di data processing

  • strumenti di dataset exploration

  • workflow di machine learning

Analizzare un intero studio DICOM

La libreria include anche una CLI per analizzare intere cartelle contenenti file DICOM.

Esempio:

				
					uv run dicom-insight ./dicom-study
				
			

Output:

				
					Study summary
-------------
Modality: CT
Body part: CHEST
Slices: 324
Matrix: 512x512
Slice thickness: 1.25 mm
Contrast suspected: true
				
			

Questo tipo di analisi è particolarmente utile quando si lavora con:

  • dataset di imaging per AI

  • migrazioni di archivi PACS

  • controllo qualità delle acquisizioni

  • esplorazione di dataset clinici

Perché può essere utile

Strumenti semplici come questo possono semplificare diversi workflow.

Esplorazione dataset

Comprendere rapidamente la composizione di grandi collezioni di immagini medicali.

Pipeline AI

Estrarre automaticamente caratteristiche degli studi per il training dei modelli.

Ingestion PACS

Verificare rapidamente i metadata degli studi in ingresso.

Controllo qualità

Identificare incongruenze tra acquisizioni.


Possibili evoluzioni

Questo progetto è volutamente semplice, ma apre a diverse possibili estensioni:

  • analisi statistica di dataset DICOM

  • classificazione automatica degli studi

  • integrazione con DICOMweb

  • generazione automatica di preview delle serie

  • interpretazione dei metadata tramite LLM

L’idea è rendere l’ecosistema DICOM più accessibile agli sviluppatori, riducendo la distanza tra standard medicali complessi e strumenti software moderni.


Repository open-source

La libreria è disponibile su GitHub:

dicom-insight

Un piccolo toolkit Python per esplorare e interpretare metadata DICOM in modo semplice e leggibile.


About D/Vision Lab

In D/Vision Lab sviluppiamo soluzioni software avanzate per:

  • piattaforme di medical imaging

  • workflow clinici supportati da AI

  • integrazioni PACS e cloud

  • visualizzazione interattiva di dati medicali

Progetti come dicom-insight nascono dall’esperienza diretta nello sviluppo di sistemi di imaging medico e dall’obiettivo di rendere strumenti complessi più accessibili per sviluppatori, ricercatori e data scientist.

Latest articles

Stop Scripting Your Setup: Why You Should Try Nix Home Manager

Screenshot dal film The Matrix (1999) in cui i 3 agenti sono visti con il codice.

Stop Scripting Your Setup: Why You Should Try Nix Home Manager

Stop Scripting Your Setup: Why You Should Try Nix Home Manager