Skip to content

Commit 21fb7f3

Browse files
authored
use lazyAttrsOf and raw for nixosConfiguration (#2)
Fixes #1
1 parent 9ee3047 commit 21fb7f3

4 files changed

Lines changed: 14 additions & 20 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
# Dendritic unflake
1111

12-
This repository serves as an example Dendritic Nix setup implemented **without** flakes nor flake-parts.
12+
This repository serves as an example Dendritic Nix implementation **without** flakes nor flake-parts.
1313

1414

15-
Entry point is [default.nix](default.nix) and has an [example](modules/example.nix) Dendritic nixosConfiguration.
15+
Entry point is [default.nix](default.nix), [modules/example.nix](modules/example.nix) defines a nixosConfiguration.
1616

1717

18-
This example uses [unflake](https://discourse.nixos.org/t/unflake-flake-dependencies-for-non-flake-projects-and-a-way-to-stop-writing-follows/72611) to fetch dependencies.
18+
This example uses [unflake](https://discourse.nixos.org/t/unflake-flake-dependencies-for-non-flake-projects-and-a-way-to-stop-writing-follows/72611) to fetch dependencies and provide flake-like inputs.
1919

2020

2121
## Usage
@@ -29,11 +29,11 @@ nix-shell https://ln-s.sh/unflake -A unflake-shell --run unflake
2929
Build `my-laptop` nixos config:
3030

3131
```console
32-
nixos-rebuild build --file . --attr nixosConfigurations.my-laptop
32+
nixos-rebuild build -f . -A nixosConfigurations.my-laptop
3333
```
3434

3535
alternatively:
3636

3737
```console
38-
nix-build . --attr nixosConfigurations.my-laptop.config.system.build.toplevel
38+
nix-build -A nixosConfigurations.my-laptop.config.system.build.toplevel
3939
```

modules/example.nix

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
11
{ lib, self, ... }:
22
{
3-
43
modules.nixos.no-boot = {
54
boot.loader.grub.enable = false;
65
fileSystems."/".device = "/dev/no-device";
76
};
87

9-
modules.nixos.installer =
10-
{ modulesPath, ... }:
11-
{
12-
imports = [ (modulesPath + "/installer/cd-dvd/installation-cd-minimal.nix") ];
13-
};
14-
158
modules.nixos.statics = {
169
system.stateVersion = "25.11";
1710
nixpkgs.hostPlatform = "x86_64-linux";
1811
passthru = { };
1912
};
2013

14+
modules.nixos.my-laptop.imports = with self.modules.nixos; [
15+
statics
16+
no-boot
17+
];
18+
2119
nixosConfigurations.my-laptop = lib.nixosSystem {
22-
modules = with self.modules.nixos; [
23-
statics
24-
no-boot
25-
# installer
26-
];
20+
modules = [ self.modules.nixos.my-laptop ];
2721
};
2822
}

modules/options/modules.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{ lib, ... }:
22
{
33
options.modules = lib.mkOption {
4-
description = "<class>.<aspect> modules. equivalent to flake-parts' flake.modules";
4+
description = "<class>.<aspect> modules. akin to flake-parts' flake.modules";
55
default = { };
6-
type = lib.types.attrsOf (lib.types.attrsOf lib.types.deferredModule);
6+
type = lib.types.lazyAttrsOf (lib.types.lazyAttrsOf lib.types.deferredModule);
77
};
88
}

modules/options/nixos-configurations.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
options.nixosConfigurations = lib.mkOption {
44
description = "NixOS configurations";
55
default = { };
6-
type = lib.types.attrsOf lib.types.anything;
6+
type = lib.types.lazyAttrsOf lib.types.raw;
77
};
88
}

0 commit comments

Comments
 (0)