this repo has no description
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge #276

276: Update core r=blaggacao a=Pacman99

Core is starting to get pretty stale. All the changes in `develop` are pretty stable and I think we should encourage updating to them. As most future updates can be done through [devlib](https://github.com/divnix/devlib), so once you switch to this version of the template. Updating to new changes will be much simpler (ie #91).

Co-authored-by: Pacman99 <pachum99@gmail.com>
Co-authored-by: Pacman99 <pachum99@myrdd.info>
Co-authored-by: David Arnold <dar@xoe.solutions>

authored by

bors[bot]
Pacman99
Pacman99
David Arnold
and committed by
GitHub
4df3d8c2 82b73cf6

+821 -1362
+22 -25
doc/concepts/extern.md
··· 1 1 # External Art 2 2 When you need to use a module, overlay, or pass a value from one of your inputs 3 - to the rest of your NixOS configuration, [extern][extern] is where you do it. 4 - 5 - Modules and overlays are self explanatory, and the `specialArgs` attribute is 6 - used to extend the arguments passed to all NixOS modules, allowing for 7 - arbitrary values to be passed from flake inputs to the rest of your 8 - configuration. 3 + to the rest of your NixOS configuration, you can make use of a couple arguments. 4 + It is encouraged to add external art directly in your `flake.nix` so the file 5 + represents a complete dependency overview of your flake. 9 6 10 - ## Home Manager 11 - There is also an `hmModules` attribute set for pulling home-manager modules in 12 - from the outside world: 7 + ## Overlays 8 + External overlays can directly be added to a channel's `overlays` list. 13 9 14 - ### Declare: 15 10 flake.nix: 16 11 ```nix 17 12 { 18 - inputs.doom-emacs.url = "github:vlaci/nix-doom-emacs"; 13 + channels.nixos.overlays = [ inputs.agenix.overlay ]; 19 14 } 20 15 ``` 16 + Upon exporting overlays, these overlays will be automatically filtered out by inspecting the `inputs` argument. 21 17 22 - extern/default.nix: 18 + ## Modules 19 + There is a dedicated `nixos.hostDefaults.externalModules` argument for external 20 + modules. 21 + 22 + flake.nix: 23 23 ```nix 24 - with inputs; 25 24 { 26 - hmModules = { 27 - doom-emacs = doom-emacs.hmModule; 28 - }; 25 + nixos.hostDefaults.externalModules = [ inputs.agenix.nixosModules.age ]; 29 26 } 30 27 ``` 31 28 32 - ### Use: 33 - users/nixos/default.nix: 29 + ## Home Manager 30 + Since there isn't a `hosts` concept for home-manager, externalModules is just a 31 + top-level argument in the `home` namespace. 32 + 33 + flake.nix: 34 34 ```nix 35 - { hmModules, ... }: 36 35 { 37 - home-manager.users.nixos = { 38 - imports = [ hmModules.doom-emacs ] ; 39 - 40 - programs.doom-emacs.enable = true; 41 - }; 36 + home.externalModules = [ doom-emacs = doom-emacs.hmModule ]; 42 37 } 43 38 ``` 44 39 45 - [extern]: https://github.com/divnix/devos/tree/core/extern/default.nix 40 + > ##### Note: 41 + > To avoid declaring "external" modules separately, which is obvious since they come from `inputs`, the optimal solution would be to automatically export modules that were created in 42 + > your flake. But this is not possible due to NixOS/nix#4740.
+22 -8
doc/concepts/hosts.md
··· 15 15 convenience, since `nixos-rebuild` automatically searches for a configuration 16 16 matching the current systems hostname if one is not specified explicitly. 17 17 18 + You can set channels, systems, and add extra modules to each host by editing the 19 + `nixos.hosts` argument in flake.nix. This is the perfect place to import 20 + host specific modules from external sources, such as the 21 + [nixos-hardware][nixos-hardware] repository. 22 + 18 23 It is recommended that the host modules only contain configuration information 19 24 specific to a particular piece of hardware. Anything reusable across machines 20 25 is best saved for [profile modules](./profiles.md). ··· 22 27 This is a good place to import sets of profiles, called [suites](./suites.md), 23 28 that you intend to use on your machine. 24 29 25 - Additionally, this is the perfect place to import anything you might need from 26 - the [nixos-hardware][nixos-hardware] repository. 27 - 28 - > ##### _Note:_ 29 - > Set `nixpkgs.system` to the architecture of this host, default is "x86_64-linux". 30 - > Keep in mind that not all packages are available for all architectures. 31 30 32 31 ## Example 33 32 33 + flake.nix: 34 + ```nix 35 + { 36 + nixos.hosts = mkMerge [ 37 + (devos.lib.importHosts ./hosts) 38 + { 39 + librem = { 40 + channelName = "latest"; 41 + modules = [ hardware.purism-librem-13v3 ]; 42 + }; 43 + } 44 + ]; 45 + } 46 + ``` 47 + 34 48 hosts/librem.nix: 35 49 ```nix 36 - { suites, hardware, ... }: 50 + { suites, ... }: 37 51 { 38 - imports = suites.laptop ++ [ hardware.purism-librem-13v3 ]; 52 + imports = suites.laptop; 39 53 40 54 boot.loader.systemd-boot.enable = true; 41 55 boot.loader.efi.canTouchEfiVariables = true;
+24 -30
doc/concepts/overrides.md
··· 1 1 # Overrides 2 - By default, the NixOS systems are based on unstable. While it is trivial to 3 - change this to a stable release, or any other branch of nixpkgs by 4 - changing the flake url, sometimes all we want is a single package from another 5 - branch. 2 + Each NixOS host follows one channel. But many times it is useful to get packages 3 + or modules from different channels. 6 4 7 - This is what the overrides are for. By default, they are pulled directly from 8 - nixpkgs/master, but you can change the `override` flake input url to 9 - nixos-unstable, or even a specific sha revision. 5 + ## Packages 6 + You can make use of `overlays/overrides.nix` to override specific packages in the 7 + default channel to be pulled from other channels. That file is simply an example 8 + of how any overlay can get `channels` as their first argument. 10 9 11 - They are defined in the `extern/overrides.nix` file. 10 + You can add overlays to any channel to override packages from other channels. 12 11 13 - ## Example 14 - 15 - ### Packages 16 - The override packages are defined as a regular overlay with an extra arguement 17 - `pkgs`. This refers to the packages built from the `override` flake. 18 - 19 - Pulling the manix package from the override flake: 12 + Pulling the manix package from the `latest` channel: 20 13 ```nix 21 - { 22 - packages = pkgs: final: prev: { 23 - inherit (pkgs) manix; 24 - }; 14 + channels: final: prev: { 15 + __dontExport = true; 16 + inherit (pkgs.latest) manix; 25 17 } 26 18 ``` 27 19 28 - ### Modules 20 + It is recommended to set the `__dontExport` property for override specific 21 + overlays. `overlays/overrides.nix` is the best place to consolidate all package 22 + overrides and the property is already set for you. 29 23 30 - You can also pull modules from override. Simply specify their path relative to 31 - the nixpkgs [modules][nixpkgs-modules] directory. The old version will be added 32 - to `disabledModules` and the new version imported into the configuration. 24 + ## Modules 25 + 26 + You can also pull modules from other channels. All modules have access to the 27 + `modulesPath` for each channel as `<channelName>ModulesPath`. And you can use 28 + `disabledModules` to remove modules from the current channel. 33 29 34 - Pulling the zsh module from the override flake: 30 + Pulling the zsh module from the `latest` channel: 35 31 ```nix 36 - { 37 - modules = [ "programs/zsh/zsh.nix" ]; 32 + { latestModulesPath }: { 33 + modules = [ "${latestModulesPath}/programs/zsh/zsh.nix" ]; 34 + disabledModules = [ "programs/zsh/zsh.nix" ]; 38 35 } 39 36 ``` 40 37 41 38 > ##### _Note:_ 42 - > Sometimes a modules name will change from one branch to another. This is what 43 - > the `disabledModules` list is for. If the module name changes, the old 44 - > version will not automatically be disabled, so simply put it's old name in 45 - > this list to disable it. 39 + > Sometimes a modules name will change from one branch to another. 46 40 47 41 [nixpkgs-modules]: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules
+7 -1
doc/concepts/suites.md
··· 6 6 In the future, we will use suites as a mechanism for deploying various machine 7 7 types which don't depend on hardware, such as vm's and containers. 8 8 9 - They are defined in `profiles/suites.nix`. 9 + They are defined with the `suites` argument in either `home` or `nixos` namespace. 10 + Suites should be passed as a function that take profiles as an argument. 11 + 12 + The profiles are passed based on the folder names and list passed to the relevant 13 + `profiles` argument. In the template's flake.nix `profiles` is set as 14 + `[ ./profiles ./users ]` and that corresponds to the `{ profiles, users }` argument 15 + pattern. 10 16 11 17 ## Definition 12 18 ```nix
+1 -2
doc/lib.md
··· 3 3 [`nixpkgs:./nixos/lib`][nixpkgs-nixos-lib] and [`nixpkgs:./pkgs/pkgs-lib`][nixpkgs-pkgs-lib], 4 4 but also occasionally [`nixpkgs:./pkgs/build-support`][nixpkgs-pkgs-build-support]. 5 5 6 - It comes with functions necesary to declutter `devos` itself, but you are 7 - welcome to extend it to your needs. 6 + All functions defined in lib can be accessed in modules and packages as `ourlib`. 8 7 9 8 For example: 10 9
+407
doc/mkFlakeOptions.md
··· 1 + ## channels 2 + nixpkgs channels to create 3 + 4 + 5 + *_Type_*: 6 + attribute set of submodules 7 + 8 + 9 + *_Default_* 10 + ``` 11 + {} 12 + ``` 13 + 14 + 15 + 16 + 17 + ## channels.\<name\>.config 18 + nixpkgs config for this channel 19 + 20 + 21 + *_Type_*: 22 + attribute set or path convertible to it 23 + 24 + 25 + *_Default_* 26 + ``` 27 + {} 28 + ``` 29 + 30 + 31 + 32 + 33 + ## channels.\<name\>.input 34 + nixpkgs flake input to use for this channel 35 + 36 + 37 + *_Type_*: 38 + nix flake 39 + 40 + 41 + *_Default_* 42 + ``` 43 + "inputs.<name>" 44 + ``` 45 + 46 + 47 + 48 + 49 + ## channels.\<name\>.overlays 50 + overlays to apply to this channel 51 + these will get exported under the 'overlays' flake output 52 + as \<channel\>/\<name\> and any overlay pulled from ${inputs} 53 + will be filtered out 54 + 55 + 56 + *_Type_*: 57 + list of valid Nixpkgs overlay or path convertible to its or anything convertible to it 58 + 59 + 60 + *_Default_* 61 + ``` 62 + [] 63 + ``` 64 + 65 + 66 + 67 + 68 + ## channelsConfig 69 + nixpkgs config for all channels 70 + 71 + 72 + *_Type_*: 73 + attribute set or path convertible to it 74 + 75 + 76 + *_Default_* 77 + ``` 78 + {} 79 + ``` 80 + 81 + 82 + 83 + 84 + ## home 85 + hosts, modules, suites, and profiles for home-manager 86 + 87 + 88 + *_Type_*: 89 + submodule 90 + 91 + 92 + *_Default_* 93 + ``` 94 + {} 95 + ``` 96 + 97 + 98 + 99 + 100 + ## home.externalModules 101 + modules to include that won't be exported 102 + meant importing modules from external flakes 103 + 104 + 105 + *_Type_*: 106 + list of valid module or path convertible to its 107 + 108 + 109 + *_Default_* 110 + ``` 111 + [] 112 + ``` 113 + 114 + 115 + 116 + 117 + ## home.modules 118 + modules to include in all hosts and export to homeModules output 119 + 120 + 121 + *_Type_*: 122 + list of path to a modules or anything convertible to it or path convertible to it 123 + 124 + 125 + *_Default_* 126 + ``` 127 + [] 128 + ``` 129 + 130 + 131 + 132 + 133 + ## home.profiles 134 + profile folders that can be collected into suites 135 + the name of the argument passed to suites is based 136 + on the folder name. 137 + [ ./profiles ] => { profiles }: 138 + 139 + 140 + *_Type_*: 141 + list of paths 142 + 143 + 144 + *_Default_* 145 + ``` 146 + [] 147 + ``` 148 + 149 + 150 + 151 + 152 + ## home.suites 153 + Function that takes profiles and returns suites for this config system 154 + These can be accessed through the 'suites' special argument. 155 + 156 + 157 + *_Type_*: 158 + function that evaluates to a(n) attrs or path convertible to it 159 + 160 + 161 + *_Default_* 162 + ``` 163 + "<function>" 164 + ``` 165 + 166 + 167 + 168 + 169 + ## inputs 170 + inputs for this flake 171 + used to set channel defaults and create registry 172 + 173 + 174 + *_Type_*: 175 + attribute set of nix flakes 176 + 177 + 178 + 179 + 180 + 181 + 182 + ## nixos 183 + hosts, modules, suites, and profiles for nixos 184 + 185 + 186 + *_Type_*: 187 + submodule 188 + 189 + 190 + *_Default_* 191 + ``` 192 + {} 193 + ``` 194 + 195 + 196 + 197 + 198 + ## nixos.hostDefaults 199 + Defaults for all hosts. 200 + the modules passed under hostDefaults will be exported 201 + to the 'nixosModules' flake output. 202 + They will also be added to all hosts. 203 + 204 + 205 + *_Type_*: 206 + submodule 207 + 208 + 209 + *_Default_* 210 + ``` 211 + {} 212 + ``` 213 + 214 + 215 + 216 + 217 + ## nixos.hostDefaults.channelName 218 + Channel this host should follow 219 + 220 + 221 + *_Type_*: 222 + a channel defined in `channels` 223 + 224 + 225 + *_Default_* 226 + ``` 227 + null 228 + ``` 229 + 230 + 231 + 232 + 233 + ## nixos.hostDefaults.externalModules 234 + modules to include that won't be exported 235 + meant importing modules from external flakes 236 + 237 + 238 + *_Type_*: 239 + list of valid module or path convertible to its 240 + 241 + 242 + *_Default_* 243 + ``` 244 + [] 245 + ``` 246 + 247 + 248 + 249 + 250 + ## nixos.hostDefaults.modules 251 + modules to include in all hosts and export to nixosModules output 252 + 253 + 254 + *_Type_*: 255 + list of path to a modules or anything convertible to it or path convertible to it 256 + 257 + 258 + *_Default_* 259 + ``` 260 + [] 261 + ``` 262 + 263 + 264 + 265 + 266 + ## nixos.hostDefaults.system 267 + system for this host 268 + 269 + 270 + *_Type_*: 271 + system defined in `supportedSystems` 272 + 273 + 274 + *_Default_* 275 + ``` 276 + null 277 + ``` 278 + 279 + 280 + 281 + 282 + ## nixos.hosts 283 + configurations to include in the nixosConfigurations output 284 + 285 + 286 + *_Type_*: 287 + attribute set of submodules 288 + 289 + 290 + *_Default_* 291 + ``` 292 + {} 293 + ``` 294 + 295 + 296 + 297 + 298 + ## nixos.hosts.\<name\>.channelName 299 + Channel this host should follow 300 + 301 + 302 + *_Type_*: 303 + a channel defined in `channels` 304 + 305 + 306 + *_Default_* 307 + ``` 308 + null 309 + ``` 310 + 311 + 312 + 313 + 314 + ## nixos.hosts.\<name\>.modules 315 + modules to include 316 + 317 + 318 + *_Type_*: 319 + list of valid module or path convertible to its or anything convertible to it 320 + 321 + 322 + *_Default_* 323 + ``` 324 + [] 325 + ``` 326 + 327 + 328 + 329 + 330 + ## nixos.hosts.\<name\>.system 331 + system for this host 332 + 333 + 334 + *_Type_*: 335 + system defined in `supportedSystems` 336 + 337 + 338 + *_Default_* 339 + ``` 340 + null 341 + ``` 342 + 343 + 344 + 345 + 346 + ## nixos.profiles 347 + profile folders that can be collected into suites 348 + the name of the argument passed to suites is based 349 + on the folder name. 350 + [ ./profiles ] => { profiles }: 351 + 352 + 353 + *_Type_*: 354 + list of paths 355 + 356 + 357 + *_Default_* 358 + ``` 359 + [] 360 + ``` 361 + 362 + 363 + 364 + 365 + ## nixos.suites 366 + Function that takes profiles and returns suites for this config system 367 + These can be accessed through the 'suites' special argument. 368 + 369 + 370 + *_Type_*: 371 + function that evaluates to a(n) attrs or path convertible to it 372 + 373 + 374 + *_Default_* 375 + ``` 376 + "<function>" 377 + ``` 378 + 379 + 380 + 381 + 382 + ## self 383 + The flake to create the devos outputs for 384 + 385 + *_Type_*: 386 + nix flake 387 + 388 + 389 + 390 + 391 + 392 + 393 + ## supportedSystems 394 + The systems supported by this flake 395 + 396 + 397 + *_Type_*: 398 + list of strings 399 + 400 + 401 + *_Default_* 402 + ``` 403 + ["aarch64-linux","i686-linux","x86_64-darwin","x86_64-linux"] 404 + ``` 405 + 406 + 407 +
+1 -1
doc/outputs/overlays.md
··· 4 4 5 5 Any _.nix_ files declared in this directory will be assumed to be a valid 6 6 overlay, and will be automatically imported into all [hosts](../concepts/hosts.md), and 7 - exported via `overlays.<file-basename>` _as well as_ 7 + exported via `overlays.<channel>/<pkgName>` _as well as_ 8 8 `packages.<system>.<pkgName>` (for valid systems), so all you have to do is 9 9 write it. 10 10
+11 -4
doc/start/from-nixos.md
··· 10 10 This will make a new file `hosts/up-$(hostname).nix`, which you can edit to 11 11 your liking. 12 12 13 + You must then add a host to `nixos.hosts` in flake.nix: 14 + ```nix 15 + { 16 + nixos.hosts = { 17 + modules = hosts/NixOS.nix; 18 + }; 19 + } 20 + ``` 21 + 13 22 Make sure your `i18n.defaultLocale` and `time.timeZone` are set properly for 14 - your region. Keep in mind that `networking.hostName` with be automatically 15 - set to the filename of your hosts file, so `hosts/my-host.nix` will have the 16 - hostname `my-host`. 23 + your region. Keep in mind that `networking.hostName` will be automatically 24 + set to the name of your host; 17 25 18 26 Now might be a good time to read the docs on [suites](../concepts/suites.md) and 19 27 [profiles](../concepts/profiles.md) and add or create any that you need. ··· 44 52 > simply `sudo nixos-rebuild switch` from anywhere on the system, but it is 45 53 > not required. 46 54 47 -
+1 -1
doc/tests.md
··· 7 7 8 8 ## Lib Tests 9 9 You can easily write tests for your own library functions in the 10 - ___tests/lib.nix___ file and they will be run on every `nix flake check` or 10 + lib/___tests/lib.nix___ file and they will be run on every `nix flake check` or 11 11 during a CI run. 12 12 13 13 ## Unit Tests
-29
extern/default.nix
··· 1 - { inputs }: with inputs; 2 - { 3 - modules = [ 4 - home.nixosModules.home-manager 5 - ci-agent.nixosModules.agent-profile 6 - ]; 7 - 8 - overlays = [ 9 - nur.overlay 10 - devshell.overlay 11 - (final: prev: { 12 - deploy-rs = deploy.packages.${prev.system}.deploy-rs; 13 - }) 14 - pkgs.overlay 15 - ]; 16 - 17 - # passed to all nixos modules 18 - specialArgs = { 19 - overrideModulesPath = "${override}/nixos/modules"; 20 - hardware = nixos-hardware.nixosModules; 21 - }; 22 - 23 - # added to home-manager 24 - userModules = [ 25 - ]; 26 - 27 - # passed to all home-manager modules 28 - userSpecialArgs = { }; 29 - }
-33
extern/overrides.nix
··· 1 - # override defaults to nixpkgs/master 2 - { 3 - # modules to pull from override, stable version is automatically disabled 4 - modules = [ ]; 5 - 6 - # if a modules name changed in override, add the old name here 7 - disabledModules = [ ]; 8 - 9 - # packages pulled from override 10 - packages = pkgs: final: prev: { 11 - inherit (pkgs) 12 - cachix 13 - dhall 14 - discord 15 - element-desktop 16 - manix 17 - nixpkgs-fmt 18 - qutebrowser 19 - signal-desktop 20 - starship; 21 - 22 - haskellPackages = prev.haskellPackages.override { 23 - overrides = hfinal: hprev: 24 - let version = prev.lib.replaceChars [ "." ] [ "" ] prev.ghc.version; 25 - in 26 - { 27 - # same for haskell packages, matching ghc versions 28 - inherit (pkgs.haskell.packages."ghc${version}") 29 - haskell-language-server; 30 - }; 31 - }; 32 - }; 33 - }
+185 -60
flake.lock
··· 2 2 "nodes": { 3 3 "ci-agent": { 4 4 "inputs": { 5 - "flake-compat": [ 6 - "flake-compat" 7 - ], 5 + "flake-compat": "flake-compat", 8 6 "nix-darwin": [ 9 7 "darwin" 10 8 ], ··· 12 10 "nixos" 13 11 ], 14 12 "nixos-unstable": [ 15 - "override" 13 + "latest" 16 14 ], 17 15 "pre-commit-hooks-nix": "pre-commit-hooks-nix" 18 16 }, 19 17 "locked": { 20 - "lastModified": 1615131736, 21 - "narHash": "sha256-z4Er9Cj3WpBDO/saLxqb7IypEvVP0/1AnO6rY5NB03Y=", 18 + "lastModified": 1619088868, 19 + "narHash": "sha256-l9db+HpNIkY41MonGE8z4pbkjBa5BdzJTG5AxV7V7Lw=", 22 20 "owner": "hercules-ci", 23 21 "repo": "hercules-ci-agent", 24 - "rev": "a1513a51e8efb96e990a562e6e724e17f2789978", 22 + "rev": "08f953a263518a3af0ca28cd887020ff3465bdf5", 25 23 "type": "github" 26 24 }, 27 25 "original": { ··· 33 31 "darwin": { 34 32 "inputs": { 35 33 "nixpkgs": [ 36 - "override" 34 + "latest" 37 35 ] 38 36 }, 39 37 "locked": { ··· 52 50 }, 53 51 "deploy": { 54 52 "inputs": { 55 - "flake-compat": [ 56 - "flake-compat" 57 - ], 58 - "naersk": [ 59 - "naersk" 60 - ], 61 - "nixpkgs": [ 62 - "override" 63 - ], 64 - "utils": [ 65 - "utils" 66 - ] 53 + "flake-compat": "flake-compat_2", 54 + "naersk": "naersk", 55 + "nixpkgs": "nixpkgs", 56 + "utils": "utils" 67 57 }, 68 58 "locked": { 69 - "lastModified": 1614654775, 70 - "narHash": "sha256-3mLxoxIXSWUuKE8YgIuqM5AZzXFd1aWxkTlplEDeXIA=", 59 + "lastModified": 1616406726, 60 + "narHash": "sha256-n9zmgxR03QNrvs9/fHewqE0j3SjL7Y+cglBCFu3U3rg=", 71 61 "owner": "serokell", 72 62 "repo": "deploy-rs", 73 - "rev": "6278b9bef5ad624676a565980417cbbef42d5227", 63 + "rev": "9e405fbc5ab5bacbd271fd78c6b6b6877c4d9f8d", 74 64 "type": "github" 75 65 }, 76 66 "original": { ··· 81 71 }, 82 72 "devshell": { 83 73 "locked": { 84 - "lastModified": 1613641255, 85 - "narHash": "sha256-iSvjFK4WYAKhuXCCtkY7uy/cFQTzS3D3Ml5WZqjEfL0=", 74 + "lastModified": 1618523768, 75 + "narHash": "sha256-Gev9da35pHUey3kGz/zrJFc/9ICs++vPCho7qB1mqd8=", 86 76 "owner": "numtide", 87 77 "repo": "devshell", 88 - "rev": "ff6cffba08600f5b7b43f398fcb58bef023bc4c4", 78 + "rev": "709fe4d04a9101c9d224ad83f73416dce71baf21", 89 79 "type": "github" 90 80 }, 91 81 "original": { ··· 94 84 "type": "github" 95 85 } 96 86 }, 87 + "digga": { 88 + "inputs": { 89 + "deploy": "deploy", 90 + "devshell": "devshell", 91 + "nixlib": "nixlib", 92 + "nixpkgs": "nixpkgs_2", 93 + "utils": "utils_2" 94 + }, 95 + "locked": { 96 + "lastModified": 1621027569, 97 + "narHash": "sha256-ugwMMfZagrWnt6yw+k1YGbydoMQ0OTYJ3WJ1kncsKCg=", 98 + "owner": "divnix", 99 + "repo": "digga", 100 + "rev": "c162f5f46206346f431f3905642a8a9f17d42217", 101 + "type": "github" 102 + }, 103 + "original": { 104 + "owner": "divnix", 105 + "repo": "digga", 106 + "type": "github" 107 + } 108 + }, 97 109 "flake-compat": { 98 110 "flake": false, 99 111 "locked": { 100 - "lastModified": 1611461076, 101 - "narHash": "sha256-ad++dTtMNeitUIKi1c66aTrVJOSf+mdZTrGrXzjDr6Q=", 102 - "owner": "BBBSnowball", 112 + "lastModified": 1606424373, 113 + "narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=", 114 + "owner": "edolstra", 115 + "repo": "flake-compat", 116 + "rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf", 117 + "type": "github" 118 + }, 119 + "original": { 120 + "owner": "edolstra", 121 + "repo": "flake-compat", 122 + "type": "github" 123 + } 124 + }, 125 + "flake-compat_2": { 126 + "flake": false, 127 + "locked": { 128 + "lastModified": 1606424373, 129 + "narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=", 130 + "owner": "edolstra", 103 131 "repo": "flake-compat", 104 - "rev": "a565cb46bee9fa856a6c15bc9c3bb947fbb784ec", 132 + "rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf", 105 133 "type": "github" 106 134 }, 107 135 "original": { 108 - "owner": "BBBSnowball", 109 - "ref": "pr-1", 136 + "owner": "edolstra", 110 137 "repo": "flake-compat", 111 138 "type": "github" 112 139 } 113 140 }, 141 + "flake-utils": { 142 + "locked": { 143 + "lastModified": 1620759905, 144 + "narHash": "sha256-WiyWawrgmyN0EdmiHyG2V+fqReiVi8bM9cRdMaKQOFg=", 145 + "owner": "numtide", 146 + "repo": "flake-utils", 147 + "rev": "b543720b25df6ffdfcf9227afafc5b8c1fabfae8", 148 + "type": "github" 149 + }, 150 + "original": { 151 + "owner": "numtide", 152 + "repo": "flake-utils", 153 + "type": "github" 154 + } 155 + }, 114 156 "home": { 115 157 "inputs": { 116 158 "nixpkgs": [ ··· 131 173 "type": "github" 132 174 } 133 175 }, 176 + "latest": { 177 + "locked": { 178 + "lastModified": 1619400530, 179 + "narHash": "sha256-7ZO7B+b9i1wFbHw62EFT+iwuBBpXeA/fcHlR63Z4J0w=", 180 + "owner": "NixOS", 181 + "repo": "nixpkgs", 182 + "rev": "e8dc8adab655eb27957859c62bef11484b53f639", 183 + "type": "github" 184 + }, 185 + "original": { 186 + "id": "nixpkgs", 187 + "type": "indirect" 188 + } 189 + }, 134 190 "naersk": { 135 191 "inputs": { 136 192 "nixpkgs": [ 137 - "override" 193 + "latest" 194 + ] 195 + }, 196 + "locked": { 197 + "lastModified": 1610392286, 198 + "narHash": "sha256-3wFl5y+4YZO4SgRYK8WE7JIS3p0sxbgrGaQ6RMw+d98=", 199 + "owner": "nmattia", 200 + "repo": "naersk", 201 + "rev": "d7bfbad3304fd768c0f93a4c3b50976275e6d4be", 202 + "type": "github" 203 + }, 204 + "original": { 205 + "owner": "nmattia", 206 + "ref": "master", 207 + "repo": "naersk", 208 + "type": "github" 209 + } 210 + }, 211 + "naersk_2": { 212 + "inputs": { 213 + "nixpkgs": [ 214 + "latest" 138 215 ] 139 216 }, 140 217 "locked": { ··· 151 228 "type": "github" 152 229 } 153 230 }, 231 + "nixlib": { 232 + "locked": { 233 + "lastModified": 1620519687, 234 + "narHash": "sha256-+6Dd72b2CASuXm2W7KRxZIE7AOy/dj4mU28vaF+zxcs=", 235 + "owner": "divnix", 236 + "repo": "nixpkgs.lib", 237 + "rev": "c7b6169809c5f74dd0c34f3d69e9d12ba4d448de", 238 + "type": "github" 239 + }, 240 + "original": { 241 + "owner": "divnix", 242 + "repo": "nixpkgs.lib", 243 + "type": "github" 244 + } 245 + }, 154 246 "nixos": { 155 247 "locked": { 156 248 "lastModified": 1615797423, ··· 181 273 "type": "github" 182 274 } 183 275 }, 184 - "nur": { 276 + "nixpkgs": { 185 277 "locked": { 186 - "lastModified": 1615921934, 187 - "narHash": "sha256-nURGM869KKA1+c1SHHsXKYcPXhHIuxWBjNXjJ90OzRQ=", 188 - "owner": "nix-community", 189 - "repo": "NUR", 190 - "rev": "faf862e8cf009edfa38ecc61188f7a6ace293552", 278 + "lastModified": 1610942247, 279 + "narHash": "sha256-PKo1ATAlC6BmfYSRmX0TVmNoFbrec+A5OKcabGEu2yU=", 280 + "owner": "NixOS", 281 + "repo": "nixpkgs", 282 + "rev": "7d71001b796340b219d1bfa8552c81995017544a", 191 283 "type": "github" 192 284 }, 193 285 "original": { 194 - "id": "nur", 195 - "type": "indirect" 286 + "owner": "NixOS", 287 + "ref": "nixpkgs-unstable", 288 + "repo": "nixpkgs", 289 + "type": "github" 196 290 } 197 291 }, 198 - "override": { 292 + "nixpkgs_2": { 199 293 "locked": { 200 - "lastModified": 1615926763, 201 - "narHash": "sha256-yeq8A3EPNuQVlsxlEQrIRsklfJwJK0Us6jtcG/u8wNs=", 202 - "owner": "NixOS", 294 + "lastModified": 1620962350, 295 + "narHash": "sha256-9ASW4d4/Z8HmRvuJI8rxbEOTbXTBpQ8y+CmFYBwtXzE=", 296 + "owner": "nixos", 203 297 "repo": "nixpkgs", 204 - "rev": "b702a56d417647de4090ac56c0f18bdc7e646610", 298 + "rev": "5d4a430472cafada97888cc80672fab255231f57", 299 + "type": "github" 300 + }, 301 + "original": { 302 + "owner": "nixos", 303 + "repo": "nixpkgs", 304 + "type": "github" 305 + } 306 + }, 307 + "nur": { 308 + "locked": { 309 + "lastModified": 1615921934, 310 + "narHash": "sha256-nURGM869KKA1+c1SHHsXKYcPXhHIuxWBjNXjJ90OzRQ=", 311 + "owner": "nix-community", 312 + "repo": "NUR", 313 + "rev": "faf862e8cf009edfa38ecc61188f7a6ace293552", 205 314 "type": "github" 206 315 }, 207 316 "original": { 208 - "id": "nixpkgs", 317 + "id": "nur", 209 318 "type": "indirect" 210 319 } 211 320 }, ··· 228 337 "pre-commit-hooks-nix": { 229 338 "flake": false, 230 339 "locked": { 231 - "lastModified": 1603721622, 232 - "narHash": "sha256-tUgyf5eYK5+0A/dvLzbbm4W7icxbpORuFMXiFe5yz+I=", 340 + "lastModified": 1617783930, 341 + "narHash": "sha256-SigoU2LWM1fMggqfM9H8XEIvjOjBVQ/wj/zrn02J28c=", 233 342 "owner": "cachix", 234 343 "repo": "pre-commit-hooks.nix", 235 - "rev": "efdbd6d28f7f44db3d9f8cf0e0b4cb9db0d259e1", 344 + "rev": "2d169bb1b23f3b71a894a66ea81f45c788943248", 236 345 "type": "github" 237 346 }, 238 347 "original": { ··· 245 354 "inputs": { 246 355 "ci-agent": "ci-agent", 247 356 "darwin": "darwin", 248 - "deploy": "deploy", 249 - "devshell": "devshell", 250 - "flake-compat": "flake-compat", 357 + "digga": "digga", 251 358 "home": "home", 252 - "naersk": "naersk", 359 + "latest": "latest", 360 + "naersk": "naersk_2", 253 361 "nixos": "nixos", 254 362 "nixos-hardware": "nixos-hardware", 255 363 "nur": "nur", 256 - "override": "override", 257 - "pkgs": "pkgs", 258 - "utils": "utils" 364 + "pkgs": "pkgs" 259 365 } 260 366 }, 261 367 "utils": { 262 368 "locked": { 263 - "lastModified": 1614513358, 264 - "narHash": "sha256-LakhOx3S1dRjnh0b5Dg3mbZyH0ToC9I8Y2wKSkBaTzU=", 369 + "lastModified": 1610051610, 370 + "narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=", 265 371 "owner": "numtide", 266 372 "repo": "flake-utils", 267 - "rev": "5466c5bbece17adaab2d82fae80b46e807611bf3", 373 + "rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc", 268 374 "type": "github" 269 375 }, 270 376 "original": { 271 377 "owner": "numtide", 272 378 "repo": "flake-utils", 379 + "type": "github" 380 + } 381 + }, 382 + "utils_2": { 383 + "inputs": { 384 + "flake-utils": "flake-utils" 385 + }, 386 + "locked": { 387 + "lastModified": 1620801141, 388 + "narHash": "sha256-XPJ+/nP/s218E11R+4LJyvkrQXvdT3D6TzNjfWVYZnI=", 389 + "owner": "gytis-ivaskevicius", 390 + "repo": "flake-utils-plus", 391 + "rev": "1a742047f3f7c97b22768ba7738ac5a01052099e", 392 + "type": "github" 393 + }, 394 + "original": { 395 + "owner": "gytis-ivaskevicius", 396 + "ref": "staging", 397 + "repo": "flake-utils-plus", 273 398 "type": "github" 274 399 } 275 400 }
+76 -33
flake.nix
··· 4 4 inputs = 5 5 { 6 6 nixos.url = "nixpkgs/nixos-unstable"; 7 - override.url = "nixpkgs"; 7 + latest.url = "nixpkgs"; 8 + digga.url = "github:divnix/digga"; 9 + 8 10 ci-agent = { 9 11 url = "github:hercules-ci/hercules-ci-agent"; 10 - inputs = { nix-darwin.follows = "darwin"; flake-compat.follows = "flake-compat"; nixos-20_09.follows = "nixos"; nixos-unstable.follows = "override"; }; 12 + inputs = { nix-darwin.follows = "darwin"; nixos-20_09.follows = "nixos"; nixos-unstable.follows = "latest"; }; 11 13 }; 12 14 darwin.url = "github:LnL7/nix-darwin"; 13 - darwin.inputs.nixpkgs.follows = "override"; 14 - deploy = { 15 - url = "github:serokell/deploy-rs"; 16 - inputs = { flake-compat.follows = "flake-compat"; naersk.follows = "naersk"; nixpkgs.follows = "override"; utils.follows = "utils"; }; 17 - }; 18 - devshell.url = "github:numtide/devshell"; 19 - flake-compat.url = "github:BBBSnowball/flake-compat/pr-1"; 20 - flake-compat.flake = false; 15 + darwin.inputs.nixpkgs.follows = "latest"; 21 16 home.url = "github:nix-community/home-manager"; 22 17 home.inputs.nixpkgs.follows = "nixos"; 23 18 naersk.url = "github:nmattia/naersk"; 24 - naersk.inputs.nixpkgs.follows = "override"; 19 + naersk.inputs.nixpkgs.follows = "latest"; 25 20 nixos-hardware.url = "github:nixos/nixos-hardware"; 26 - utils.url = "github:numtide/flake-utils"; 21 + 27 22 pkgs.url = "path:./pkgs"; 28 23 pkgs.inputs.nixpkgs.follows = "nixos"; 29 24 }; 30 25 31 - outputs = inputs@{ deploy, nixos, nur, self, utils, ... }: 32 - let 33 - lib = import ./lib { inherit self nixos utils inputs; }; 34 - in 35 - lib.mkFlake 36 - { 37 - inherit self; 38 - hosts = ./hosts; 39 - packages = import ./pkgs; 40 - suites = import ./profiles/suites.nix; 41 - extern = import ./extern; 42 - overrides = import ./extern/overrides.nix; 43 - overlays = ./overlays; 44 - profiles = ./profiles; 45 - userProfiles = ./users/profiles; 46 - modules = import ./modules/module-list.nix; 47 - userModules = import ./users/modules/module-list.nix; 48 - } // { 49 - inherit lib; 50 - defaultTemplate = self.templates.flk; 26 + outputs = inputs@{ self, pkgs, digga, nixos, ci-agent, home, nixos-hardware, nur, ... }: 27 + digga.lib.mkFlake { 28 + inherit self inputs; 29 + 30 + channelsConfig = { allowUnfree = true; }; 31 + 32 + channels = { 33 + nixos = { 34 + imports = [ (digga.lib.importers.overlays ./overlays) ]; 35 + overlays = [ 36 + ./pkgs/default.nix 37 + pkgs.overlay # for `srcs` 38 + nur.overlay 39 + ]; 40 + }; 41 + latest = { }; 42 + }; 43 + 44 + lib = import ./lib { lib = digga.lib // nixos.lib; }; 45 + 46 + sharedOverlays = [ 47 + (final: prev: { 48 + lib = prev.lib.extend (lfinal: lprev: { 49 + our = self.lib; 50 + }); 51 + }) 52 + ]; 53 + 54 + nixos = { 55 + hostDefaults = { 56 + system = "x86_64-linux"; 57 + channelName = "nixos"; 58 + modules = ./modules/module-list.nix; 59 + externalModules = [ 60 + { _module.args.ourLib = self.lib; } 61 + ci-agent.nixosModules.agent-profile 62 + home.nixosModules.home-manager 63 + ./modules/customBuilds.nix 64 + ]; 65 + }; 66 + 67 + imports = [ (digga.lib.importers.hosts ./hosts) ]; 68 + hosts = { 69 + /* set host specific properties here */ 70 + NixOS = { }; 71 + }; 72 + profiles = [ ./profiles ./users ]; 73 + suites = { profiles, users, ... }: with profiles; { 74 + base = [ core users.nixos users.root ]; 75 + }; 76 + }; 77 + 78 + home = { 79 + modules = ./users/modules/module-list.nix; 80 + externalModules = [ ]; 81 + profiles = [ ./users/profiles ]; 82 + suites = { profiles, ... }: with profiles; { 83 + base = [ direnv git ]; 84 + }; 85 + }; 86 + 87 + homeConfigurations = digga.lib.mkHomeConfigurations self.nixosConfigurations; 88 + 89 + deploy.nodes = digga.lib.mkDeployNodes self.nixosConfigurations { }; 90 + 91 + #defaultTemplate = self.templates.flk; 51 92 templates.flk.path = ./.; 52 93 templates.flk.description = "flk template"; 53 - }; 94 + 95 + } 96 + ; 54 97 }
-45
lib/attrs.nix
··· 1 - { lib, ... }: 2 - rec { 3 - # mapFilterAttrs :: 4 - # (name -> value -> bool ) 5 - # (name -> value -> { name = any; value = any; }) 6 - # attrs 7 - mapFilterAttrs = seive: f: attrs: 8 - lib.filterAttrs 9 - seive 10 - (lib.mapAttrs' f attrs); 11 - 12 - # Generate an attribute set by mapping a function over a list of values. 13 - genAttrs' = values: f: lib.listToAttrs (map f values); 14 - 15 - # Convert a list of file paths to attribute set where 16 - # the key is the folder or filename stripped of nix 17 - # extension and imported content of the file as value. 18 - # 19 - pathsToImportedAttrs = paths: 20 - let 21 - paths' = lib.filter 22 - (path: lib.hasSuffix ".nix" path 23 - || lib.pathExists "${path}/default.nix") 24 - paths; 25 - in 26 - genAttrs' paths' (path: { 27 - name = lib.removeSuffix ".nix" 28 - # Safe as long this is just used as a name 29 - (builtins.unsafeDiscardStringContext (baseNameOf path)); 30 - value = import path; 31 - }); 32 - 33 - concatAttrs = lib.fold (attr: sum: lib.recursiveUpdate sum attr) { }; 34 - 35 - # Filter out packages that support given system and follow flake check requirements 36 - filterPackages = system: packages: 37 - let 38 - # Everything that nix flake check requires for the packages output 39 - filter = (n: v: with v; let platforms = meta.hydraPlatforms or meta.platforms or [ ]; in 40 - lib.isDerivation v && !meta.broken && builtins.elem system platforms); 41 - in 42 - lib.filterAttrs filter packages; 43 - 44 - safeReadDir = path: lib.optionalAttrs (builtins.pathExists path) (builtins.readDir path); 45 - }
+2 -4
lib/compat/default.nix
··· 1 1 let 2 - inherit (lock.nodes.flake-compat.locked) rev narHash; 3 - 4 - lock = builtins.fromJSON (builtins.readFile "${../..}/flake.lock"); 2 + rev = "e7e5d481a0e15dcd459396e55327749989e04ce0"; 5 3 flake = (import 6 4 ( 7 5 fetchTarball { 8 6 url = "https://github.com/edolstra/flake-compat/archive/${rev}.tar.gz"; 9 - sha256 = narHash; 7 + sha256 = "0zd3x46fswh5n6faq4x2kkpy6p3c6j593xbdlbsl40ppkclwc80x"; 10 8 } 11 9 ) 12 10 {
+2 -28
lib/default.nix
··· 1 - args@{ nixos, self, ... }: 2 - let inherit (nixos) lib; in 3 - lib.makeExtensible (final: 4 - let callLibs = file: import file 5 - ({ 6 - inherit lib; 7 - 8 - dev = final; 9 - } // args); 10 - in 11 - with final; 12 - { 13 - inherit callLibs; 14 - 15 - attrs = callLibs ./attrs.nix; 16 - os = callLibs ./devos; 17 - lists = callLibs ./lists.nix; 18 - strings = callLibs ./strings.nix; 19 - 20 - mkFlake = callLibs ./mkFlake; 21 - 22 - pkgs-lib = callLibs ./pkgs-lib; 23 - 24 - inherit (attrs) mapFilterAttrs genAttrs' safeReadDir 25 - pathsToImportedAttrs concatAttrs filterPackages; 26 - inherit (lists) pathsIn; 27 - inherit (strings) rgxToString; 28 - }) 1 + { lib }: 2 + lib.makeExtensible (self: { })
-30
lib/devos/default.nix
··· 1 - { lib, nixos, dev, ... }: 2 - { 3 - # pkgImport :: Nixpkgs -> Overlays -> System -> Pkgs 4 - pkgImport = nixpkgs: overlays: system: 5 - import nixpkgs { 6 - inherit system overlays; 7 - config = { allowUnfree = true; }; 8 - }; 9 - 10 - profileMap = list: map (profile: profile.default) (lib.flatten list); 11 - 12 - mkNodes = dev.callLibs ./mkNodes.nix; 13 - 14 - mkHosts = dev.callLibs ./mkHosts.nix; 15 - 16 - mkSuites = dev.callLibs ./mkSuites.nix; 17 - 18 - mkProfileAttrs = dev.callLibs ./mkProfileAttrs.nix; 19 - 20 - mkPkgs = dev.callLibs ./mkPkgs.nix; 21 - 22 - recImport = dev.callLibs ./recImport.nix; 23 - 24 - devosSystem = dev.callLibs ./devosSystem.nix; 25 - 26 - mkHomeConfigurations = dev.callLibs ./mkHomeConfigurations.nix; 27 - 28 - mkPackages = dev.callLibs ./mkPackages.nix; 29 - } 30 -
-102
lib/devos/devosSystem.nix
··· 1 - { lib, nixos, self, inputs, ... }: 2 - 3 - { modules, ... } @ args: 4 - lib.nixosSystem (args // { 5 - modules = 6 - let 7 - moduleList = builtins.attrValues modules; 8 - modpath = "nixos/modules"; 9 - 10 - fullHostConfig = (lib.nixosSystem (args // { modules = moduleList; })).config; 11 - 12 - isoConfig = (lib.nixosSystem 13 - (args // { 14 - modules = moduleList ++ [ 15 - 16 - "${nixos}/${modpath}/installer/cd-dvd/installation-cd-minimal-new-kernel.nix" 17 - 18 - ({ config, suites, ... }: { 19 - 20 - # avoid unwanted systemd service startups 21 - # all strings in disabledModules get appended to modulesPath 22 - # so convert each to list which can be coerced to string 23 - disabledModules = map lib.singleton suites.allProfiles; 24 - 25 - nix.registry = lib.mapAttrs (n: v: { flake = v; }) inputs; 26 - 27 - isoImage.isoBaseName = "nixos-" + config.networking.hostName; 28 - isoImage.contents = [{ 29 - source = self; 30 - target = "/devos/"; 31 - }]; 32 - isoImage.storeContents = [ 33 - self.devShell.${config.nixpkgs.system} 34 - # include also closures that are "switched off" by the 35 - # above profile filter on the local config attribute 36 - fullHostConfig.system.build.toplevel 37 - ]; 38 - # still pull in tools of deactivated profiles 39 - environment.systemPackages = fullHostConfig.environment.systemPackages; 40 - 41 - # confilcts with networking.wireless which might be slightly 42 - # more useful on a stick 43 - networking.networkmanager.enable = lib.mkForce false; 44 - # confilcts with networking.wireless 45 - networking.wireless.iwd.enable = lib.mkForce false; 46 - 47 - # Set up a link-local boostrap network 48 - # See also: https://github.com/NixOS/nixpkgs/issues/75515#issuecomment-571661659 49 - networking.usePredictableInterfaceNames = lib.mkForce true; # so prefix matching works 50 - networking.useNetworkd = lib.mkForce true; 51 - networking.useDHCP = lib.mkForce false; 52 - networking.dhcpcd.enable = lib.mkForce false; 53 - systemd.network = { 54 - # https://www.freedesktop.org/software/systemd/man/systemd.network.html 55 - networks."boostrap-link-local" = { 56 - matchConfig = { 57 - Name = "en* wl* ww*"; 58 - }; 59 - networkConfig = { 60 - Description = "Link-local host bootstrap network"; 61 - MulticastDNS = true; 62 - LinkLocalAddressing = "ipv6"; 63 - DHCP = "yes"; 64 - }; 65 - address = [ 66 - # fall back well-known link-local for situations where MulticastDNS is not available 67 - "fe80::47" # 47: n=14 i=9 x=24; n+i+x 68 - ]; 69 - extraConfig = '' 70 - # Unique, yet stable. Based off the MAC address. 71 - IPv6LinkLocalAddressGenerationMode = "eui64" 72 - ''; 73 - }; 74 - }; 75 - }) 76 - ]; 77 - })).config; 78 - hmConfig = (lib.nixosSystem 79 - (args // { 80 - modules = moduleList ++ [ 81 - ({ config, ... }: { 82 - home-manager.useUserPackages = lib.mkForce false; 83 - home-manager.sharedModules = [ 84 - { 85 - home.sessionVariables = { 86 - inherit (config.environment.sessionVariables) NIX_PATH; 87 - }; 88 - xdg.configFile."nix/registry.json".text = 89 - config.environment.etc."nix/registry.json".text; 90 - } 91 - ]; 92 - }) 93 - ]; 94 - })).config; 95 - in 96 - moduleList ++ [{ 97 - system.build = { 98 - iso = isoConfig.system.build.isoImage; 99 - homes = hmConfig.home-manager.users; 100 - }; 101 - }]; 102 - })
-12
lib/devos/mkHomeConfigurations.nix
··· 1 - { lib, self, ... }: 2 - 3 - with lib; 4 - let 5 - mkHomes = host: config: 6 - mapAttrs' (user: v: nameValuePair "${user}@${host}" v.home) 7 - config.config.system.build.homes; 8 - 9 - hmConfigs = mapAttrs mkHomes self.nixosConfigurations; 10 - 11 - in 12 - foldl recursiveUpdate { } (attrValues hmConfigs)
-109
lib/devos/mkHosts.nix
··· 1 - { lib, dev, nixos, inputs, self, ... }: 2 - 3 - { dir, extern, suites, overrides, multiPkgs, ... }: 4 - let 5 - defaultSystem = "x86_64-linux"; 6 - 7 - experimentalFeatures = [ 8 - "flakes" 9 - "nix-command" 10 - "ca-references" 11 - "ca-derivations" 12 - ]; 13 - 14 - modules = { 15 - modOverrides = { config, overrideModulesPath, ... }: 16 - let 17 - inherit (overrides) modules disabledModules; 18 - in 19 - { 20 - disabledModules = modules ++ disabledModules; 21 - imports = map 22 - (path: "${overrideModulesPath}/${path}") 23 - modules; 24 - }; 25 - 26 - global = { config, pkgs, ... }: { 27 - home-manager = { 28 - useGlobalPkgs = true; 29 - useUserPackages = true; 30 - 31 - extraSpecialArgs = extern.userSpecialArgs // { suites = suites.user; }; 32 - sharedModules = extern.userModules ++ (builtins.attrValues self.homeModules); 33 - }; 34 - users.mutableUsers = lib.mkDefault false; 35 - 36 - hardware.enableRedistributableFirmware = lib.mkDefault true; 37 - 38 - nix.nixPath = [ 39 - "nixpkgs=${nixos}" 40 - "nixos-config=${self}/lib/compat/nixos" 41 - "home-manager=${inputs.home}" 42 - ]; 43 - 44 - nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system}; 45 - 46 - nix.registry = { 47 - devos.flake = self; 48 - nixos.flake = nixos; 49 - override.flake = inputs.override; 50 - }; 51 - 52 - nix.package = pkgs.nixFlakes; 53 - 54 - nix.extraOptions = '' 55 - experimental-features = ${lib.concatStringsSep " " 56 - experimentalFeatures 57 - } 58 - ''; 59 - 60 - system.configurationRevision = lib.mkIf (self ? rev) self.rev; 61 - }; 62 - 63 - # Everything in `./modules/list.nix`. 64 - flakeModules = { imports = builtins.attrValues self.nixosModules ++ extern.modules; }; 65 - 66 - cachix = let rootCachix = ../../cachix.nix; in 67 - if builtins.pathExists rootCachix 68 - then rootCachix 69 - else { } 70 - ; 71 - }; 72 - 73 - specialArgs = extern.specialArgs // { suites = suites.system; }; 74 - 75 - mkHostConfig = hostName: 76 - let 77 - local = { 78 - require = [ 79 - "${dir}/${hostName}.nix" 80 - ]; 81 - 82 - networking = { inherit hostName; }; 83 - 84 - _module.args = { 85 - inherit self; 86 - hosts = builtins.mapAttrs (_: host: host.config) 87 - (removeAttrs hosts [ hostName ]); 88 - }; 89 - }; 90 - lib = { 91 - lib = { inherit specialArgs; }; 92 - lib.testModule = { 93 - imports = [ local ] ++ builtins.attrValues modules; 94 - }; 95 - }; 96 - in 97 - dev.os.devosSystem { 98 - inherit specialArgs; 99 - system = defaultSystem; 100 - modules = modules // { inherit local lib; }; 101 - }; 102 - 103 - hosts = dev.os.recImport 104 - { 105 - inherit dir; 106 - _import = mkHostConfig; 107 - }; 108 - in 109 - hosts
-16
lib/devos/mkNodes.nix
··· 1 - { lib, ... }: 2 - 3 - /** 4 - Synopsis: mkNodes _nixosConfigurations_ 5 - 6 - Generate the `nodes` attribute expected by deploy-rs 7 - where _nixosConfigurations_ are `nodes`. 8 - **/ 9 - deploy: lib.mapAttrs (_: config: { 10 - hostname = config.config.networking.hostName; 11 - 12 - profiles.system = { 13 - user = "root"; 14 - path = deploy.lib.x86_64-linux.activate.nixos config; 15 - }; 16 - })
-18
lib/devos/mkPackages.nix
··· 1 - { lib, dev, self, ... }: 2 - 3 - { pkgs }: 4 - let 5 - inherit (self) overlay overlays; 6 - packagesNames = lib.attrNames (overlay null null) 7 - ++ lib.attrNames (dev.concatAttrs 8 - (lib.attrValues 9 - (lib.mapAttrs (_: v: v null null) overlays) 10 - ) 11 - ); 12 - in 13 - lib.fold 14 - (key: sum: lib.recursiveUpdate sum { 15 - ${key} = pkgs.${key}; 16 - }) 17 - { } 18 - packagesNames
-27
lib/devos/mkPkgs.nix
··· 1 - { lib, dev, nixos, self, inputs, ... }: 2 - 3 - { extern, overrides }: 4 - (inputs.utils.lib.eachDefaultSystem 5 - (system: 6 - let 7 - overridePkgs = dev.os.pkgImport inputs.override [ ] system; 8 - overridesOverlay = overrides.packages; 9 - 10 - overlays = [ 11 - (final: prev: { 12 - lib = prev.lib.extend (lfinal: lprev: { 13 - inherit dev; 14 - inherit (lib) nixosSystem; 15 - 16 - utils = inputs.utils.lib; 17 - }); 18 - }) 19 - (overridesOverlay overridePkgs) 20 - self.overlay 21 - ] 22 - ++ extern.overlays 23 - ++ (lib.attrValues self.overlays); 24 - in 25 - { pkgs = dev.os.pkgImport nixos overlays system; } 26 - ) 27 - ).pkgs
-35
lib/devos/mkProfileAttrs.nix
··· 1 - { lib, dev, ... }: 2 - 3 - let mkProfileAttrs = 4 - /** 5 - Synopsis: mkProfileAttrs _path_ 6 - 7 - Recursively collect the subdirs of _path_ containing a default.nix into attrs. 8 - This sets a contract, eliminating ambiguity for _default.nix_ living under the 9 - profile directory. 10 - 11 - Example: 12 - let profiles = mkProfileAttrs ./profiles; in 13 - assert profiles ? core.default; 0 14 - **/ 15 - dir: 16 - let 17 - imports = 18 - let 19 - files = dev.safeReadDir dir; 20 - 21 - p = n: v: 22 - v == "directory" 23 - && n != "profiles"; 24 - in 25 - lib.filterAttrs p files; 26 - 27 - f = n: _: 28 - lib.optionalAttrs 29 - (lib.pathExists "${dir}/${n}/default.nix") 30 - { default = "${dir}/${n}"; } 31 - // mkProfileAttrs "${dir}/${n}"; 32 - in 33 - lib.mapAttrs f imports; 34 - in mkProfileAttrs 35 -
-24
lib/devos/mkSuites.nix
··· 1 - { lib, dev, ... }: 2 - 3 - { users, profiles, userProfiles, suites } @ args: 4 - let 5 - inherit (dev) os; 6 - 7 - definedSuites = suites { 8 - inherit (args) users profiles userProfiles; 9 - }; 10 - 11 - allProfiles = 12 - let defaults = lib.collect (x: x ? default) profiles; 13 - in map (x: x.default) defaults; 14 - 15 - allUsers = 16 - let defaults = lib.collect (x: x ? default) users; 17 - in map (x: x.default) defaults; 18 - 19 - createSuites = _: suites: lib.mapAttrs (_: v: os.profileMap v) suites // { 20 - inherit allProfiles allUsers; 21 - }; 22 - 23 - in 24 - lib.mapAttrs createSuites definedSuites
-12
lib/devos/recImport.nix
··· 1 - { lib, dev, ... }: 2 - 3 - { dir, _import ? base: import "${dir}/${base}.nix" }: 4 - dev.mapFilterAttrs 5 - (_: v: v != null) 6 - (n: v: 7 - if n != "default.nix" && lib.hasSuffix ".nix" n && v == "regular" 8 - then 9 - let name = lib.removeSuffix ".nix" n; in lib.nameValuePair (name) (_import name) 10 - else 11 - lib.nameValuePair ("") (null)) 12 - (dev.safeReadDir dir)
-8
lib/lists.nix
··· 1 - { lib, dev, ... }: 2 - { 3 - pathsIn = dir: 4 - let 5 - fullPath = name: "${toString dir}/${name}"; 6 - in 7 - map fullPath (lib.attrNames (dev.safeReadDir dir)); 8 - }
-55
lib/mkFlake/default.nix
··· 1 - { dev, nixos, inputs, ... }: 2 - let 3 - inherit (dev) os; 4 - inherit (inputs) utils deploy; 5 - evalFlakeArgs = dev.callLibs ./evalArgs.nix; 6 - in 7 - 8 - { self, ... } @ args: 9 - let 10 - 11 - cfg = (evalFlakeArgs { inherit args; }).config; 12 - 13 - multiPkgs = os.mkPkgs { inherit (cfg) extern overrides; }; 14 - 15 - outputs = { 16 - nixosConfigurations = os.mkHosts { 17 - inherit self multiPkgs; 18 - inherit (cfg) extern suites overrides; 19 - dir = cfg.hosts; 20 - }; 21 - 22 - homeConfigurations = os.mkHomeConfigurations; 23 - 24 - nixosModules = cfg.modules; 25 - 26 - homeModules = cfg.userModules; 27 - 28 - overlay = cfg.packages; 29 - inherit (cfg) overlays; 30 - 31 - deploy.nodes = os.mkNodes deploy self.nixosConfigurations; 32 - }; 33 - 34 - systemOutputs = utils.lib.eachDefaultSystem (system: 35 - let 36 - pkgs = multiPkgs.${system}; 37 - pkgs-lib = dev.pkgs-lib.${system}; 38 - # all packages that are defined in ./pkgs 39 - legacyPackages = os.mkPackages { inherit pkgs; }; 40 - in 41 - { 42 - checks = pkgs-lib.tests.mkChecks { 43 - inherit (self.deploy) nodes; 44 - hosts = self.nixosConfigurations; 45 - homes = self.homeConfigurations; 46 - }; 47 - 48 - inherit legacyPackages; 49 - packages = dev.filterPackages system legacyPackages; 50 - 51 - devShell = pkgs-lib.shell; 52 - }); 53 - in 54 - outputs // systemOutputs 55 -
-154
lib/mkFlake/evalArgs.nix
··· 1 - { self, dev, nixos, inputs, ... }: 2 - 3 - { args }: 4 - let 5 - argOpts = with nixos.lib; { config, options, ... }: 6 - let 7 - inherit (dev) os; 8 - 9 - inherit (config) self; 10 - 11 - inputAttrs = with types; functionTo attrs; 12 - moduleType = with types; anything // { 13 - inherit (submodule { }) check; 14 - description = "valid module"; 15 - }; 16 - in 17 - { 18 - options = with types; { 19 - self = mkOption { 20 - type = addCheck attrs nixos.lib.isStorePath; 21 - description = "The flake to create the devos outputs for"; 22 - }; 23 - hosts = mkOption { 24 - type = path; 25 - default = "${self}/hosts"; 26 - defaultText = "\${self}/hosts"; 27 - apply = toString; 28 - description = '' 29 - Path to directory containing host configurations that will be exported 30 - to the 'nixosConfigurations' output. 31 - ''; 32 - }; 33 - packages = mkOption { 34 - # functionTo changes arg names which breaks flake check 35 - type = types.anything // { 36 - check = builtins.isFunction; 37 - description = "Nixpkgs overlay"; 38 - }; 39 - default = (final: prev: { }); 40 - defaultText = "(final: prev: {})"; 41 - description = '' 42 - Overlay for custom packages that will be included in treewide 'pkgs'. 43 - This should follow the standard nixpkgs overlay format - two argument function 44 - that returns an attrset. 45 - These packages will be exported to the 'packages' and 'legacyPackages' outputs. 46 - ''; 47 - }; 48 - modules = mkOption { 49 - type = listOf moduleType; 50 - default = [ ]; 51 - apply = dev.pathsToImportedAttrs; 52 - description = '' 53 - list of modules to include in confgurations and export in 'nixosModules' output 54 - ''; 55 - }; 56 - userModules = mkOption { 57 - type = listOf moduleType; 58 - default = [ ]; 59 - apply = dev.pathsToImportedAttrs; 60 - description = '' 61 - list of modules to include in home-manager configurations and export in 62 - 'homeModules' output 63 - ''; 64 - }; 65 - profiles = mkOption { 66 - type = path; 67 - default = "${self}/profiles"; 68 - defaultText = "\${self}/profiles"; 69 - apply = x: os.mkProfileAttrs (toString x); 70 - description = "path to profiles folder that can be collected into suites"; 71 - }; 72 - userProfiles = mkOption { 73 - type = path; 74 - default = "${self}/users/profiles"; 75 - defaultText = "\${self}/users/profiles"; 76 - apply = x: os.mkProfileAttrs (toString x); 77 - description = "path to user profiles folder that can be collected into userSuites"; 78 - }; 79 - suites = 80 - let 81 - defaults = { user = { }; system = { }; }; 82 - in 83 - mkOption { 84 - type = inputAttrs; 85 - default = { ... }: defaults; 86 - defaultText = "{ user = {}; system = {}; }"; 87 - apply = suites: defaults // os.mkSuites { 88 - inherit suites; 89 - inherit (config) profiles users userProfiles; 90 - }; 91 - description = '' 92 - Function with inputs 'users' and 'profiles' that returns attribute set 93 - with user and system suites. The former for Home Manager and the latter 94 - for nixos configurations. 95 - These can be accessed through the 'suites' specialArg in each config system. 96 - ''; 97 - }; 98 - users = mkOption { 99 - type = path; 100 - default = "${self}/users"; 101 - defaultText = "\${self}/users"; 102 - apply = x: os.mkProfileAttrs (toString x); 103 - description = '' 104 - path to folder containing profiles that define system users 105 - ''; 106 - }; 107 - extern = 108 - let 109 - defaults = { 110 - modules = [ ]; 111 - overlays = [ ]; 112 - specialArgs = { }; 113 - userModules = [ ]; 114 - userSpecialArgs = { }; 115 - }; 116 - in 117 - mkOption { 118 - type = inputAttrs; 119 - default = { ... }: defaults; 120 - defaultText = '' 121 - { modules = []; overlays = []; specialArgs = []; userModules = []; userSpecialArgs = []; } 122 - ''; 123 - # So unneeded extern attributes can safely be deleted 124 - apply = x: defaults // (x { inputs = inputs // self.inputs; }); 125 - description = '' 126 - Function with argument 'inputs' that contains all devos and ''${self}'s inputs. 127 - The function should return an attribute set with modules, overlays, and 128 - specialArgs to be included across nixos and home manager configurations. 129 - Only attributes that are used should be returned. 130 - ''; 131 - }; 132 - overlays = mkOption { 133 - type = path; 134 - default = "${self}/overlays"; 135 - defaultText = "\${self}/overlays"; 136 - apply = x: dev.pathsToImportedAttrs (dev.pathsIn (toString x)); 137 - description = '' 138 - path to folder containing overlays which will be applied to pkgs and exported in 139 - the 'overlays' output 140 - ''; 141 - }; 142 - overrides = mkOption rec { 143 - type = attrs; 144 - default = { modules = [ ]; disabledModules = [ ]; packages = _: _: _: { }; }; 145 - defaultText = "{ modules = []; disabledModules = []; packages = {}; }"; 146 - apply = x: default // x; 147 - description = "attrset of packages and modules that will be pulled from nixpkgs master"; 148 - }; 149 - }; 150 - }; 151 - in 152 - nixos.lib.evalModules { 153 - modules = [ argOpts args ]; 154 - }
-20
lib/pkgs-lib/default.nix
··· 1 - args@{ lib, dev, utils, nixos, ... }: 2 - lib.genAttrs utils.lib.defaultSystems (system: 3 - lib.makeExtensible (final: 4 - let 5 - pkgs = import nixos { inherit system; }; 6 - callLibs = file: import file 7 - (args // { 8 - inherit pkgs system; 9 - pkgs-lib = final; 10 - }); 11 - in 12 - with final; 13 - { 14 - inherit callLibs; 15 - 16 - tests = callLibs ./tests; 17 - shell = callLibs ./shell; 18 - } 19 - ) 20 - )
-49
lib/pkgs-lib/shell/default.nix
··· 1 - { lib, dev, inputs, system, nixos, ... }: 2 - let 3 - overlays = [ 4 - inputs.devshell.overlay 5 - (final: prev: { 6 - deploy-rs = 7 - inputs.deploy.packages.${prev.system}.deploy-rs; 8 - }) 9 - ]; 10 - 11 - pkgs = dev.os.pkgImport nixos overlays system; 12 - 13 - flk = pkgs.callPackage ./flk.nix { }; 14 - 15 - installPkgs = (lib.nixosSystem { 16 - inherit system; 17 - modules = [ ]; 18 - }).config.system.build; 19 - in 20 - pkgs.devshell.mkShell { 21 - imports = [ (pkgs.devshell.importTOML ./devshell.toml) ]; 22 - 23 - packages = with installPkgs; [ 24 - nixos-install 25 - nixos-generate-config 26 - nixos-enter 27 - ]; 28 - 29 - git.hooks = { 30 - pre-commit.text = lib.fileContents ./pre-commit.sh; 31 - }; 32 - 33 - commands = with pkgs; [ 34 - { package = flk; } 35 - { 36 - name = "nix"; 37 - help = pkgs.nixFlakes.meta.description; 38 - command = '' 39 - ${pkgs.nixFlakes}/bin/nix --experimental-features "nix-command flakes ca-references" "${"\${@}"}" 40 - ''; 41 - } 42 - ] 43 - ++ lib.optional (system != "i686-linux") { package = cachix; } 44 - ++ lib.optional (system == "x86_64-linux") { 45 - name = "deploy"; 46 - package = deploy-rs; 47 - help = "A simple multi-profile Nix-flake deploy tool."; 48 - }; 49 - }
-29
lib/pkgs-lib/shell/devshell.toml
··· 1 - imports = [ "git.hooks" ] 2 - 3 - [devshell] 4 - packages = [ 5 - "git-crypt" 6 - ] 7 - 8 - [[commands]] 9 - package = "git" 10 - category = "vcs" 11 - 12 - [[commands]] 13 - package = "nixpkgs-fmt" 14 - category = "linters" 15 - 16 - [[commands]] 17 - package = "editorconfig-checker" 18 - category = "linters" 19 - 20 - [[commands]] 21 - package = "python3Packages.grip" 22 - category = "documentation" 23 - 24 - [[commands]] 25 - package = "mdbook" 26 - category = "documentation" 27 - 28 - [git.hooks] 29 - enable = true
-23
lib/pkgs-lib/shell/flk.nix
··· 1 - { stdenv }: 2 - let 3 - name = "flk"; 4 - in 5 - stdenv.mkDerivation { 6 - inherit name; 7 - 8 - src = ./flk.sh; 9 - 10 - dontUnpack = true; 11 - dontBuild = true; 12 - 13 - installPhase = '' 14 - mkdir -p $out/bin 15 - install $src $out/bin/${name} 16 - ''; 17 - 18 - checkPhase = '' 19 - ${stdenv.shell} -n -O extglob $out/bin/${name} 20 - ''; 21 - 22 - meta.description = "Build, deploy, and install NixOS"; 23 - }
-98
lib/pkgs-lib/shell/flk.sh
··· 1 - #!/usr/bin/env bash 2 - 3 - [[ -d "$DEVSHELL_ROOT" ]] || 4 - { 5 - echo "This script must be run from devos's devshell" >&2 6 - exit 1 7 - } 8 - 9 - shopt -s extglob 10 - 11 - HOSTNAME="$(hostname)" 12 - 13 - usage () { 14 - printf "%b\n" \ 15 - "\e[4mUsage\e[0m: $(basename $0) COMMAND [ARGS]\n" \ 16 - "\e[4mCommands\e[0m:" 17 - 18 - printf " %-30s %s\n\n" \ 19 - "up" "Generate $DEVSHELL_ROOT/hosts/up-$HOSTNAME.nix" \ 20 - "update [INPUT]" "Update and commit the lock file, or specific input" \ 21 - "get (core|community) [DEST]" "Copy the desired template to DEST" \ 22 - "iso HOST" "Generate an ISO image of HOST" \ 23 - "install HOST [ARGS]" "Shortcut for nixos-install" \ 24 - "home HOST USER [switch]" "Home-manager config of USER from HOST" \ 25 - "HOST (switch|boot|test)" "Shortcut for nixos-rebuild" 26 - } 27 - 28 - case "$1" in 29 - ""|"-h"|"help"|*(-)"help") 30 - usage 31 - ;; 32 - 33 - "up") 34 - mkdir -p "$DEVSHELL_ROOT/up" 35 - 36 - nixos-generate-config --dir "$DEVSHELL_ROOT/up/$HOSTNAME" 37 - 38 - printf "%s\n" \ 39 - "{ suites, ... }:" \ 40 - "{" \ 41 - " imports = [" \ 42 - " ../up/$HOSTNAME/configuration.nix" \ 43 - " ] ++ suites.core;" \ 44 - "}" > "$DEVSHELL_ROOT/hosts/up-$HOSTNAME.nix" 45 - 46 - git add -f \ 47 - "$DEVSHELL_ROOT/up/$HOSTNAME" \ 48 - "$DEVSHELL_ROOT/hosts/up-$HOSTNAME.nix" 49 - ;; 50 - 51 - "update") 52 - if [[ -n "$2" ]]; then 53 - if [[ -n "$3" ]]; then 54 - (cd $2; nix flake list-inputs --update-input "$3") 55 - else 56 - (cd $2; nix flake update) 57 - fi 58 - nix flake list-inputs --update-input "$2" "$DEVSHELL_ROOT" 59 - else 60 - nix flake update "$DEVSHELL_ROOT" 61 - fi 62 - ;; 63 - 64 - "get") 65 - if [[ "$2" == "core" || "$2" == "community" ]]; then 66 - nix flake new -t "github:divnix/devos/$2" "${3:-flk}" 67 - else 68 - echo "flk get (core|community) [DEST]" 69 - exit 1 70 - fi 71 - ;; 72 - 73 - "iso") 74 - nix build \ 75 - "$DEVSHELL_ROOT#nixosConfigurations.$2.config.system.build.iso" \ 76 - "${@:3}" 77 - ;; 78 - 79 - "install") 80 - sudo nixos-install --flake "$DEVSHELL_ROOT#$2" "${@:3}" 81 - ;; 82 - 83 - "home") 84 - ref="$DEVSHELL_ROOT/#homeConfigurations.$3@$2.activationPackage" 85 - 86 - if [[ "$4" == "switch" ]]; then 87 - nix build "$ref" && result/activate && 88 - unlink result 89 - 90 - else 91 - nix build "$ref" "${@:4}" 92 - fi 93 - ;; 94 - 95 - *) 96 - sudo nixos-rebuild --flake "$DEVSHELL_ROOT#$1" "${@:2}" 97 - ;; 98 - esac
-29
lib/pkgs-lib/shell/pre-commit.sh
··· 1 - #!/usr/bin/env bash 2 - 3 - if git rev-parse --verify HEAD >/dev/null 2>&1 4 - then 5 - against=HEAD 6 - else 7 - # Initial commit: diff against an empty tree object 8 - against=$(${git}/bin/git hash-object -t tree /dev/null) 9 - fi 10 - 11 - diff="git diff-index --name-only --cached $against --diff-filter d" 12 - 13 - nix_files=($($diff -- '*.nix')) 14 - all_files=($($diff)) 15 - 16 - # Format staged nix files. 17 - if [[ -n "${nix_files[@]}" ]]; then 18 - nixpkgs-fmt "${nix_files[@]}" \ 19 - && git add "${nix_files[@]}" 20 - fi 21 - 22 - # check editorconfig 23 - editorconfig-checker -- "${all_files[@]}" 24 - if [[ $? != '0' ]]; then 25 - printf "%b\n" \ 26 - "\nCode is not aligned with .editorconfig" \ 27 - "Review the output and commit your fixes" >&2 28 - exit 1 29 - fi
-83
lib/pkgs-lib/tests/default.nix
··· 1 - { pkgs-lib, pkgs, system, inputs, nixos, lib, ... }: 2 - let 3 - mkChecks = { hosts, nodes, homes ? { } }: 4 - let 5 - deployHosts = lib.filterAttrs 6 - (n: _: hosts.${n}.config.nixpkgs.system == system) 7 - nodes; 8 - deployChecks = inputs.deploy.lib.${system}.deployChecks { nodes = deployHosts; }; 9 - tests = 10 - { libTests = libTests; } 11 - // lib.optionalAttrs (deployHosts != { }) { 12 - profilesTest = profilesTest (hosts.${(builtins.head (builtins.attrNames deployHosts))}); 13 - } // lib.mapAttrs (n: v: v.activationPackage) homes; 14 - 15 - in 16 - lib.recursiveUpdate tests deployChecks; 17 - 18 - mkTest = host: 19 - let 20 - nixosTesting = 21 - (import "${nixos}/nixos/lib/testing-python.nix" { 22 - inherit system; 23 - inherit (host.config.lib) specialArgs; 24 - inherit pkgs; 25 - extraConfigurations = [ 26 - host.config.lib.testModule 27 - ]; 28 - }); 29 - in 30 - test: 31 - let 32 - loadedTest = 33 - if builtins.typeOf test == "path" 34 - then import test 35 - else test; 36 - calledTest = 37 - if pkgs.lib.isFunction loadedTest 38 - then pkgs.callPackage loadedTest { } 39 - else loadedTest; 40 - in 41 - nixosTesting.makeTest calledTest; 42 - 43 - profilesTest = host: mkTest host { 44 - name = "profiles"; 45 - 46 - machine = { suites, ... }: { 47 - imports = suites.allProfiles ++ suites.allUsers; 48 - }; 49 - 50 - testScript = '' 51 - ${host.config.networking.hostName}.systemctl("is-system-running --wait") 52 - ''; 53 - }; 54 - 55 - libTests = pkgs.runCommandNoCC "devos-lib-tests" 56 - { 57 - buildInputs = [ 58 - pkgs.nix 59 - ( 60 - let tests = pkgs-lib.callLibs ./lib.nix; 61 - in 62 - if tests == [ ] 63 - then null 64 - else throw (builtins.toJSON tests) 65 - ) 66 - ]; 67 - } '' 68 - datadir="${pkgs.nix}/share" 69 - export TEST_ROOT=$(pwd)/test-tmp 70 - export NIX_BUILD_HOOK= 71 - export NIX_CONF_DIR=$TEST_ROOT/etc 72 - export NIX_LOCALSTATE_DIR=$TEST_ROOT/var 73 - export NIX_LOG_DIR=$TEST_ROOT/var/log/nix 74 - export NIX_STATE_DIR=$TEST_ROOT/var/nix 75 - export NIX_STORE_DIR=$TEST_ROOT/store 76 - export PAGER=cat 77 - cacheDir=$TEST_ROOT/binary-cache 78 - nix-store --init 79 - 80 - touch $out 81 - ''; 82 - in 83 - { inherit mkTest libTests profilesTest mkChecks; }
-93
lib/pkgs-lib/tests/lib.nix
··· 1 - { pkgs, lib, dev, ... }: 2 - with dev; 3 - lib.runTests { 4 - testConcatAttrs = { 5 - expr = concatAttrs [{ foo = 1; } { bar = 2; } { baz = 3; }]; 6 - 7 - expected = { foo = 1; bar = 2; baz = 3; }; 8 - }; 9 - 10 - testGenAttrs' = { 11 - expr = genAttrs' 12 - [ "/foo/bar" "/baz/buzz" ] 13 - (path: { 14 - name = baseNameOf path; 15 - value = "${path}/fizz"; 16 - }); 17 - 18 - expected = { bar = "/foo/bar/fizz"; buzz = "/baz/buzz/fizz"; }; 19 - }; 20 - 21 - testMapFilterAttrs = { 22 - expr = mapFilterAttrs 23 - (n: v: n == "foobar" && v == 1) 24 - (n: v: lib.nameValuePair ("${n}bar") (v + 1)) 25 - { foo = 0; bar = 2; }; 26 - 27 - expected = { foobar = 1; }; 28 - }; 29 - 30 - testPathsIn = { 31 - expr = pathsIn (toString ./testPathsIn); 32 - 33 - expected = map toString [ 34 - ./testPathsIn/bar 35 - ./testPathsIn/baz 36 - ./testPathsIn/foo 37 - ]; 38 - }; 39 - 40 - testPathsToImportedAttrs = { 41 - expr = 42 - pathsToImportedAttrs [ 43 - (toString ./testPathsToImportedAttrs/dir) 44 - ./testPathsToImportedAttrs/foo.nix 45 - ./testPathsToImportedAttrs/bar.nix 46 - ./testPathsToImportedAttrs/t.nix 47 - ./testPathsToImportedAttrs/f.nix 48 - ]; 49 - 50 - expected = { 51 - dir = { a = 5; }; 52 - foo = { bar = 1; }; 53 - bar = { foo = 2; }; 54 - t = true; 55 - f = false; 56 - }; 57 - }; 58 - 59 - testRgxToString = lib.testAllTrue [ 60 - (rgxToString ".+x" "vxk" == "vx") 61 - (rgxToString "^fo" "foo" == "fo") 62 - (rgxToString "a?" "a" == "a") 63 - (rgxToString "hat" "foohatbar" == "hat") 64 - ]; 65 - 66 - testSafeReadDir = { 67 - expr = safeReadDir ./profiles // safeReadDir ./nonexistentdir; 68 - expected = { 69 - foo = "directory"; 70 - t = "directory"; 71 - }; 72 - }; 73 - 74 - testSuites = 75 - let 76 - profiles = os.mkProfileAttrs (toString ./profiles); 77 - users = ""; 78 - userProfiles = ""; 79 - suites = { profiles, ... }: { 80 - system.bar = [ profiles.foo ]; 81 - }; 82 - in 83 - { 84 - expr = os.mkSuites { inherit profiles users userProfiles suites; }; 85 - expected = { 86 - system = { 87 - bar = [ profiles.foo.default ]; 88 - allProfiles = [ profiles.foo.default profiles.t.default ]; 89 - allUsers = [ ]; 90 - }; 91 - }; 92 - }; 93 - }
-3
lib/pkgs-lib/tests/profiles/foo/default.nix
··· 1 - { 2 - bar = 5; 3 - }
-1
lib/pkgs-lib/tests/profiles/t/default.nix
··· 1 -
lib/pkgs-lib/tests/testPathsIn/bar

This is a binary file and will not be displayed.

lib/pkgs-lib/tests/testPathsIn/baz

This is a binary file and will not be displayed.

lib/pkgs-lib/tests/testPathsIn/foo

This is a binary file and will not be displayed.

-1
lib/pkgs-lib/tests/testPathsToImportedAttrs/bar.nix
··· 1 - { foo = 2; }
-1
lib/pkgs-lib/tests/testPathsToImportedAttrs/dir/default.nix
··· 1 - { a = 5; }
-1
lib/pkgs-lib/tests/testPathsToImportedAttrs/f.nix
··· 1 - true && false
-1
lib/pkgs-lib/tests/testPathsToImportedAttrs/foo.nix
··· 1 - { bar = 1; }
-1
lib/pkgs-lib/tests/testPathsToImportedAttrs/t.nix
··· 1 - true || false
-20
lib/strings.nix
··· 1 - { lib, ... }: 2 - { 3 - # returns matching part of _regex_ _string_; null indicates failure. 4 - rgxToString = regex: string: 5 - let 6 - match = 7 - let 8 - head = lib.substring 0 1 regex; 9 - sec = lib.substring 1 2 regex; 10 - in 11 - if head == "^" 12 - || head == "." 13 - || (sec == "*" || sec == "+" || sec == "?") 14 - then builtins.match "(${regex}).*" string 15 - else builtins.match ".*(${regex}).*" string; 16 - in 17 - if lib.isList match 18 - then lib.head match 19 - else null; 20 - }
+30
modules/customBuilds.nix
··· 1 + { lib, self, diggaLib, config, modules, channel, ... }: 2 + let 3 + mkBuild = buildModule: 4 + # TODO: get specialArgs as a module argument and drop builderArgs usage 5 + channel.input.lib.nixosSystem (diggaLib.mergeAny config.lib.builderArgs { 6 + modules = [ buildModule ]; 7 + }); 8 + in 9 + { 10 + system.build = { 11 + iso = (mkBuild (diggaLib.modules.isoConfig { 12 + inherit self; 13 + inherit (self) inputs; 14 + fullHostConfig = config; 15 + })).config.system.build.isoImage; 16 + 17 + homes = (mkBuild ({ config, ... }: { 18 + home-manager.useUserPackages = lib.mkForce false; 19 + home-manager.sharedModules = [ 20 + { 21 + home.sessionVariables = { 22 + inherit (config.environment.sessionVariables) NIX_PATH; 23 + }; 24 + xdg.configFile."nix/registry.json".text = 25 + config.environment.etc."nix/registry.json".text; 26 + } 27 + ]; 28 + })).config.home-manager.users; 29 + }; 30 + }
+28
overlays/overrides.nix
··· 1 + channels: final: prev: { 2 + 3 + __dontExport = true; # overrides clutter up actual creations 4 + 5 + inherit (channels.latest) 6 + cachix 7 + dhall 8 + discord 9 + element-desktop 10 + manix 11 + nixpkgs-fmt 12 + qutebrowser 13 + signal-desktop 14 + starship; 15 + 16 + 17 + haskellPackages = prev.haskellPackages.override { 18 + overrides = hfinal: hprev: 19 + let version = prev.lib.replaceChars [ "." ] [ "" ] prev.ghc.version; 20 + in 21 + { 22 + # same for haskell packages, matching ghc versions 23 + inherit (channels.latest.haskell.packages."ghc${version}") 24 + haskell-language-server; 25 + }; 26 + }; 27 + 28 + }
+2 -3
profiles/core/default.nix
··· 1 - { config, lib, pkgs, ... }: 1 + { self, config, lib, pkgs, ... }: 2 2 let inherit (lib) fileContents; 3 3 in 4 4 { ··· 12 12 binutils 13 13 coreutils 14 14 curl 15 - deploy-rs 16 15 direnv 17 16 dnsutils 18 17 dosfstools ··· 77 76 ''; 78 77 79 78 # fix nixos-option 80 - nixos-option = "nixos-option -I nixpkgs=${toString ../../lib/compat}"; 79 + nixos-option = "nixos-option -I nixpkgs=${self}/lib/compat"; 81 80 82 81 # sudo 83 82 s = ifSudo "sudo -E ";