Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vic/fp-nm-ws
A flake-parts module to access per-system module arguments inside nixos-modules.
https://github.com/vic/fp-nm-ws
flake-parts flakes nix nixos-module
Last synced: about 2 months ago
JSON representation
A flake-parts module to access per-system module arguments inside nixos-modules.
- Host: GitHub
- URL: https://github.com/vic/fp-nm-ws
- Owner: vic
- License: apache-2.0
- Created: 2023-11-08T22:39:48.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-08T22:43:32.000Z (about 1 year ago)
- Last Synced: 2024-10-11T22:23:52.895Z (2 months ago)
- Topics: flake-parts, flakes, nix, nixos-module
- Language: Nix
- Homepage:
- Size: 5.86 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fp-nm-ws: FlakeParts NixosModule WithSystem'
This flake provides a [flake-parts](https://flake.parts) module
that allows nixos-modules to access [perSystem](https://flake.parts/module-arguments#withsystem) [module parameters](https://flake.parts/module-arguments#persystem-module-parameters) without having to rely on global variables.Mixing the provided `nixosModules.default` module, will provide you
with `withSystem'`, `self'`, and `inputs'` to your other nixos modules.### Example Usage
```nix
# flake.nix
{
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
inputs.fp-nm-ws.url = "github:vic/fp-nm-ws";
outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } ./your-flake-module.nix;
}
``````nix
# your-flake-module.nix
{inputs, ...}: {
perSystem = {system, ...}: {
config._module.args.foo = "moo-${system}"; # suppose you have a per-system module argument named foo.
options.bar.default = "some per-system option";
};flake.nixosModules.your-nixos-module.imports = [
inputs.fp-nm-ws.nixosModules.default # mix-in along with your nixos module.
./your-nixos-module.nix
];}
``````nix
# your-nixos-module.nix
{ config, lib, withSystem', inputs', ...}: {# an example usage is reusing the same nixpkgs instance.
nixpkgs.pkgs = inputs'.nixpkgs.legacyPackages;accessFoo = withSystem' ({foo, ...}: foo); # use named parameters
accessBar = withSystem' (sys@{config, ...}: sys.config.bar);}
```