From 2d6b16950b424c10dc8bca6522f057e84d29b723 Mon Sep 17 00:00:00 2001 From: Leyla Becker Date: Thu, 3 Oct 2024 22:42:30 +0200 Subject: [PATCH] added util to lib --- flake.nix | 11 ++++++----- users/leyla/default.nix | 2 +- util/default.nix | 16 ++++++++++------ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/flake.nix b/flake.nix index 6a25fab..bfd7292 100644 --- a/flake.nix +++ b/flake.nix @@ -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 diff --git a/users/leyla/default.nix b/users/leyla/default.nix index a9efe1c..47b3edb 100644 --- a/users/leyla/default.nix +++ b/users/leyla/default.nix @@ -23,7 +23,7 @@ in { extraGroups = lib.mkMerge [ ["networkmanager" "wheel"] ( - lib.mkIf (!cfg.isThinUser) ["adbusers"] + lib.mkUnless cfg.isThinUser ["adbusers"] ) ]; diff --git a/util/default.nix b/util/default.nix index acd1997..3d16bf3 100644 --- a/util/default.nix +++ b/util/default.nix @@ -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) + ]; }