Modules and library for filesystem based configuration.
Add the flake to your existing configuration.
# flake.nix
inputs = {
nixos-tidy = {
url = "github:pipelight/nixos-tidy";
inputs.nixpkgs.follows = "nixpkgs";
};
};
# 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 {
})
];
};
}
};
-
Minimalist
Find many minimalists examples self-contained in a single
flake.nix
file, in the templates directory. -
Real world
And a complete working example at crocuda.nixos. Where all the magic happens in
default.nix
.
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.
# 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
];
};
It enables a most wanted separation of concerns, where home-manager modules and nix modules can lay in the same directory.
.
├── gnome
│ ├── default.nix
│ ├── test.nix
│ └── home.nix
├── hyprland
│ ├── default.nix
│ ├── test.nix
│ └── home.nix
└── flake.nix # put boilerplate code at the flake top-level.
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"];
};
See the template flake with umports 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.
Use inputs.nixos-tidy.nixosModules.home-merger
.
Checkout module definition for
options list.
Home-merger is a wrapper around home-manager that you can call multiple times, in order to scatter user definitions in separate files.
- Use it to split user definition.
# file_1.nix
home-merger = {
users = ["alice"];
umports.paths = [
./alice_modules
];
};
# 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 adjacentdefault.nix
module.
.
└── fish
├── default.nix
└── home.nix
# fish/default.nix
programs.fish.enable = true;
home-merger = {
users = ["bob"];
umports.paths = [
./home.nix
];
};
# fish/home.nix
home.programs.fish.enable = true;
Use inputs.nixos-tidy.nixosModules.allow-unfree
Cherry-pick unfree software exceptions with regexes.
#default.nix
allow-unfree = [
# use regexes
"nvidia-.*"
"cuda.*"
];
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.