From 7acde21fc5fdc653a5b5eef373badc7828316d4f Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Fri, 13 May 2022 11:14:11 -0600 Subject: [PATCH] feat: add an overlay --- flake.nix | 73 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/flake.nix b/flake.nix index 2612689..142716e 100644 --- a/flake.nix +++ b/flake.nix @@ -15,41 +15,7 @@ nixpkgsForHost = host: import inputs.nixpkgs { - overlays = [ - (self: super: { - alejandra = self.rustPlatform.buildRustPackage { - pname = "alejandra"; - inherit version; - src = self.stdenv.mkDerivation { - name = "src"; - builder = builtins.toFile "builder.sh" '' - source $stdenv/setup - - mkdir $out - cp -rT --no-preserve=mode,ownership $src $out/src/ - cp $cargoLock $out/Cargo.lock - cp $cargoToml $out/Cargo.toml - ''; - cargoLock = ./Cargo.lock; - cargoToml = ./Cargo.toml; - src = ./src; - }; - cargoLock.lockFile = ./Cargo.lock; - - passthru.tests = { - version = self.testVersion {package = super.alejandra;}; - }; - - meta = { - description = "The Uncompromising Nix Code Formatter."; - homepage = "https://github.com/kamadorueda/alejandra"; - license = self.lib.licenses.unlicense; - maintainers = [self.lib.maintainers.kamadorueda]; - platforms = self.lib.systems.doubles.all; - }; - }; - }) - ]; + overlays = [overlay]; system = host; }; @@ -59,6 +25,40 @@ nixpkgs."x86_64-darwin" = nixpkgsForHost "x86_64-darwin"; nixpkgs."x86_64-linux" = nixpkgsForHost "x86_64-linux"; + overlay = final: prev: { + alejandra = final.rustPlatform.buildRustPackage { + pname = "alejandra"; + inherit version; + src = final.stdenv.mkDerivation { + name = "src"; + builder = builtins.toFile "builder.sh" '' + source $stdenv/setup + + mkdir $out + cp -rT --no-preserve=mode,ownership $src $out/src/ + cp $cargoLock $out/Cargo.lock + cp $cargoToml $out/Cargo.toml + ''; + cargoLock = ./Cargo.lock; + cargoToml = ./Cargo.toml; + src = ./src; + }; + cargoLock.lockFile = ./Cargo.lock; + + passthru.tests = { + version = final.testVersion {package = prev.alejandra;}; + }; + + meta = { + description = "The Uncompromising Nix Code Formatter."; + homepage = "https://github.com/kamadorueda/alejandra"; + license = final.lib.licenses.unlicense; + maintainers = [final.lib.maintainers.kamadorueda]; + platforms = final.lib.systems.doubles.all; + }; + }; + }; + buildBinariesForHost = host: pkgs: let binaries = builtins.listToAttrs ( builtins.map (pkg: { @@ -115,6 +115,9 @@ ]; }; + inherit overlay; + overlays.default = overlay; + packages."aarch64-darwin" = with nixpkgs."aarch64-darwin"; buildBinariesForHost "aarch64-darwin" [ alejandra