diff --git a/default.nix b/default.nix index b19997de..4c423dcd 100644 --- a/default.nix +++ b/default.nix @@ -1,12 +1,15 @@ -{ pkgs ? import { } -, withSandboxSupport ? false -, withAutocomplete ? true -, withNom ? false +{ + pkgs ? import { }, + withSandboxSupport ? false, + withAutocomplete ? true, + withNom ? false, }: with pkgs; let - withNom' = withNom && (builtins.tryEval (builtins.elem buildPlatform.system pkgs.ghc.meta.platforms)).value or false; + withNom' = + withNom + && (builtins.tryEval (builtins.elem buildPlatform.system pkgs.ghc.meta.platforms)).value or false; in python3.pkgs.buildPythonApplication { name = "nixpkgs-review"; @@ -24,8 +27,7 @@ python3.pkgs.buildPythonApplication { python3.pkgs.pytest pkgs.nixVersions.stable or nix_2_4 git - ] ++ lib.optional withSandboxSupport bubblewrap - ++ lib.optional withNom' nix-output-monitor; + ] ++ lib.optional withSandboxSupport bubblewrap ++ lib.optional withNom' nix-output-monitor; checkPhase = '' echo -e "\x1b[32m## run nixpkgs-review --help\x1b[0m" @@ -34,9 +36,10 @@ python3.pkgs.buildPythonApplication { ''; makeWrapperArgs = let - binPath = [ pkgs.nixVersions.stable or nix_2_4 git ] - ++ lib.optional withSandboxSupport bubblewrap - ++ lib.optional withNom' nix-output-monitor; + binPath = [ + pkgs.nixVersions.stable or nix_2_4 + git + ] ++ lib.optional withSandboxSupport bubblewrap ++ lib.optional withNom' nix-output-monitor; in [ "--prefix PATH : ${lib.makeBinPath binPath}" diff --git a/flake.nix b/flake.nix index 35fceafe..b25fcf1f 100644 --- a/flake.nix +++ b/flake.nix @@ -10,27 +10,42 @@ treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = inputs @ { flake-parts, ... }: - flake-parts.lib.mkFlake { inherit inputs; } ({ lib, ... }: { - imports = [ ./treefmt.nix ]; - systems = [ - "aarch64-linux" - "x86_64-linux" - "riscv64-linux" + outputs = + inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } ( + { lib, ... }: + { + imports = [ ./treefmt.nix ]; + systems = [ + "aarch64-linux" + "x86_64-linux" + "riscv64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; - perSystem = { config, pkgs, self', ... }: { - packages = { - nixpkgs-review = pkgs.callPackage ./. { }; - default = config.packages.nixpkgs-review; - } // lib.optionalAttrs (pkgs.stdenv.isLinux) { - nixpkgs-review-sandbox = pkgs.callPackage ./. { withSandboxSupport = true; }; - }; - devShells = { - default = (self'.packages.nixpkgs-review-sandbox or self'.packages.nixpkgs-review).override { withNom = true; }; - }; - }; - }); + "x86_64-darwin" + "aarch64-darwin" + ]; + perSystem = + { + config, + pkgs, + self', + ... + }: + { + packages = + { + nixpkgs-review = pkgs.callPackage ./. { }; + default = config.packages.nixpkgs-review; + } + // lib.optionalAttrs (pkgs.stdenv.isLinux) { + nixpkgs-review-sandbox = pkgs.callPackage ./. { withSandboxSupport = true; }; + }; + devShells = { + default = (self'.packages.nixpkgs-review-sandbox or self'.packages.nixpkgs-review).override { + withNom = true; + }; + }; + }; + } + ); } diff --git a/nixpkgs_review/nix/evalAttrs.nix b/nixpkgs_review/nix/evalAttrs.nix index 01e5ff3a..90eb64a5 100644 --- a/nixpkgs_review/nix/evalAttrs.nix +++ b/nixpkgs_review/nix/evalAttrs.nix @@ -11,7 +11,8 @@ let inherit (pkgs) lib; attrs = fromJSON (readFile attr-json); - getProperties = name: + getProperties = + name: let attrPath = lib.splitString "." name; pkg = lib.attrByPath attrPath null pkgs; @@ -27,19 +28,18 @@ let }) ] else - lib.flip map pkg.outputs or [ "out" ] (output: + lib.flip map pkg.outputs or [ "out" ] ( + output: let # some packages are set to null if they aren't compatible with a platform or package set maybePath = tryEval "${lib.getOutput output pkg}"; broken = !exists || !maybePath.success; in - lib.nameValuePair - (if output == "out" then name else "${name}.${output}") - { - inherit exists broken; - path = if !broken then maybePath.value else null; - drvPath = if !broken then pkg.drvPath else null; - } + lib.nameValuePair (if output == "out" then name else "${name}.${output}") { + inherit exists broken; + path = if !broken then maybePath.value else null; + drvPath = if !broken then pkg.drvPath else null; + } ); in diff --git a/nixpkgs_review/nix/review-shell.nix b/nixpkgs_review/nix/review-shell.nix index d78007d6..7b0c318f 100644 --- a/nixpkgs_review/nix/review-shell.nix +++ b/nixpkgs_review/nix/review-shell.nix @@ -1,16 +1,16 @@ -{ local-system -, nixpkgs-config-path -, # Path to Nix file containing the Nixpkgs config - attrs-path -, # Path to Nix file containing a list of attributes to build - nixpkgs-path -, # Path to this review's nixpkgs +{ + local-system, + nixpkgs-config-path, + # Path to Nix file containing the Nixpkgs config + attrs-path, + # Path to Nix file containing a list of attributes to build + nixpkgs-path, + # Path to this review's nixpkgs local-pkgs ? import nixpkgs-path { system = local-system; config = import nixpkgs-config-path; - } -, lib ? local-pkgs.lib -, + }, + lib ? local-pkgs.lib, }: let diff --git a/shell.nix b/shell.nix index d6c62595..d61716d4 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,6 @@ -{ pkgs ? import { } }: +{ + pkgs ? import { }, +}: with pkgs; diff --git a/tests/assets/nixpkgs/default.nix b/tests/assets/nixpkgs/default.nix index 785557ce..17c2b7b3 100644 --- a/tests/assets/nixpkgs/default.nix +++ b/tests/assets/nixpkgs/default.nix @@ -1,16 +1,19 @@ -{ config ? { }, system ? null } @ args: +{ + config ? { }, + # deadnix: skip + system ? null, +}@args: let - pkgs = - import "@NIXPKGS@" (args // { inherit config; - }); - in { - pkg1 = pkgs.stdenv.mkDerivation { + pkgs = import "@NIXPKGS@" (args // { inherit config; }); +in +{ + pkg1 = pkgs.stdenv.mkDerivation { name = "pkg1"; dontUnpack = true; installPhase = '' install -D ${./pkg1.txt} $out/foo ''; - }; - # hack to not break evaluation with nixpkgs_review/nix/*.nix - inherit (pkgs) lib mkShell bashInteractive; - } + }; + # hack to not break evaluation with nixpkgs_review/nix/*.nix + inherit (pkgs) lib mkShell bashInteractive; +}