modules/system: flatten

This commit is contained in:
Nikodem Rabuliński 2025-01-04 19:59:42 +01:00
parent 52c84814e8
commit 5c3f1dac68
14 changed files with 65 additions and 70 deletions

View file

@ -1,4 +1,5 @@
{
config,
inputs,
...
}:
@ -7,7 +8,6 @@ let
in
{
imports = [
./system
flakeModule
];
@ -20,4 +20,20 @@ in
settei = flakeModule;
default = settei;
};
flake.nixosModules = rec {
settei = import ./system {
inherit (config) perInput;
isLinux = true;
};
default = settei;
};
flake.darwinModules = rec {
settei = import ./system {
inherit (config) perInput;
isLinux = false;
};
default = settei;
};
}

View file

@ -1,21 +1,50 @@
{ config, lib, ... }:
{
flake =
lib.genAttrs
[
"nixosModules"
"darwinModules"
]
(
attr:
let
isLinux = lib.hasPrefix "nixos" attr;
in
{
settei = import ./settei {
inherit (config) perInput;
inherit isLinux;
};
}
);
perInput,
# TODO: Figure out a nicer way of doing this without infrec?
isLinux,
}:
{
config,
configurationName,
lib,
pkgs,
inputs,
inputs',
username,
...
}:
{
_file = ./default.nix;
imports = [
(import ./sane-defaults.nix { inherit isLinux; })
(import ./flake-qol.nix { inherit perInput; })
./user.nix
(import ./programs { inherit isLinux; })
(import ./tailscale.nix { inherit isLinux; })
(import ./containers.nix { inherit isLinux; })
./unfree.nix
(import ./hercules.nix { inherit isLinux; })
(import ./github-runner.nix { inherit isLinux; })
(import ./incus.nix { inherit isLinux; })
(import ./monitoring.nix { inherit isLinux; })
];
options.settei = with lib; {
username = mkOption {
type = types.str;
default = "niko";
};
};
config = {
programs.fish.enable = true;
users.users.${username}.shell = pkgs.fish;
time.timeZone = lib.mkDefault "Europe/Warsaw";
# NixOS' fish module doesn't allow setting what package to use for fish,
# so I need to override the fish package.
nixpkgs.overlays = [ (_: _: { inherit (inputs'.settei.packages) fish; }) ];
};
}

View file

@ -1,50 +0,0 @@
{
perInput,
# TODO: Figure out a nicer way of doing this without infrec?
isLinux,
}:
{
config,
configurationName,
lib,
pkgs,
inputs,
inputs',
username,
...
}:
{
_file = ./default.nix;
imports = [
(import ./sane-defaults.nix { inherit isLinux; })
(import ./flake-qol.nix { inherit perInput; })
./user.nix
(import ./programs { inherit isLinux; })
(import ./tailscale.nix { inherit isLinux; })
(import ./containers.nix { inherit isLinux; })
./unfree.nix
(import ./hercules.nix { inherit isLinux; })
(import ./github-runner.nix { inherit isLinux; })
(import ./incus.nix { inherit isLinux; })
(import ./monitoring.nix { inherit isLinux; })
];
options.settei = with lib; {
username = mkOption {
type = types.str;
default = "niko";
};
};
config = {
programs.fish.enable = true;
users.users.${username}.shell = pkgs.fish;
time.timeZone = lib.mkDefault "Europe/Warsaw";
# NixOS' fish module doesn't allow setting what package to use for fish,
# so I need to override the fish package.
nixpkgs.overlays = [ (_: _: { inherit (inputs'.settei.packages) fish; }) ];
};
}