https://github.com/pipelight/nixos-tidy
Nix functions to create sharable, flexible and standardized Nixos configurations.
https://github.com/pipelight/nixos-tidy
Last synced: 2 months ago
JSON representation
Nix functions to create sharable, flexible and standardized Nixos configurations.
- Host: GitHub
- URL: https://github.com/pipelight/nixos-tidy
- Owner: pipelight
- License: gpl-2.0
- Created: 2024-01-17T09:42:02.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-28T12:41:35.000Z (3 months ago)
- Last Synced: 2025-05-05T15:18:54.280Z (2 months ago)
- Language: Nix
- Homepage:
- Size: 470 KB
- Stars: 69
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Nixos-tidy - Make filesystem based configurations.
Modules and library for filesystem based configuration.
## Install (add to your config).
Add the flake to your existing configuration.
```nix
# flake.nix
inputs = {
nixos-tidy = {
url = "github:pipelight/nixos-tidy";
inputs.nixpkgs.follows = "nixpkgs";
};
};
``````nix
# flake.nix
outputs = {
self,
nixpkgs,
...
}: {
nixosConfiguration = {
default = pkgs.lib.nixosSystem {
modules = [
# pick some modules
inputs.nixos-tidy.nixosModules.home-merger
({
config,
pkgs,
lib,
inputs,
...
}: let
# Use functions from library.
slib = inputs.nixos-tidy.lib;
in {})
];
};
}
};
```## Examples
- Minimalist
Find many minimalists examples self-contained in a single `flake.nix` file,
in the [templates directory](https://github.com/pipelight/nixos-tidy/blob/master/templates/).- Real world
And a complete working example at [crocuda.nixos](https://github.com/pipelight/crocuda.nixos).
Where all the magic happens in `default.nix`.## A single Top-level imports 🤌 (umports).
Use `slib = inputs.nixos-tidy.lib`
Get rid of **imports** statements everywhere.
You only need **one top-level imports** statement.It imports recursively all the files from inside a directory.
### Nix only (without home-manager)
```nix
# flake.nix
imports = let
slib = inputs.nixos-tidy.lib;
in
[]
# Import all nixos modules recursively
++ slib.umportNixModules {
paths = [
inputs.anOtherFlake.nixosModules.default
./.
];
exclude = [
# Do not forget to exclude current file
# and flake definition.
./default.nix
./flake.nix
];
};
```### With home-manager
It enables a most wanted separation of concerns,
where home-manager modules and nix modules
can lay in the same directory.```sh
.
├── gnome
│  ├── default.nix
│  ├── test.nix
│  └── home.nix
├── hyprland
│ ├── default.nix
│  ├── test.nix
│ └── home.nix
└── flake.nix # put boilerplate code at the flake top-level.
``````nix
imports = let
slib = inputs.nixos-tidy.lib;
in
[]
# Import all nixos modules recursively
++ slib.umportNixModules {
paths = [
inputs.anOtherFlake.nixosModules.default
./.
];
exclude = [
# Do not forget to exclude current file
# and flake definition.
./default.nix
./flake.nix
]
}
++ slib.umportHomeModules {
paths = [
inputs.nur.modules.homeManager.default
./.
];
}
# Home-merger options
{
users = ["anon"];
};
```### File naming constraints.
See the [template flake with umports](https://github.com/pipelight/nixos-tidy/blob/master/templates/umports/flake.nix) for a working example (with home-manager).
Umports makes the distinctions between module types based on
filenames.
So be sure to have your filenames checked.Nix: \*.nix
Home-manager: home.nix || home.\*.nix || home\_\*.nix
Unit-tests: test.nix || test.\*.nix || test\_\*.nix.## A flexible home-manager (Home-merger).
Use `inputs.nixos-tidy.nixosModules.home-merger`.
Checkout module definition for
[options list](https://github.com/pipelight/nixos-tidy/blob/master/modules/home-merger/default.nix).Home-merger is a wrapper around home-manager that you can call multiple times,
in order to scatter user definitions in separate files.### Top-level import (Umports)
- Use it to split user definition.
```nix
# file_1.nix
home-merger = {
users = ["alice"];
umports.paths = [
./alice_modules
];
};
``````nix
# file_2.nix
home-merger = {
users = ["bob"];
extraSpecialArgs = {inherit inputs;};
imports = [
inputs.anOtherModule.homeManagerModules.default
];
umports.paths = [
./bob_modules
];
};
```- Or use it
to import a `home.nix` module
from an adjacent `default.nix` module.```sh
.
└── fish
  ├── default.nix
  └── home.nix
``````nix
# fish/default.nix
programs.fish.enable = true;home-merger = {
users = ["bob"];
umports.paths = [
./home.nix
];
};
``````nix
# fish/home.nix
home.programs.fish.enable = true;
```## Allow-unfree
Use `inputs.nixos-tidy.nixosModules.allow-unfree`
Cherry-pick unfree software exceptions with regexes.
```nix
#default.nix
allow-unfree = [
# use regexes
"nvidia-.*"
"cuda.*"
];
```## Network privacy (ipv6)
Use `inputs.nixos-tidy.nixosModules.networking-privacy`
Not released yet.
Only on dev branch.Strengthen ipv6 privacy configuration for
Linux kernel,
NetworkManager,
openvswitch,
static configuration
and systemd-networkd.