From 5088049295015e0ba303b67cb122b797fbeb6e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 9 May 2022 09:20:56 +0200 Subject: [PATCH] only target single nix version in repo --- .nix-version | 1 + flake.nix | 60 ++++++++++++++++++++++------------------------------ shell.nix | 4 ++-- 3 files changed, 28 insertions(+), 37 deletions(-) create mode 100644 .nix-version diff --git a/.nix-version b/.nix-version new file mode 100644 index 0000000..6842dbd --- /dev/null +++ b/.nix-version @@ -0,0 +1 @@ +unstable diff --git a/flake.nix b/flake.nix index 1156772..971dd6e 100644 --- a/flake.nix +++ b/flake.nix @@ -4,53 +4,43 @@ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: + outputs = + { self + , nixpkgs + , flake-utils + }: + flake-utils.lib.eachDefaultSystem ( + system: let + nixVersion = nixpkgs.lib.fileContents ./.nix-version; pkgs = nixpkgs.legacyPackages.${system}; inherit (pkgs) stdenv; - drvArgs = { srcDir = self; }; + devShell = self.devShells.${system}.default; + drvArgs = { + srcDir = self; + nix = if nixVersion == "unstable" then pkgs.nixUnstable else pkgs.nixVersions."nix_${nixVersion}"; + }; in - rec { + { packages.nix-eval-jobs = pkgs.callPackage ./default.nix drvArgs; - checks = - let - mkVariant = nix: (packages.nix-eval-jobs.override { - inherit nix; - }).overrideAttrs (_: { - name = "nix-eval-jobs-${nix.version}"; - inherit (nix) version; - }); - in - { + checks.treefmt = stdenv.mkDerivation { + name = "treefmt-check"; + src = self; + nativeBuildInputs = devShell.nativeBuildInputs; + dontConfigure = true; - treefmt = - let - devShell = devShells.default; - in - stdenv.mkDerivation { - name = "treefmt-check"; - src = self; - nativeBuildInputs = devShell.nativeBuildInputs; - dontConfigure = true; + inherit (devShell) NODE_PATH; - inherit (devShell) NODE_PATH; + buildPhase = '' + env HOME=$(mktemp -d) treefmt --fail-on-change + ''; - buildPhase = '' - env HOME=$(mktemp -d) treefmt --fail-on-change - ''; - - installPhase = "touch $out"; - }; - - build = mkVariant pkgs.nix; - build-unstable = mkVariant pkgs.nixUnstable; - }; + installPhase = "touch $out"; + }; packages.default = self.packages.${system}.nix-eval-jobs; devShells.default = pkgs.callPackage ./shell.nix drvArgs; - } ); } diff --git a/shell.nix b/shell.nix index ec82a6c..f64215e 100644 --- a/shell.nix +++ b/shell.nix @@ -11,15 +11,15 @@ import nixpkgs { } ) , srcDir ? null +, nix }: let inherit (pkgs) lib stdenv; - nix = pkgs.nixUnstable; in (pkgs.callPackage ./default.nix { - inherit nix srcDir; + inherit srcDir nix; }).overrideAttrs (old: { src = null;