If a module is an attrset deduplicating imports does not work properly
and would lead to the module system complaining about redefining
options. Here is an example:
error: The option `age.identityPaths' in `/nix/store/wn50ysifrfp5qj5pp3jqpyvwh8ksz36y-source/machines/foo' is already declared in `/nix/store/wn50ysifrfp5qj5pp3jqpyvwh8ksz36y-source/common/ddclient/default.nix'.
when common/ddclient/default.nix and machines/foo/default.nix is:
{ ..., agenix, ... }: {
imports = [
agenix.nixosModules.age
];
}
Turning the module into a filepath fixes the issue.
nix-darwin is detecting `/etc/nix/nix.conf` from the
cachix/install-nix-action and refusing to overwrite it, failing the
nix-darwin activation and therefore the rest of CI.
This commit `mv`s the existing `nix.conf` to avoid the above, and then
adds support for new-style nix commands and flakes to the nix-darwin
configuration to allow their subsequent use in CI.
It also removes the nix config from the `cachix/install-nix-action`
step, which was duplicated effort since we are blowing it away with
nix-darwin anyway.
Relevant:
- https://github.com/LnL7/nix-darwin/issues/149
Why
===
* flake.nix had a lot of almost redundant lines in it.
* i686 support is probably being dropped soon in nixpkgs
https://github.com/NixOS/nixpkgs/pull/266164
What changed
==
* Add new input nix-systems/default which represents the default
systems typically used in the Nix community
* Define and use an eachSystem function that simplifies the flake.nix file
This adds a “default” NixOS module in flake.nix. This makes using this in flakes a little less verbose and repetitive.
Before this change:
```nix
nixpkgs.lib.nixosSystem {
modules = [
./configuration.nix
agenix.nixosModules.age
];
}
After this change:
```nix
nixpkgs.lib.nixosSystem {
modules = [
./configuration.nix
agenix.nixosModule
];
}
```
flake.lock previously included a "indirect" reference to nixpkgs.
I am not sure what this means but I added `inputs.nixpkgs` and updated nixpkgs because this old version of nixpkgs didn't have any support for aarch64-darwin at all.
Now on a aarch64-darwin I can type `nix build` and get a working version of agenix.
Flake outputs are a mixture of system-dependent and system-independent
sets, and flake-utils doesn't do much to distinguish one from the other.
Because of that, the `age` NixOS module currently has to be acessed as
`agenix.nixosModules.${system}.age`, rather than the documented
`agenix.nixosModules.age`.
To remedy that, (conceptually) split `outputs` in two, let flake-utils
handle the system-dependent half, and merge them to form the actual
outputs. The names for the two halves were taken from [1].
[1]: https://github.com/NixOS/nix/issues/3843#issuecomment-661720562