added util to lib

This commit is contained in:
Leyla Becker 2024-10-03 22:42:30 +02:00
parent dd6046af27
commit 2d6b16950b
3 changed files with 17 additions and 12 deletions

View file

@ -67,13 +67,14 @@
"x86_64-linux"
];
forEachPkgs = lambda: forEachSystem (system: lambda nixpkgs.legacyPackages.${system});
in {
packages = forEachPkgs (pkgs: import ./pkgs {inherit pkgs;});
callPackage = nixpkgs.lib.callPackageWith (nixpkgs // { lib = lib; });
lib = callPackage ./util {} // nixpkgs.lib;
in {
nixosConfigurations = {
# Leyla Laptop
horizon = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs;};
specialArgs = {inherit inputs lib;};
modules = [
home-manager.nixosModules.home-manager home-manager-config
./hosts/horizon/configuration.nix
@ -82,7 +83,7 @@
};
# Leyla Desktop
twilight = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs;};
specialArgs = {inherit inputs lib;};
modules = [
home-manager.nixosModules.home-manager home-manager-config
./hosts/twilight/configuration.nix
@ -90,7 +91,7 @@
};
# NAS Service
defiant = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs;};
specialArgs = {inherit inputs lib;};
modules = [
disko.nixosModules.disko
home-manager.nixosModules.home-manager home-manager-config

View file

@ -23,7 +23,7 @@ in {
extraGroups = lib.mkMerge [
["networkmanager" "wheel"]
(
lib.mkIf (!cfg.isThinUser) ["adbusers"]
lib.mkUnless cfg.isThinUser ["adbusers"]
)
];

View file

@ -1,7 +1,11 @@
_: {
# mkUnless = condition: then: (mkIf (!condition) then);
# mkIfElse = condition: then: else: lib.mkMerge [
# (mkIf condition then)
# (mkUnless condition else)
# ];
{
lib,
...
}:
{
mkUnless = condition: yes: (lib.mkIf (!condition) yes);
mkIfElse = condition: yes: no: lib.mkMerge [
(lib.mkIf condition yes)
(lib.mkUnless condition no)
];
}