# Refactoring My Infrastructure As Code Configurations

**URL:** https://discourse.nixos.org/t/refactoring-my-infrastructure-as-code-configurations/63720
**Category:** Links
**Created:** [May 1, 2025, 10:05am UTC](https://discourse.nixos.org/t/refactoring-my-infrastructure-as-code-configurations/63720 "2025-05-01T10:05:48Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![drupol](https://discourse.nixos.org/user_avatar/discourse.nixos.org/drupol/32/9471_2.png) [@drupol](https://discourse.nixos.org/u/drupol)
#### Post date: [May 1, 2025, 10:05am UTC](https://discourse.nixos.org/t/refactoring-my-infrastructure-as-code-configurations/63720/1 "2025-05-01T10:05:48Z")

</div>

> **[Refactoring My Infrastructure As Code Configurations](https://not-a-number.io/2025/refactoring-my-infrastructure-as-code-configurations/)**
>
> The drupol/nixos-x260 repository began as a simple and practical way to manage the configuration of my Lenovo ThinkPad X260 laptop, hence the (bad) name. Unsurprisingly, I quickly became hooked on the NixOS Linux distribution, and before long, I was...

---

<div class="post-metadata">

### Author: ![mightyiam](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mightyiam/32/33998_2.png) [@mightyiam](https://discourse.nixos.org/u/mightyiam)
#### Post date: [May 3, 2025, 10:26am UTC](https://discourse.nixos.org/t/refactoring-my-infrastructure-as-code-configurations/63720/2 "2025-05-03T10:26:32Z")

</div>

Thank you for taking the time to write this and share publicly. As desktop Linux users are flocking to NixOS it is valuable they are exposed to patterns to choose from that make sense to them.

> It is definitely the best Flake framework and it is simply out of this world!

@roberth 👆

> Simplify the user interface for defining a host machine

I want this as well.

> Create a Nix starter template to help newcomers to adopt this approach.

💯

> I would like to thank [Shahar “Dawn” Or (mightyiam)](https://github.com/mightyiam) for [pioneering](https://discourse.nixos.org/t/pattern-every-file-is-a-flake-parts-module/61271) this approach. My repository is inspired by his work.

🕺 🕺 🕺

---

<div class="post-metadata">

### Author: ![mightyiam](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mightyiam/32/33998_2.png) [@mightyiam](https://discourse.nixos.org/u/mightyiam)
#### Post date: [May 4, 2025, 5:50am UTC](https://discourse.nixos.org/t/refactoring-my-infrastructure-as-code-configurations/63720/3 "2025-05-04T05:50:52Z")

</div>

> <https://github.com/mightyiam/infra/commit/c858a90525b2f1a8184ded6da2e2b6ef786ec1e3>

---

<div class="post-metadata">

### Author: ![quasigod](https://discourse.nixos.org/user_avatar/discourse.nixos.org/quasigod/32/37014_2.png) [@quasigod](https://discourse.nixos.org/u/quasigod)
#### Post date: [May 5, 2025, 8:58pm UTC](https://discourse.nixos.org/t/refactoring-my-infrastructure-as-code-configurations/63720/4 "2025-05-05T20:58:45Z")

</div>

I really liked this writeup! I’ve been working on my own refactor as well that has a lot in common with what you’re doing!

Currently, I have a module system that lets you define configs for nixos, home, and darwin. The modules are imported, and the config is split into separate nixos, home, and darwin modules and imported as needed. I don’t use feature tags, but do enable different modules by default based on systems tags like workstation, gaming, laptop, etc.

This system works pretty well for the most part, but there’s some weird stuff going on with imports, I think because of conditional imports not being allowed. Using flake-parts modules should fix that. Thanks for sharing!

---

<div class="post-metadata">

### Author: ![drupol](https://discourse.nixos.org/user_avatar/discourse.nixos.org/drupol/32/9471_2.png) [@drupol](https://discourse.nixos.org/u/drupol)
#### Post date: [May 5, 2025, 9:00pm UTC](https://discourse.nixos.org/t/refactoring-my-infrastructure-as-code-configurations/63720/5 "2025-05-05T21:00:02Z")

</div>

Do you have a link to your repo?

---

<div class="post-metadata">

### Author: ![quasigod](https://discourse.nixos.org/user_avatar/discourse.nixos.org/quasigod/32/37014_2.png) [@quasigod](https://discourse.nixos.org/u/quasigod)
#### Post date: [May 5, 2025, 9:20pm UTC](https://discourse.nixos.org/t/refactoring-my-infrastructure-as-code-configurations/63720/6 "2025-05-05T21:20:11Z")

</div>

Sure, it’s currently not entirely functional or documented in the slightest. I’m also using [nilla](https://github.com/nilla-nix/nilla) and npins atm instead of using flakes.

The library for the modules is here: [quasigod/unify: A framework for unifying multiple types of Nix configurations, allowing you to easily define them in the same modules. - Codeberg.org](https://codeberg.org/quasigod/unify)

And this is the configuration using it: [Making sure you're not a bot!](https://codeberg.org/quasigod/nixconfig/src/branch/nilla)

Both have out of date readme’s and no docs atm. The config is able to build, but I’m not super happy with the structure atm. For example, the imports.nix file which handles all the imports to avoid issues with conditional imports. I’m in the middle of finals week atm, but after it, I hope to clean a lot of it up.
