Modular, context-aware and aspect-oriented dendritic Nix configurations. Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/ den.oeiuwq.com
configurations den dendritic nix aspect oriented

Improve CI examples organization - one aspect+usage+check per file (#75)

This helps people find aspect implementation, aspect usage and test in one file.

Closes #73

authored by oeiuwq.com and committed by

GitHub 19e00ef7 374ad5fb

+451 -302
+6 -6
README.md
··· 24 24 25 25 - [Parametric](modules/aspects/provides/define-user.nix) over `host`/`home`/`user`. 26 26 27 - - [Share](templates/default/modules/_profile/namespace.nix) aspects across systems & repos. 27 + - [Share](templates/examples/modules/_profile/namespace.nix) aspects across systems & repos. 28 28 29 29 - Bidirectional [dependencies](modules/aspects/dependencies.nix): user/host contributions. 30 30 ··· 38 38 39 39 - [Batteries](modules/aspects/provides/): Opt-in, replaceable aspects. 40 40 41 - - [Well-tested](templates/default/modules/_example/ci.nix) with an [example suite](templates/default/modules/). 41 + - [Well-tested](templates/examples/modules/_example/ci) with [examples](templates/examples). 42 42 43 43 Need more batteries? See [vic/denful](https://github.com/vic/denful). 44 44 ··· 46 46 </td> 47 47 <td> 48 48 49 - 🏠 Define [Hosts, Users](templates/default/modules/_example/hosts.nix) & [Homes](templates/default/modules/_example/homes.nix) concisely. 49 + 🏠 Define [Hosts, Users](templates/examples/modules/_example/hosts.nix) & [Homes](templates/examples/modules/_example/homes.nix) concisely. 50 50 51 51 See schema in [`_types.nix`](modules/_types.nix). 52 52 ··· 61 61 } 62 62 ``` 63 63 64 - 🧩 [Aspect-oriented](https://github.com/vic/flake-aspects) incremental features. ([example](templates/default/modules/_example/aspects.nix)) 64 + 🧩 [Aspect-oriented](https://github.com/vic/flake-aspects) incremental features. ([example](templates/default/modules/den.nix)) 65 65 66 66 Any module can contribute configurations to aspects. 67 67 ··· 114 114 nix run .#vm 115 115 ``` 116 116 117 - Our [default template](templates/default) provides a [profile-based layout](templates/default/modules/_profile/) for a quick start. 117 + Our [default template](templates/default) provides an annotated quick-start. 118 118 119 119 </td> 120 120 </tr> ··· 122 122 123 123 You are done! You know everything to start creating configurations with `den`. 124 124 125 - Feel free to to __explore__ the codebase, particularly our [included batteries](modules/aspects/provides) and [tests](templates/default/modules/_example). 125 + Feel free to to __explore__ the codebase, particularly our [included batteries](modules/aspects/provides) and [tests](templates/examples/modules/_example/ci). 126 126 127 127 ## Learn more at our [documentation website](https://vic.github.io/den) 128 128
templates/examples/modules/_example/_non_dendritic/hosts/honeycrisp/_darwin/something.nix templates/examples/modules/_example/ci/_non_dendritic/hosts/honeycrisp/_darwin/something.nix
templates/examples/modules/_example/_non_dendritic/hosts/rockhopper/_nixos/hardware-auto-generated.nix templates/examples/modules/_example/ci/_non_dendritic/hosts/rockhopper/_nixos/hardware-auto-generated.nix
-157
templates/examples/modules/_example/aspects.nix
··· 1 - # Feel free to remove this file, adapt or split into modules. 2 - # 3 - # NOTE: This file does not reflect best organization practices, 4 - # for that see the _profile directory. 5 - # 6 - # These examples exercice all den features, use them as reference 7 - # of usage. 8 - # See ci.nix for checks. 9 - # See defaults.nix, and other files in _example/*.nix 10 - { 11 - inputs, 12 - lib, 13 - den, 14 - ... 15 - }: 16 - let 17 - # A custom `nixos` class module that defines an option `names`. 18 - # Used to test that we are not duplicating values from owned configs. 19 - nixosNames.options.names = lib.mkOption { type = lib.types.listOf lib.types.str; }; 20 - 21 - # Example: A static aspect for vm installers. 22 - vm-bootable = { 23 - nixos = 24 - { modulesPath, ... }: 25 - { 26 - imports = [ (modulesPath + "/installer/cd-dvd/installation-cd-minimal.nix") ]; 27 - }; 28 - }; 29 - 30 - # Example: parametric host aspect to automatically set hostName on any host. 31 - set-host-name = 32 - { host, ... }: 33 - { 34 - ${host.class}.networking.hostName = host.name; 35 - }; 36 - 37 - # Example: configuration that depends on both host and user. provides anytime { user, host } is in context. 38 - user-to-host-conditional = 39 - { user, host, ... }: 40 - if user.userName == "alice" && !lib.hasSuffix "darwin" host.system then 41 - { 42 - nixos.programs.tmux.enable = true; 43 - } 44 - else 45 - { }; 46 - 47 - # Example: adds hello into each user. provides only to OS. 48 - hello-package-for-user = 49 - { 50 - OS, 51 - fromUser, 52 - user, 53 - host, 54 - ... 55 - }: 56 - den.lib.take.unused [ OS fromUser ] { 57 - ${host.class} = 58 - { pkgs, ... }: 59 - { 60 - users.users.${user.userName}.packages = [ pkgs.hello ]; 61 - }; 62 - }; 63 - 64 - # Example: configuration that depends on both host and user. provides only to HM. 65 - host-to-user-conditional = 66 - { 67 - HM, 68 - user, 69 - host, 70 - ... 71 - }: 72 - den.lib.take.unused [ HM ] ( 73 - if user.userName == "alice" && !lib.hasSuffix "darwin" host.system then 74 - { 75 - homeManager.programs.git.enable = true; 76 - } 77 - else 78 - { } 79 - ); 80 - 81 - # Example: luke standalone home-manager has access to rockhopper osConfig specialArg. 82 - os-conditional-hm = 83 - { home }: 84 - { 85 - # access osConfig, wired via extraSpecialArgs in homes.nix. 86 - homeManager = 87 - { osConfig, ... }: 88 - { 89 - programs.bat.enable = osConfig.programs.${home.programToDependOn}.enable; 90 - }; 91 - }; 92 - 93 - in 94 - { 95 - den.default.includes = [ 96 - # Example: static aspect 97 - vm-bootable 98 - 99 - # Example: parametric { host } aspect 100 - set-host-name 101 - 102 - # Example: parametric { OS, fromUser } aspect. 103 - hello-package-for-user 104 - 105 - # Example: parametric over many contexts: { home }, { host, user }, { fromUser, toHost } 106 - den.provides.define-user 107 - ]; 108 - 109 - # Example: user provides static config to all its nixos hosts. 110 - den.aspects.alice.nixos.users.users.alice.description = "Alice Q. User"; 111 - 112 - # Example: host provides static config to all its users hm. 113 - den.aspects.rockhopper.homeManager.programs.direnv.enable = true; 114 - 115 - # Example: adelie host using github:nix-community/NixOS-WSL 116 - den.aspects.adelie.nixos = { 117 - imports = [ inputs.nixos-wsl.nixosModules.default ]; 118 - wsl.enable = true; 119 - }; 120 - 121 - # Example: enable helix for alice on all its home-managed hosts. 122 - den.aspects.alice.homeManager.programs.helix.enable = true; 123 - 124 - # can uses unfree vscode. 125 - den.aspects.cam.homeManager.programs.vscode.enable = true; 126 - den.aspects.cam.includes = [ (den._.unfree [ "vscode" ]) ]; 127 - 128 - den.aspects.will.includes = [ 129 - # will has always loved red snappers 130 - (den._.user-shell "fish") 131 - # will is primary user in WSL NixOS. 132 - den._.primary-user 133 - ]; 134 - 135 - den.aspects.rockhopper.nixos.names = [ "tux" ]; 136 - den.aspects.rockhopper.includes = [ 137 - # Example: importing a third-party nixos module. 138 - { nixos.imports = [ nixosNames ]; } 139 - # Example: host provides parametric user configuration. 140 - host-to-user-conditional 141 - ]; 142 - 143 - # Example: user provides parametric host configuration. 144 - den.aspects.alice.includes = [ 145 - user-to-host-conditional 146 - # alice is always admin in all its hosts 147 - den._.primary-user 148 - ]; 149 - 150 - # Example: standalone-hm config depends on osConfig (non-recursive) 151 - # NOTE: this will only work for standalone hm, and not for hosted hm 152 - # since a hosted hm configuration cannot depend on the os configuration. 153 - den.aspects.luke.includes = [ 154 - os-conditional-hm 155 - ]; 156 - 157 - }
-118
templates/examples/modules/_example/ci.nix
··· 1 - # Adds some checks for CI 2 - { self, lib, ... }: 3 - { 4 - perSystem = 5 - { pkgs, ... }: 6 - let 7 - checkFile = 8 - name: file: 9 - pkgs.runCommandLocal name { } '' 10 - ls -la ${file} | tee $out 11 - ''; 12 - 13 - checkCond = 14 - name: cond: 15 - let 16 - code = if cond then "touch $out" else ''echo "Cond-Failed: ${name}"''; 17 - in 18 - pkgs.runCommandLocal name { } code; 19 - 20 - rockhopper = self.nixosConfigurations.rockhopper; 21 - honeycrisp = self.darwinConfigurations.honeycrisp; 22 - adelie = self.wslConfigurations.adelie; 23 - cam = self.homeConfigurations.cam; 24 - bob = self.homeConfigurations.bob; 25 - luke = self.homeConfigurations.luke; 26 - 27 - alice-at-rockhopper = rockhopper.config.home-manager.users.alice; 28 - alice-at-honeycrisp = honeycrisp.config.home-manager.users.alice; 29 - 30 - checks.x86_64-linux = { 31 - vm = checkFile "vm-builds" "${rockhopper.config.system.build.vm}/bin/run-rockhopper-vm"; 32 - 33 - hosts-rockhopper = checkFile "nixos-builds" rockhopper.config.system.build.toplevel; 34 - homes-cam = checkFile "home-builds" cam.activation-script; 35 - 36 - rockhopper-hostname = checkCond "den.default.host.includes sets hostName" ( 37 - rockhopper.config.networking.hostName == "rockhopper" 38 - ); 39 - honeycrisp-hostname = checkCond "den.default.host.includes sets hostName" ( 40 - honeycrisp.config.networking.hostName == "honeycrisp" 41 - ); 42 - alice-primary-on-macos = checkCond "den._.primary-user sets macos primary" ( 43 - honeycrisp.config.system.primaryUser == "alice" 44 - ); 45 - alice-exists-on-rockhopper = checkCond "den.default.user.includes defines user on host" ( 46 - rockhopper.config.users.users.alice.isNormalUser 47 - ); 48 - alice-not-exists-on-adelie = checkCond "den.default.user.includes defines user on host" ( 49 - !adelie.config.users.users ? alice 50 - ); 51 - will-exists-on-adelie = checkCond "den.default.user.includes defines user on host" ( 52 - adelie.config.users.users.will.isNormalUser 53 - ); 54 - will-is-wsl-default = checkCond "wsl.defaultUser defined" (adelie.config.wsl.defaultUser == "will"); 55 - 56 - import-tree = checkCond "auto-imported from rockhopper/_nixos" (rockhopper.config.auto-imported); 57 - 58 - user-contributes-to-host = checkCond "alice.nixos sets on rockhopper host" ( 59 - rockhopper.config.users.users.alice.description == "Alice Q. User" 60 - ); 61 - 62 - host-contributes-to-user = checkCond "rockhopper contributes to all its users" ( 63 - alice-at-rockhopper.programs.direnv.enable 64 - ); 65 - 66 - alice-hm-fish-enabled-by-default = checkCond "home-managed fish for alice" ( 67 - alice-at-rockhopper.programs.fish.enable 68 - ); 69 - alice-hm-helix-enabled-by-user = checkCond "home-managed helix for alice" ( 70 - alice-at-rockhopper.programs.helix.enable 71 - ); 72 - 73 - alice-hm-git-enabled-on = checkCond "home-managed git for alice at rockhopper" ( 74 - alice-at-rockhopper.programs.git.enable 75 - ); 76 - alice-hm-git-enabled-off = checkCond "home-managed git for alice at honeycrisp" ( 77 - !alice-at-honeycrisp.programs.git.enable 78 - ); 79 - 80 - alice-os-tmux-enabled-on = checkCond "os tmux for hosts having alice" ( 81 - rockhopper.config.programs.tmux.enable 82 - ); 83 - alice-os-tmux-enabled-off = checkCond "os tmux for hosts having alice" ( 84 - !honeycrisp.config.programs.tmux.enable 85 - ); 86 - 87 - will-always-love-you = checkCond "red-snapper fish is default shell" ( 88 - "fish" == lib.getName adelie.config.users.users.will.shell 89 - ); 90 - 91 - luke-hm-depends-on-osConfig = checkCond "standalone hm can depend on osConfig" ( 92 - luke.config.programs.bat.enable 93 - ); 94 - 95 - alice-hello-enabled-by-default = checkCond "added hello at user packages" ( 96 - let 97 - progs = rockhopper.config.users.users.alice.packages; 98 - expr = map lib.getName progs; 99 - expected = [ "hello" ]; 100 - in 101 - expr == expected 102 - ); 103 - 104 - rockhopper-names-single-entry = checkCond "custom nixos array option set once" ( 105 - rockhopper.config.names == [ "tux" ] 106 - ); 107 - 108 - }; 109 - 110 - checks.aarch64-darwin = { 111 - hosts-honeyscrisp = checkFile "darwin-builds" honeycrisp.config.system.build.toplevel; 112 - homes-bob = checkFile "darwin-home-builds" bob.activation-script; 113 - }; 114 - in 115 - { 116 - checks = checks.${pkgs.system} or { }; 117 - }; 118 - }
+27
templates/examples/modules/_example/ci/builds.nix
··· 1 + # Adds some checks for CI 2 + { 3 + perSystem = 4 + { 5 + pkgs, 6 + checkFile, 7 + rockhopper, 8 + honeycrisp, 9 + cam, 10 + bob, 11 + ... 12 + }: 13 + let 14 + checks.x86_64-linux = { 15 + vm = checkFile "vm-builds" "${rockhopper.config.system.build.vm}/bin/run-rockhopper-vm"; 16 + hosts-rockhopper = checkFile "nixos-builds" rockhopper.config.system.build.toplevel; 17 + homes-cam = checkFile "home-builds" cam.activation-script; 18 + }; 19 + checks.aarch64-darwin = { 20 + hosts-honeycrisp = checkFile "darwin-builds" honeycrisp.config.system.build.toplevel; 21 + homes-bob = checkFile "darwin-home-builds" bob.activation-script; 22 + }; 23 + in 24 + { 25 + checks = checks.${pkgs.system} or { }; 26 + }; 27 + }
+23
templates/examples/modules/_example/ci/custom-nixos-module.nix
··· 1 + { lib, ... }: 2 + let 3 + # A custom `nixos` class module that defines an option `names`. 4 + # Used to test that we are not duplicating values from owned configs. 5 + nixosNames.options.names = lib.mkOption { type = lib.types.listOf lib.types.str; }; 6 + in 7 + { 8 + 9 + den.aspects.rockhopper.includes = [ 10 + # Example: importing a third-party nixos module. 11 + { nixos.imports = [ nixosNames ]; } 12 + ]; 13 + 14 + den.aspects.rockhopper.nixos.names = [ "tux" ]; 15 + 16 + perSystem = 17 + { checkCond, rockhopper, ... }: 18 + { 19 + checks.rockhopper-names-single-entry = checkCond "custom nixos array option set once" ( 20 + rockhopper.config.names == [ "tux" ] 21 + ); 22 + }; 23 + }
+27
templates/examples/modules/_example/ci/define-user.nix
··· 1 + { den, ... }: 2 + { 3 + den.default.includes = [ 4 + # Example: parametric over many contexts: { home }, { host, user }, { fromUser, toHost } 5 + den.provides.define-user 6 + ]; 7 + 8 + perSystem = 9 + { 10 + checkCond, 11 + rockhopper, 12 + adelie, 13 + ... 14 + }: 15 + { 16 + 17 + checks.alice-exists-on-rockhopper = checkCond "den.default.user.includes defines user on host" ( 18 + rockhopper.config.users.users.alice.isNormalUser 19 + ); 20 + checks.alice-not-exists-on-adelie = checkCond "den.default.user.includes defines user on host" ( 21 + !adelie.config.users.users ? alice 22 + ); 23 + checks.will-exists-on-adelie = checkCond "den.default.user.includes defines user on host" ( 24 + adelie.config.users.users.will.isNormalUser 25 + ); 26 + }; 27 + }
+8
templates/examples/modules/_example/ci/enable-wsl-host.nix
··· 1 + { inputs, ... }: 2 + { 3 + # Example: adelie host using github:nix-community/NixOS-WSL 4 + den.aspects.adelie.nixos = { 5 + imports = [ inputs.nixos-wsl.nixosModules.default ]; 6 + wsl.enable = true; 7 + }; 8 + }
+37
templates/examples/modules/_example/ci/helpers.nix
··· 1 + { self, ... }: 2 + { 3 + perSystem = 4 + { pkgs, ... }: 5 + let 6 + checkFile = 7 + name: file: 8 + pkgs.runCommandLocal name { } '' 9 + ls -la ${file} | tee $out 10 + ''; 11 + 12 + checkCond = 13 + name: cond: 14 + let 15 + code = if cond then "touch $out" else ''echo "Cond-Failed: ${name}"''; 16 + in 17 + pkgs.runCommandLocal name { } code; 18 + 19 + rockhopper = self.nixosConfigurations.rockhopper; 20 + honeycrisp = self.darwinConfigurations.honeycrisp; 21 + adelie = self.wslConfigurations.adelie; 22 + cam = self.homeConfigurations.cam; 23 + bob = self.homeConfigurations.bob; 24 + luke = self.homeConfigurations.luke; 25 + 26 + alice-at-rockhopper = rockhopper.config.home-manager.users.alice; 27 + alice-at-honeycrisp = honeycrisp.config.home-manager.users.alice; 28 + in 29 + { 30 + _module.args = { 31 + inherit checkCond checkFile; 32 + inherit rockhopper honeycrisp adelie; 33 + inherit cam bob luke; 34 + inherit alice-at-rockhopper alice-at-honeycrisp; 35 + }; 36 + }; 37 + }
+13
templates/examples/modules/_example/ci/host-configures-users.nix
··· 1 + { 2 + 3 + # Example: host provides static config to all its users hm. 4 + den.aspects.rockhopper.homeManager.programs.direnv.enable = true; 5 + 6 + perSystem = 7 + { checkCond, alice-at-rockhopper, ... }: 8 + { 9 + checks.host-contributes-to-user = checkCond "rockhopper contributes to all its users" ( 10 + alice-at-rockhopper.programs.direnv.enable 11 + ); 12 + }; 13 + }
+45
templates/examples/modules/_example/ci/host-user-conditional-hm.nix
··· 1 + { den, lib, ... }: 2 + let 3 + # Example: configuration that depends on both host and user. provides only to HM. 4 + host-to-user-conditional = 5 + { 6 + HM, 7 + user, 8 + host, 9 + ... 10 + }: 11 + den.lib.take.unused [ HM ] ( 12 + if user.userName == "alice" && !lib.hasSuffix "darwin" host.system then 13 + { 14 + homeManager.programs.git.enable = true; 15 + } 16 + else 17 + { } 18 + ); 19 + in 20 + { 21 + 22 + den.aspects.rockhopper.includes = [ 23 + # Example: host provides parametric user configuration. 24 + host-to-user-conditional 25 + ]; 26 + 27 + perSystem = 28 + { 29 + checkCond, 30 + alice-at-rockhopper, 31 + alice-at-honeycrisp, 32 + ... 33 + }: 34 + { 35 + 36 + checks.alice-hm-git-enabled-on = checkCond "home-managed git for alice at rockhopper" ( 37 + alice-at-rockhopper.programs.git.enable 38 + ); 39 + checks.alice-hm-git-enabled-off = checkCond "home-managed git for alice at honeycrisp" ( 40 + !alice-at-honeycrisp.programs.git.enable 41 + ); 42 + 43 + }; 44 + 45 + }
+47
templates/examples/modules/_example/ci/one-os-package-per-user.nix
··· 1 + { den, ... }: 2 + let 3 + 4 + # Example: adds hello into each user. provides only to OS. 5 + hello-package-for-user = 6 + { 7 + OS, 8 + fromUser, 9 + user, 10 + host, 11 + ... 12 + }: 13 + den.lib.take.unused [ OS fromUser ] { 14 + ${host.class} = 15 + { pkgs, ... }: 16 + { 17 + users.users.${user.userName}.packages = [ pkgs.hello ]; 18 + }; 19 + }; 20 + 21 + in 22 + { 23 + 24 + den.default.includes = [ 25 + # Example: parametric { OS, fromUser } aspect. 26 + hello-package-for-user 27 + ]; 28 + 29 + perSystem = 30 + { 31 + checkCond, 32 + rockhopper, 33 + lib, 34 + ... 35 + }: 36 + { 37 + checks.alice-hello-enabled-by-default = checkCond "added hello at user packages" ( 38 + let 39 + progs = rockhopper.config.users.users.alice.packages; 40 + expr = map lib.getName progs; 41 + expected = [ "hello" ]; 42 + in 43 + expr == expected 44 + ); 45 + }; 46 + 47 + }
+29
templates/examples/modules/_example/ci/primary-user.nix
··· 1 + { den, ... }: 2 + { 3 + den.aspects.alice.includes = [ 4 + # alice is always admin in all its hosts 5 + den._.primary-user 6 + ]; 7 + 8 + den.aspects.will.includes = [ 9 + # will is primary user in WSL NixOS. 10 + den._.primary-user 11 + ]; 12 + 13 + perSystem = 14 + { 15 + checkCond, 16 + honeycrisp, 17 + adelie, 18 + ... 19 + }: 20 + { 21 + checks.alice-primary-on-macos = checkCond "den._.primary-user sets macos primary" ( 22 + honeycrisp.config.system.primaryUser == "alice" 23 + ); 24 + 25 + checks.will-is-wsl-default = checkCond "wsl.defaultUser defined" ( 26 + adelie.config.wsl.defaultUser == "will" 27 + ); 28 + }; 29 + }
+29
templates/examples/modules/_example/ci/set-hostname.nix
··· 1 + { 2 + den.default.includes = 3 + let 4 + # Example: parametric host aspect to automatically set hostName on any host. 5 + set-host-name = 6 + { host, ... }: 7 + { 8 + ${host.class}.networking.hostName = host.name; 9 + }; 10 + in 11 + [ set-host-name ]; 12 + 13 + perSystem = 14 + { 15 + checkCond, 16 + rockhopper, 17 + honeycrisp, 18 + ... 19 + }: 20 + { 21 + checks.rockhopper-hostname = checkCond "den.default.host.includes sets hostName" ( 22 + rockhopper.config.networking.hostName == "rockhopper" 23 + ); 24 + 25 + checks.honeycrisp-hostname = checkCond "den.default.host.includes sets hostName" ( 26 + honeycrisp.config.networking.hostName == "honeycrisp" 27 + ); 28 + }; 29 + }
+31
templates/examples/modules/_example/ci/standalone-hm-special-args-osconfig.nix
··· 1 + let 2 + 3 + # Example: luke standalone home-manager has access to rockhopper osConfig specialArg. 4 + os-conditional-hm = 5 + { home }: 6 + { 7 + # access osConfig, wired via extraSpecialArgs in homes.nix. 8 + homeManager = 9 + { osConfig, ... }: 10 + { 11 + programs.bat.enable = osConfig.programs.${home.programToDependOn}.enable; 12 + }; 13 + }; 14 + in 15 + { 16 + 17 + # Example: standalone-hm config depends on osConfig (non-recursive) 18 + # NOTE: this will only work for standalone hm, and not for hosted hm 19 + # since a hosted hm configuration cannot depend on the os configuration. 20 + den.aspects.luke.includes = [ 21 + os-conditional-hm 22 + ]; 23 + 24 + perSystem = 25 + { checkCond, luke, ... }: 26 + { 27 + checks.luke-hm-depends-on-osConfig = checkCond "standalone hm can depend on osConfig" ( 28 + luke.config.programs.bat.enable 29 + ); 30 + }; 31 + }
+6
templates/examples/modules/_example/ci/unfree.nix
··· 1 + { den, ... }: 2 + { 3 + # cam uses unfree vscode. 4 + den.aspects.cam.homeManager.programs.vscode.enable = true; 5 + den.aspects.cam.includes = [ (den._.unfree [ "vscode" ]) ]; 6 + }
+12
templates/examples/modules/_example/ci/user-configures-hosts.nix
··· 1 + { 2 + # Example: user provides static config to all its nixos hosts. 3 + den.aspects.alice.nixos.users.users.alice.description = "Alice Q. User"; 4 + 5 + perSystem = 6 + { checkCond, rockhopper, ... }: 7 + { 8 + checks.user-contributes-to-host = checkCond "alice.nixos sets on rockhopper host" ( 9 + rockhopper.config.users.users.alice.description == "Alice Q. User" 10 + ); 11 + }; 12 + }
+12
templates/examples/modules/_example/ci/user-home-defaults.nix
··· 1 + { 2 + # globally enable fish on all homes ever. 3 + den.default.homeManager.programs.fish.enable = true; 4 + 5 + perSystem = 6 + { checkCond, alice-at-rockhopper, ... }: 7 + { 8 + checks.alice-hm-fish-enabled-by-default = checkCond "home-managed fish for alice" ( 9 + alice-at-rockhopper.programs.fish.enable 10 + ); 11 + }; 12 + }
+38
templates/examples/modules/_example/ci/user-host-conditional-os.nix
··· 1 + { lib, ... }: 2 + let 3 + 4 + # Example: configuration that depends on both host and user. provides anytime { user, host } is in context. 5 + user-to-host-conditional = 6 + { user, host, ... }: 7 + if user.userName == "alice" && !lib.hasSuffix "darwin" host.system then 8 + { 9 + nixos.programs.tmux.enable = true; 10 + } 11 + else 12 + { }; 13 + in 14 + { 15 + 16 + # Example: user provides parametric host configuration. 17 + den.aspects.alice.includes = [ 18 + user-to-host-conditional 19 + ]; 20 + 21 + perSystem = 22 + { 23 + checkCond, 24 + rockhopper, 25 + honeycrisp, 26 + ... 27 + }: 28 + { 29 + checks.alice-os-tmux-enabled-on = checkCond "os tmux for hosts having alice" ( 30 + rockhopper.config.programs.tmux.enable 31 + ); 32 + checks.alice-os-tmux-enabled-off = checkCond "os tmux for hosts having alice" ( 33 + !honeycrisp.config.programs.tmux.enable 34 + ); 35 + 36 + }; 37 + 38 + }
+17
templates/examples/modules/_example/ci/user-shell.nix
··· 1 + { den, lib, ... }: 2 + { 3 + 4 + den.aspects.will.includes = [ 5 + # will has always loved red snappers 6 + (den._.user-shell "fish") 7 + ]; 8 + 9 + perSystem = 10 + { checkCond, adelie, ... }: 11 + { 12 + checks.will-always-love-you = checkCond "red-snapper fish is default shell" ( 13 + "fish" == lib.getName adelie.config.users.users.will.shell 14 + ); 15 + }; 16 + 17 + }
+13
templates/examples/modules/_example/ci/user-specific-hm-config.nix
··· 1 + { 2 + # Example: enable helix for alice on all its home-managed hosts. 3 + den.aspects.alice.homeManager.programs.helix.enable = true; 4 + 5 + perSystem = 6 + { checkCond, alice-at-rockhopper, ... }: 7 + { 8 + checks.alice-hm-helix-enabled-by-user = checkCond "home-managed helix for alice" ( 9 + alice-at-rockhopper.programs.helix.enable 10 + ); 11 + }; 12 + 13 + }
+16
templates/examples/modules/_example/ci/vm-bootable.nix
··· 1 + let 2 + # Example: A static aspect for vm installers. 3 + vm-bootable = { 4 + nixos = 5 + { modulesPath, ... }: 6 + { 7 + imports = [ (modulesPath + "/installer/cd-dvd/installation-cd-minimal.nix") ]; 8 + }; 9 + }; 10 + in 11 + { 12 + den.default.includes = [ 13 + # Example: static aspect 14 + vm-bootable 15 + ]; 16 + }
-1
templates/examples/modules/_example/defaults.nix
··· 10 10 # these defaults are set for checking with CI. 11 11 nixos.programs.vim.enable = true; 12 12 darwin.programs.zsh.enable = true; 13 - homeManager.programs.fish.enable = true; 14 13 }; 15 14 }
+7
templates/examples/modules/_example/home-managed.nix
··· 2 2 { 3 3 # see batteries/home-manager.nix 4 4 den.default.includes = [ den._.home-manager ]; 5 + 6 + # enable home-manager dependency. 7 + flake-file.inputs.home-manager = { 8 + url = "github:nix-community/home-manager"; 9 + inputs.nixpkgs.follows = "nixpkgs"; 10 + }; 11 + 5 12 }
-7
templates/examples/modules/_example/homes.nix
··· 28 28 programToDependOn = "vim"; 29 29 }; 30 30 31 - # move these inputs to any module you want. 32 - # they are here for all our examples to work on CI. 33 - flake-file.inputs.home-manager = { 34 - url = "github:nix-community/home-manager"; 35 - inputs.nixpkgs.follows = "nixpkgs"; 36 - }; 37 - 38 31 }
+8
templates/examples/modules/_example/import-non-dendritic.nix templates/examples/modules/_example/ci/import-tree.nix
··· 17 17 (<den/import-tree/home> ./_non_dendritic/homes) 18 18 ]; 19 19 20 + # tests 21 + perSystem = 22 + { checkCond, rockhopper, ... }: 23 + { 24 + checks.import-tree = checkCond "auto-imported from rockhopper/_nixos" ( 25 + rockhopper.config.auto-imported 26 + ); 27 + }; 20 28 }
-13
templates/examples/modules/_example/vm.nix
··· 1 - { inputs, ... }: 2 - { 3 - perSystem = 4 - { pkgs, ... }: 5 - { 6 - packages.vm = pkgs.writeShellApplication { 7 - name = "vm"; 8 - text = '' 9 - ${inputs.self.nixosConfigurations.rockhopper.config.system.build.vm}/bin/run-rockhopper-vm "$@" 10 - ''; 11 - }; 12 - }; 13 - }