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
|
- [tinted-theming](https://github.com/tinted-theming) - used their base16
|
||||||
stuff when needed.
|
stuff when needed.
|
||||||
- [fdncred](https://github.com/fdncred) - made the `ls` alias i use
|
- [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,
|
self,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (self) lib;
|
inherit (self.lib) mkHosts;
|
||||||
in {
|
in {
|
||||||
flake = {
|
flake = {
|
||||||
nixosConfigurations = builtins.mapAttrs (n: v: lib.mkHost (v // {host = n;})) {
|
nixosConfigurations = mkHosts {
|
||||||
solterra = {
|
solterra = {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
extraModules = [
|
extraModules = [
|
||||||
|
|
|
@ -3,21 +3,35 @@
|
||||||
self,
|
self,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
flake.lib = inputs.nixpkgs.lib.extend (_: _: {
|
flake.lib = let
|
||||||
|
inherit (inputs.nixpkgs.lib) nixosSystem;
|
||||||
|
inherit (builtins) mapAttrs;
|
||||||
mkHost = {
|
mkHost = {
|
||||||
host,
|
hostname,
|
||||||
system,
|
system,
|
||||||
extraModules ? [],
|
extraModules ? [],
|
||||||
|
extraSpecialArgs ? {},
|
||||||
}:
|
}:
|
||||||
inputs.nixpkgs.lib.nixosSystem {
|
nixosSystem {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
specialArgs = {inherit inputs self;} // extraSpecialArgs;
|
||||||
modules =
|
modules =
|
||||||
extraModules
|
[
|
||||||
++ [
|
../hosts/${hostname}
|
||||||
../hosts/${host}
|
self.nixosModules.default
|
||||||
inputs.self.nixosModules.default
|
{
|
||||||
({config, ...}: {
|
_module.args = {
|
||||||
config = {
|
lib' = self.lib;
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
|
||||||
|
nixpkgs = {
|
||||||
|
inherit system;
|
||||||
|
config.allowUnfree = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
networking.hostName = hostname;
|
||||||
nix = {
|
nix = {
|
||||||
settings.extra-experimental-features = [
|
settings.extra-experimental-features = [
|
||||||
"nix-command"
|
"nix-command"
|
||||||
|
@ -28,21 +42,16 @@
|
||||||
dates = "weekly";
|
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 = {
|
systemd.oomd = {
|
||||||
enableRootSlice = true;
|
enableRootSlice = true;
|
||||||
|
extraConfig = {DefaultMemoryPressureDurationSec = "20s";};
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
]
|
||||||
|
++ extraModules;
|
||||||
};
|
};
|
||||||
})
|
mkHosts = mapAttrs (hostname: args: mkHost (args // {inherit hostname;}));
|
||||||
];
|
in {
|
||||||
specialArgs = {
|
inherit mkHosts;
|
||||||
inherit inputs self;
|
|
||||||
};
|
};
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue