refactor(lib): expose lib to nixos as lib'
This commit is contained in:
parent
4e2ae9fdfd
commit
f4770f1908
3 changed files with 45 additions and 35 deletions
|
@ -25,3 +25,4 @@ big warning shouting at them, I feel like showing off. :^)
|
|||
- [tinted-theming](https://github.com/tinted-theming) - used their base16
|
||||
stuff when needed.
|
||||
- [fdncred](https://github.com/fdncred) - made the `ls` alias i use
|
||||
- [diniamo](https://github.com/diniamo) - used his idea of importing a custom lib into nixos
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
self,
|
||||
...
|
||||
}: let
|
||||
inherit (self) lib;
|
||||
inherit (self.lib) mkHosts;
|
||||
in {
|
||||
flake = {
|
||||
nixosConfigurations = builtins.mapAttrs (n: v: lib.mkHost (v // {host = n;})) {
|
||||
nixosConfigurations = mkHosts {
|
||||
solterra = {
|
||||
system = "x86_64-linux";
|
||||
extraModules = [
|
||||
|
|
|
@ -3,46 +3,55 @@
|
|||
self,
|
||||
...
|
||||
}: {
|
||||
flake.lib = inputs.nixpkgs.lib.extend (_: _: {
|
||||
flake.lib = let
|
||||
inherit (inputs.nixpkgs.lib) nixosSystem;
|
||||
inherit (builtins) mapAttrs;
|
||||
mkHost = {
|
||||
host,
|
||||
hostname,
|
||||
system,
|
||||
extraModules ? [],
|
||||
extraSpecialArgs ? {},
|
||||
}:
|
||||
inputs.nixpkgs.lib.nixosSystem {
|
||||
nixosSystem {
|
||||
inherit system;
|
||||
specialArgs = {inherit inputs self;} // extraSpecialArgs;
|
||||
modules =
|
||||
extraModules
|
||||
++ [
|
||||
../hosts/${host}
|
||||
inputs.self.nixosModules.default
|
||||
({config, ...}: {
|
||||
config = {
|
||||
nix = {
|
||||
settings.extra-experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
];
|
||||
gc = {
|
||||
automatic = true;
|
||||
dates = "weekly";
|
||||
};
|
||||
};
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
environment.shellAliases = {
|
||||
rebs = "nixos-rebuild --use-remote-sudo switch --flake .#${host}";
|
||||
rebt = "nixos-rebuild --use-remote-sudo test --flake .#${host}";
|
||||
};
|
||||
networking.hostName = host;
|
||||
systemd.oomd = {
|
||||
enableRootSlice = true;
|
||||
[
|
||||
../hosts/${hostname}
|
||||
self.nixosModules.default
|
||||
{
|
||||
_module.args = {
|
||||
lib' = self.lib;
|
||||
inherit system;
|
||||
};
|
||||
|
||||
nixpkgs = {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
}
|
||||
{
|
||||
networking.hostName = hostname;
|
||||
nix = {
|
||||
settings.extra-experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
];
|
||||
gc = {
|
||||
automatic = true;
|
||||
dates = "weekly";
|
||||
};
|
||||
};
|
||||
})
|
||||
];
|
||||
specialArgs = {
|
||||
inherit inputs self;
|
||||
};
|
||||
systemd.oomd = {
|
||||
enableRootSlice = true;
|
||||
extraConfig = {DefaultMemoryPressureDurationSec = "20s";};
|
||||
};
|
||||
}
|
||||
]
|
||||
++ extraModules;
|
||||
};
|
||||
});
|
||||
mkHosts = mapAttrs (hostname: args: mkHost (args // {inherit hostname;}));
|
||||
in {
|
||||
inherit mkHosts;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue