From 4ba33ec946191c26426c4c937f4273ace74b67ae Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 8 Jul 2024 13:42:36 +0200 Subject: [PATCH 1/2] chore: Remove unused bindings --- devShell.nix | 1 - lib/mkFlake.nix | 7 ------- lib/options.nix | 2 +- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/devShell.nix b/devShell.nix index 1b4ed46f..6daaa1ec 100644 --- a/devShell.nix +++ b/devShell.nix @@ -18,7 +18,6 @@ let devshell = import devshellSrc { inherit system; }; withCategory = category: attrset: attrset // { inherit category; }; - util = withCategory "utils"; rootDir = "$PRJ_ROOT"; diff --git a/lib/mkFlake.nix b/lib/mkFlake.nix index 5925b770..e1b93240 100644 --- a/lib/mkFlake.nix +++ b/lib/mkFlake.nix @@ -28,22 +28,15 @@ let reverseList ; inherit (builtins) - pathExists attrNames attrValues concatMap concatStringsSep - elemAt - filter foldl' - genList head - isString - length listToAttrs mapAttrs removeAttrs - split tail ; diff --git a/lib/options.nix b/lib/options.nix index 5904f454..b5c6ed67 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -1,7 +1,7 @@ { lib, config, inputs, ... }: let - inherit (lib) mkIf filterAttrs mapAttrsToList mapAttrs' mkOption types; + inherit (lib) mkIf filterAttrs mapAttrs' mkOption types; mkFalseOption = description: mkOption { inherit description; default = false; From ac06c59ab0e5cb239afd3dec4c3c86be648ed938 Mon Sep 17 00:00:00 2001 From: Gytis Ivaskevicius Date: Tue, 30 Jul 2024 21:16:59 +0300 Subject: [PATCH 2/2] chore: cleanup with statix --- lib/exportPackages.nix | 2 +- lib/internal-functions.nix | 4 ++-- lib/mkFlake.nix | 6 +++--- lib/options.nix | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/exportPackages.nix b/lib/exportPackages.nix index 99785625..b9e1f0cb 100644 --- a/lib/exportPackages.nix +++ b/lib/exportPackages.nix @@ -78,7 +78,7 @@ let # fold list into one attribute set exportPackages = foldl' (lhs: rhs: lhs // rhs) { } exportPackagesList; - system = (head (attrValues channels)).system; + inherit ((head (attrValues channels))) system; in # flatten nested sets with "/" delimiter then drop disallowed packages diff --git a/lib/internal-functions.nix b/lib/internal-functions.nix index b780a028..65c7be00 100644 --- a/lib/internal-functions.nix +++ b/lib/internal-functions.nix @@ -1,7 +1,7 @@ with builtins; rec { filterAttrs = pred: set: - listToAttrs (concatMap (name: let value = set.${name}; in if pred name value then [ ({ inherit name value; }) ] else [ ]) (attrNames set)); + listToAttrs (concatMap (name: let value = set.${name}; in if pred name value then [{ inherit name value; }] else [ ]) (attrNames set)); /* Generate an attribute set by mapping a function over a list of attribute names. @@ -40,7 +40,7 @@ rec { => [ "nix" "json" "yaml" ] */ partitionString = sep: s: - filter (v: isString v) (split "${sep}" s); + filter isString (split "${sep}" s); # Returns the type of a path: regular (for file), symlink, or directory pathType = p: getAttr (baseNameOf p) (readDir (dirOf p)); diff --git a/lib/mkFlake.nix b/lib/mkFlake.nix index e1b93240..3beab5aa 100644 --- a/lib/mkFlake.nix +++ b/lib/mkFlake.nix @@ -96,7 +96,7 @@ let /* nixos specific arguments */ # Use lib from patched nixpkgs - lib = selectedNixpkgs.lib; + inherit (selectedNixpkgs) lib; # Use nixos modules from patched nixpkgs baseModules = import (patchedChannel + "/nixos/modules/module-list.nix"); nixosSpecialArgs = @@ -149,7 +149,7 @@ let import patchedChannel { inherit (host) system; - overlays = selectedNixpkgs.overlays; + inherit (selectedNixpkgs) overlays; config = selectedNixpkgs.config // hostConfig.nixpkgs.config; } // { inherit (selectedNixpkgs) name input; }; nixpkgs.config = lib.mkForce { }; @@ -194,7 +194,7 @@ mergeAny otherArguments ( (system: let filterAttrs = pred: set: - listToAttrs (concatMap (name: let value = set.${name}; in if pred name value then [ ({ inherit name value; }) ] else [ ]) (attrNames set)); + listToAttrs (concatMap (name: let value = set.${name}; in if pred name value then [{ inherit name value; }] else [ ]) (attrNames set)); # Little hack, we make sure that `legacyPackages` contains `nix` to make sure that we are dealing with nixpkgs. # For some odd reason `devshell` contains `legacyPackages` out put as well diff --git a/lib/options.nix b/lib/options.nix index b5c6ed67..b4de2205 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -18,10 +18,10 @@ let cfg = config.nix; in { - options = { - nix.generateNixPathFromInputs = mkFalseOption "Generate NIX_PATH from available inputs."; - nix.generateRegistryFromInputs = mkFalseOption "Generate Nix registry from available inputs."; - nix.linkInputs = mkFalseOption "Symlink inputs to /etc/nix/inputs."; + options.nix = { + generateNixPathFromInputs = mkFalseOption "Generate NIX_PATH from available inputs."; + generateRegistryFromInputs = mkFalseOption "Generate Nix registry from available inputs."; + linkInputs = mkFalseOption "Symlink inputs to /etc/nix/inputs."; }; config = {