Minor changes

- Redid the flake module to be based on extendModules instead
- Added wrappers
- Refactored code
- Updated dependencies
This commit is contained in:
Nikodem Rabuliński 2023-08-31 22:27:07 +02:00
parent 9661927410
commit ee7223ca36
No known key found for this signature in database
GPG key ID: FF629AA9E08138DB
19 changed files with 468 additions and 97 deletions

View file

@ -1,4 +1,4 @@
{...}: {
{
imports = [
./nixos
./flake

View file

@ -10,11 +10,6 @@
}: let
inherit (lib) mkOption mapAttrs;
inherit (flake-parts-lib) mkSubmoduleOptions;
possibleConfigurations = {
nixos = {};
darwin = {};
home = {};
};
in {
_file = ./configurations.nix;
@ -24,29 +19,18 @@ in {
builders = {
nixos = mkOption {
type = lib.types.functionTo lib.types.unspecified;
default = nixpkgs.lib.nixosSystem;
default = _name: nixpkgs.lib.nixosSystem;
};
darwin = mkOption {
type = lib.types.functionTo lib.types.unspecified;
default = darwin.lib.darwinSystem;
default = _name: darwin.lib.darwinSystem;
};
home = mkOption {
type = lib.types.functionTo lib.types.unspecified;
default = home-manager.lib.homeManagerConfiguration;
default = _name: home-manager.lib.homeManagerConfiguration;
};
};
# Those functions map the value of the configuration attribute
# and emit a list of arguments to be passed to respected evalModules
mappers =
mapAttrs
(_: _:
mkOption {
type = lib.types.functionTo lib.types.attrs;
default = lib.id;
})
possibleConfigurations;
configurations = {
nixos = mkOption {
type = lib.types.unspecified;
@ -61,42 +45,21 @@ in {
default = {};
};
};
# This is exposed so that it's possible to modify the arguments that get passed to a builder
# after they have been mapped. Probably shouldn't do it. Probably should remove it or make it read-only
configurationOptions =
mapAttrs
(_: _:
mkOption {
type = lib.types.attrsOf lib.types.attrs;
})
possibleConfigurations;
};
config = {
configurationOptions =
mapAttrs
(
name: _:
mapAttrs
(configurationName: val: let
mapped = config.mappers.${name} val;
# TODO: specialArgs is actually extraSpecialArgs in home-manager.
# At which level should that be handled?
defaultArgs = {
specialArgs = {inherit configurationName;};
};
in
lib.recursiveUpdate defaultArgs mapped)
config.configurations.${name}
)
possibleConfigurations;
config.
flake = {
nixosConfigurations =
mapAttrs
(_: args: config.builders.nixos args)
config.configurationOptions.nixos;
};
nixosConfigurations =
mapAttrs
config.builders.nixos
config.configurations.nixos;
darwinConfigurations =
mapAttrs
config.builders.darwin
config.configurations.darwin;
homeConfigurations =
mapAttrs
config.builders.home
config.configurations.home;
};
}

View file

@ -45,6 +45,16 @@
experimental-features = ["nix-command" "flakes" "repl-flake" "auto-allocate-uids"];
trusted-users = [username];
auto-allocate-uids = true;
extra-substituters = [
"https://hyprland.cachix.org"
"https://cache.garnix.io"
"https://nix-community.cachix.org"
];
trusted-public-keys = [
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
};