Generate flake.nix from module options. Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/ dendrix.oeiuwq.com/Dendritic.html
dendritic nix inputs

fix: use `attrsOf anything` instead of `attrs` (#55)

* fix: use `attrsOf anything` instead of `attrs`

this has more predictable merging behaviour, `attrs` was silently discaring substituters defined in different files.

* feat: make it a `freeformType` instead, and add mergeable lists for common options

authored by

Vidhan Bhatt and committed by
GitHub
fa1846d8 af92ed37

+43 -3
+33 -1
modules/options/flake-file.nix
··· 13 13 nixConfig = lib.mkOption { 14 14 default = { }; 15 15 description = "nix config"; 16 - type = lib.types.attrs; 16 + type = lib.types.submodule { 17 + freeformType = lib.types.attrsOf lib.types.anything; 18 + 19 + options = { 20 + substituters = lib.mkOption { 21 + type = lib.types.listOf lib.types.str; 22 + description = '' 23 + List of binary cache URLs used to obtain pre-built binaries 24 + of Nix packages. 25 + ''; 26 + }; 27 + 28 + extra-substituters = lib.mkOption { 29 + type = lib.types.listOf lib.types.str; 30 + description = '' 31 + List of binary cache URLs used to obtain pre-built binaries 32 + of Nix packages. 33 + ''; 34 + }; 35 + 36 + trusted-public-keys = lib.mkOption { 37 + type = lib.types.listOf lib.types.str; 38 + example = [ "hydra.nixos.org-1:CNHJZBh9K4tP3EKF6FkkgeVYsS3ohTl+oS0Qa8bezVs=" ]; 39 + description = "List of public keys used to sign binary caches."; 40 + }; 41 + 42 + extra-trusted-public-keys = lib.mkOption { 43 + type = lib.types.listOf lib.types.str; 44 + example = [ "hydra.nixos.org-1:CNHJZBh9K4tP3EKF6FkkgeVYsS3ohTl+oS0Qa8bezVs=" ]; 45 + description = "List of public keys used to sign binary caches."; 46 + }; 47 + }; 48 + }; 17 49 }; 18 50 }; 19 51 };
+10 -2
modules/write-flake.nix
··· 1 1 { 2 2 lib, 3 + options, 3 4 config, 4 5 inputs, 5 6 ... ··· 80 81 ''; 81 82 82 83 nixConfig = 83 - if flake-file.nixConfig != { } then 84 + let 85 + nixConfigOptions = 86 + options.flake-file.valueMeta.configuration.options.nixConfig.valueMeta.configuration.options; 87 + filteredConfig = lib.filterAttrs ( 88 + name: _: !(nixConfigOptions ? ${name}) || nixConfigOptions.${name}.isDefined 89 + ) flake-file.nixConfig; 90 + in 91 + if filteredConfig != { } then 84 92 '' 85 - nixConfig = ${nixCode flake-file.nixConfig}; 93 + nixConfig = ${nixCode filteredConfig}; 86 94 '' 87 95 else 88 96 "";